-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs-index
: Track API
#85
Conversation
Benchmark for c2371c5Click to view benchmark
|
fe60070
to
91645e2
Compare
Benchmark for 95ad4a0Click to view benchmark
|
Benchmark for f653836Click to view benchmark
|
fs-index/README.md
Outdated
@@ -10,6 +10,7 @@ The most important struct in this crate is `ResourceIndex` which comes with: | |||
|
|||
- **Reactive API** | |||
- `update_all`: Method to update the index by rescanning files and returning changes (additions/deletions). | |||
- `update_one`: Method to update the index by rescanning a single file (addition/deletion/modification). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be mentioned in other section. "Reactive" means that we have a stream of updates and we react on these updates, even if we manually poll the stream. But this "cherry-pick" is completely manual approach, not reactive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. What about the term "Selective API"?
@@ -666,3 +666,245 @@ fn test_update_all_files_with_same_hash() { | |||
assert_eq!(index.collisions().len(), 1, "{:?}", index); | |||
}); | |||
} | |||
|
|||
/// Simple test for tracking a single resource addition. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the arklib
PR we also tried to implement an automated test scenario, where we'd test one specific invariant that "any sequence of update_one
calls must be equivalent to update_all
on the full data". My idea how to approach it is something like:
- Start with empty directory.
- Generate an update, randomly one of 3 kinds (modification and deletion could be generated only when we have some files).
- Call
update_one
on the updated file. - In isolation, build new index from the current state of the directory.
- Compare outputs of step 3 and step 4. Must be equal.
This is not exactly a unit test, because it's slow and tests multiple corner cases in one scenario. But I think it must be useful to run it periodically. By the way, I think that Ishan and Pushkar do in fs-storage
with property-based testing should reflect the same idea.
Do you think it's feasible to implement in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a plan.
We could create multiple tests to verify this as well.
To do this properly and cleanly, we’ll likely need to set up some helper functions.
Given the scope, I think this should be handled in its own PR. This current PR is blocking #36, so once it's merged, I can add the additional tests along with the index watch API.
What do you think?
Benchmark for ac3828dClick to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks great 👍
Signed-off-by: Tarek <[email protected]>
Signed-off-by: Tarek <[email protected]>
Signed-off-by: Tarek <[email protected]>
Signed-off-by: Tarek <[email protected]>
Signed-off-by: Tarek <[email protected]>
Signed-off-by: Tarek <[email protected]>
Signed-off-by: Tarek <[email protected]>
7b07c9d
to
3ac8300
Compare
Benchmark for 52515f0Click to view benchmark
|
Description
This PR adds a new method to the
ResourceIndex
in thefs-index
crate. The added method,update_one
, allows the index to be updated with the latest information from the file system for a single resource. It handles updates for resources that have been added, removed, or modified.Fixes #84
Changes
ResourceIndex::update_one
test_track_removal
test_track_modification
test_track_removal_with_collision
test_track_addition
test_track_modification_with_collision
test_track_addition_with_collision
index_update_one