Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Move steps to decompress from scratch to a separate method #52

Merged
merged 1 commit into from
Feb 7, 2023

Conversation

brantburnett
Copy link
Owner

Motivation

The DecompressAllTags method is overly complicated and the step to decompress from scratch is not a hot path. At most it should be hit once per block when processing a stream and never when processing a block.

Modifications

Move the logic to decompress from scratch to a separate method. Slightly optimize the short-circuit logic as well.

Results

JIT should be able to do a better job of enregistration and preventing register spillage. DecompressAllTags also gets a smaller stack size which may reduce cache misses.

We're seeing some minor gains decompressing from streams on .NET 6/7. The gains are within error margins so hard to confirm, they may be more significant on more constrained systems.

Method Job Runtime ReadSize Mean Error StdDev Median
Inline MediumRun-.NET 6.0 .NET 6.0 16384 180.2 us 1.63 us 2.40 us 179.0 us
MethodCall MediumRun-.NET 6.0 .NET 6.0 16384 179.6 us 2.15 us 2.94 us 178.5 us
Inline MediumRun-.NET 7.0 .NET 7.0 16384 156.0 us 2.23 us 3.19 us 156.7 us
MethodCall MediumRun-.NET 7.0 .NET 7.0 16384 155.8 us 1.55 us 2.22 us 155.6 us
Inline MediumRun-.NET Framework 4.8 .NET Framework 4.8 16384 278.1 us 1.83 us 2.57 us 277.3 us
MethodCall MediumRun-.NET Framework 4.8 .NET Framework 4.8 16384 280.3 us 3.59 us 5.37 us 281.4 us

Motivation
----------
The DecompressAllTags method is overly complicated and the step to
decompress from scratch is not a hot path. At most it should be hit
once per block when processing a stream and never when processing a
block.

Modifications
-------------
Move the logic to decompress from scratch to a separate method. Slightly
optimize the short-circuit logic as well.

Results
-------
JIT should be able to do a better job of enregistration and preventing
register spillage. DecompressAllTags also gets a smaller stack size
which may reduce cache misses.

We're seeing some minor gains decompressing from streams on .NET 6/7.
The gains are within error margins so hard to confirm, they may be
more significant on more constrained systems.

|     Method |                          Job |            Runtime | ReadSize |     Mean |   Error |  StdDev |   Median |
|----------- |----------------------------- |------------------- |--------- |---------:|--------:|--------:|---------:|
|     Inline |           MediumRun-.NET 6.0 |           .NET 6.0 |    16384 | 180.2 us | 1.63 us | 2.40 us | 179.0 us |
| MethodCall |           MediumRun-.NET 6.0 |           .NET 6.0 |    16384 | 179.6 us | 2.15 us | 2.94 us | 178.5 us |
|     Inline |           MediumRun-.NET 7.0 |           .NET 7.0 |    16384 | 156.0 us | 2.23 us | 3.19 us | 156.7 us |
| MethodCall |           MediumRun-.NET 7.0 |           .NET 7.0 |    16384 | 155.8 us | 1.55 us | 2.22 us | 155.6 us |
|     Inline | MediumRun-.NET Framework 4.8 | .NET Framework 4.8 |    16384 | 278.1 us | 1.83 us | 2.57 us | 277.3 us |
| MethodCall | MediumRun-.NET Framework 4.8 | .NET Framework 4.8 |    16384 | 280.3 us | 3.59 us | 5.37 us | 281.4 us |
@brantburnett brantburnett merged commit 18def04 into main Feb 7, 2023
@brantburnett brantburnett deleted the readfromscratch-method branch February 7, 2023 16:57
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant