Page MenuHomePhabricator

[blob] Implement cleanup helper functions
ClosedPublic

Authored by bartek on Oct 4 2023, 3:04 AM.
Tags
None
Referenced Files
F3385414: D9351.diff
Fri, Nov 29, 12:16 AM
Unknown Object (File)
Mon, Nov 25, 8:49 PM
Unknown Object (File)
Mon, Nov 25, 1:33 PM
Unknown Object (File)
Mon, Nov 18, 3:32 AM
Unknown Object (File)
Mon, Nov 18, 3:20 AM
Unknown Object (File)
Tue, Nov 12, 2:05 AM
Unknown Object (File)
Sun, Nov 10, 10:30 AM
Unknown Object (File)
Thu, Nov 7, 11:44 AM
Subscribers

Details

Summary

Implementation of helpers introduced in D9350. These are part of the cleanup logic
and are extensively used in the next diff

Depends on D9350

Test Plan

The code compiles, these are tested thoroughly in the next diff

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Oct 4 2023, 3:21 AM

Rebase. Fix filter-map condition

tomek added inline comments.
services/blob/src/database/types.rs
153

Do we need both Eq and PartialEq?

services/blob/src/service.rs
313–323

It is something similar to partition, but I guess it might be challenging to use it when self is a vector.

This revision is now accepted and ready to land.Oct 10 2023, 5:06 AM

LGTM, potentially we could add these optimisations:

  1. Return impl Iterator<> instead of Vec
  2. Return &'self str in blobs_to_find_holders

but I haven't analysed it very thoroughly so there might be lifetime/ergonomics issues

LGTM, potentially we could add these optimisations:

  1. Return impl Iterator<> instead of Vec

Thanks! I'll see if this saves me one unnecessary collect() into Vec

  1. Return &'self str in blobs_to_find_holders

I'll look into this. Anyway, cloning small strings is cheap (holder/blob-hash are usually no longer than 40-50 characters)

services/blob/src/service.rs
313–323

The partition way might be not the most efficient way. Bear in mind that self is a BTreeMap while checked is a Vec.

services/blob/src/database/types.rs
153

Yes, they are needed for HashMap / BTreeMap keys

  1. Return impl Iterator<> instead of Vec

Tried that, but unfortunately these methods are already inside a trait, and it turns out that "return impl trait inside a trait" is unstable 😞 (see also this SO answer)

│  impl Trait only allowed in function and inherent method return types, not in trait method return types rustc (E0562) [500, 39]
│ see issue #91611 https://github.com/rust-lang/rust/issues/91611 for more information

Doing fn foo<T: Iterator<Item = ...>>(&self) -> T; doesn't work either

Rebase on parent diff feedback

This revision was automatically updated to reflect the committed changes.