Repository navigation
perf: recognise identical files before parsing them - #26
Merged
Merged
Conversation
store_workout parsed every file before asking whether its exact bytes were already stored. Parsing is most of a file's cost, so re-sending an export spent as long as the first import storing nothing: 130 s for 150 FIT activities, enough on its own to hit nginx's 120 s timeout. Check the hash first, then parse only for the same-session check. The retry now takes 0.7 s.
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.
store_workoutparsed each file before checking whether its exact bytes were already stored. Parsing is most of what a file costs, so sending an export a second time took as long as the first import while storing nothing.find_duplicateintofind_identical(hash only, checked before parsing) andfind_same_session(needs the parsed file, as before).main.docs/DESIGN.md: one paragraph on why the hash is checked first.Measured with 150 synthetic Garmin-style FIT activities (1 Hz, avg 131 KB, 11 MB zipped) on PostgreSQL 16, calling
store_archivedirectly:The first import is unchanged (about 1–1.6 s per activity), so a large export still exceeds nginx's 120 s timeout; that is fixed separately by importing archives in the background.
Checks: ruff lint and format, pytest 345 passed, coverage 96.5%.