perf: overwrite file features in place - #2317
Open
John Lyu (PaleNeutron) wants to merge 2 commits into
Open
Conversation
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.
Description
FileFeatureStorage.writewith a fixed-width float32 seek/write for the common case.FeatureStorage.rewriteremains valid.Motivation and Context
The existing overlap path reads the complete feature file and builds multiple pandas objects before rewriting it. It also passes the float32 header value to
range, which raisesTypeErrorfor any overlapping write. Casting that value tointalone is insufficient because the current rewrite omits the start-index header and does not truncate stale trailing bytes.Since each entry is a fixed-width float32, writes that start at or after the current start index can seek directly to the target byte offset and write only the new values. Only left extension needs to shift existing data and rewrite the file.
How Has This Been Tested?
pytest qlib/tests/test_all_pipeline.pyunder upper directory ofqlib.python -m pytest -q tests/storage_tests/test_file_feature_storage.py(4 passed)./tmp(3 passed).TypeError.Screenshots of Test Results (if appropriate):
N/A
Types of changes