Repository navigation
Keep 'chop --ignore' reading the file in order - #428
Merged
Merged
Conversation
ChopFile's workers seek to each chunk's offset, so the order the chunks are handed over in is the order the file is read in. Filtering rebuilt that list by ranging over a map, and Go randomizes map iteration, so --ignore turned a front-to-back read into a different random walk over the whole file on every run. Sort the survivors by offset again. Keying the filter by chunk ID also collapses repeated chunks, which saves re-reading them, so that stays. The filtering moved into its own function to make the order assertable.
ChopFile's workers seek to each chunk's offset, so the order the chunks are handed over in is the order the file is read in. Filtering rebuilt that list by ranging over a map, and Go randomizes map iteration, so --ignore turned a front-to-back read into a different random walk over the whole file on every run. Sort the survivors by offset again. Keying the filter by chunk ID also collapses repeated chunks, which saves re-reading them, so that stays.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ChopFilestarts a worker per--concurrency, each with its own file handle, and every worker seeks toc.Startbefore reading. The order the chunks are handed over in is therefore the order the file gets read in, and nothing downstream reorders or buffers.Without
--ignorethat list comes straight from the index, in ascending offset order, so the workers read a sliding window that advances through the file. With--ignorethe list was rebuilt by ranging over the filter map, and Go randomizes map iteration deliberately — a different random start bucket per loop — so the file was read in a different random order on every run, with no readahead value and no reproducibility.The survivors are sorted by offset again, which restores the index order exactly since filtering only ever deletes. Keying the filter map by chunk ID also collapses repeated chunks;
ChunkStoragealready skips storing a chunk twice, butreadChunkFromFileruns first, so the dedup still saves a seek and a read per repeat and is kept.The filtering moved into
chunksToStoreso the ordering can be asserted. The test runs it ten times, since one pass of a randomized map proves little, and also checks that no chunk ID is handed over twice and that an unfiltered index is passed through untouched.