lzma: make operation a concrete type #57
Open
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.
Prior to this commit, operation was an interface type, which meant that every call to methods like binTree.NextOp or hashTable.NextOp, which could return either a match op or a literal op, would dynamically allocate memory (and eventually require garbage collection).
After this commit, the "package xz" benchmarks show a modest speed gain and a dramatic fall in the number of allocations.
name old speed new speed delta
Reader-8 28.9MB/s ± 0% 32.0MB/s ± 0% +11.01% (p=0.008 n=5+5)
Writer-8 6.50MB/s ± 0% 6.95MB/s ± 1% +6.99% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
Reader-8 37.3MB ± 0% 15.5MB ± 0% -58.39% (p=0.008 n=5+5)
Writer-8 80.2MB ± 0% 60.8MB ± 0% -24.19% (p=0.000 n=5+4)
name old allocs/op new allocs/op delta
Reader-8 1.21M ± 0% 0.00M ± 0% -99.96% (p=0.008 n=5+5)
Writer-8 1.22M ± 0% 0.00M ± 0% -99.62% (p=0.000 n=5+4)