Repository navigation
Stop doing work the output doesn't depend on - #84
Merged
Merged
Conversation
Profiling unpack of a 320 KB .key: YAML is 80% of the time, MessageToDict 18%, Protobuf decoding 1.5% and Snappy 0.4%. Packing is the same shape, with yaml.load at 76%. libyaml is installed and used, but CDumper/CLoader only replace the emitter and lexer - the Representer, Resolver and Constructor above them stay pure Python, and a single document builds 118,618 ScalarNode objects. The driver is volume: the YAML form of a document is ~30x the size of the .iwa it came from. Three changes, none of which alter a byte of output: - `ls` no longer decodes anything. It prints names taken from the zip directory, but process_file parsed every archive first and handed the result to a sink that ignored it. 6.3ms -> 0.4ms on table.key, and it scaled with document size for no benefit. Directory listings still report .iwa rather than .iwa.yaml. - A YAML sink is now handed the dict a replacement already produced, instead of rebuilding an IWAFile from it only for the sink to call to_dict() again. Worth ~33% of the per-archive cost, though only archives containing text take that branch, so the real saving scales with how text-heavy a deck is. Binary sinks still get a real IWAFile - they need it to serialize. - Scalar tag resolution is memoized. Resolver.resolve() is a pure function of (value, implicit) for a fixed resolver table, and PyYAML calls it 259,176 times for one document. The cache is bounded. Verified byte-identical output against master for ls, cat, unpack, pack, unpack --replacements and replace, by hashing every produced file. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179M4xvAKPGrgKpy4AeCsM7
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.
Did some profiling with Claude, and found:
Most of the time is spent in Python after YAML ser/de.
To speed things up: