Skip to content

Decompress snappy into a bytearray - #153

Merged
yunzheng merged 1 commit into
fox-it:mainfrom
falklindner:fix/snappy-bytearray
Oct 27, 2026
Merged

yunzheng merged 1 commit into
fox-it:mainfrom
falklindner:fix/snappy-bytearray

Conversation

@falklindner

Copy link
Copy Markdown
Contributor

snappy.decompress writes into a bytearray instead of a BytesIO, so it needs no memoryview at all. The PyPy export problem #148 fixed can't occur, and the slowdown since #148 is gone:

large benchmark main this PR
CPython 3.13 157 µs 85 µs
PyPy 8.0.1 265 µs 16 µs

Tested with tox -e lint,3.10,3.11,3.13,pypy3.10,pypy3.11,benchmark on Linux.

Closes #152

🤖 Generated with Claude Code

https://claude.ai/code/session_01HJvjcGbjsG74UunzfT5zNE

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (dd93fb4) to head (c1aa3ee).

Files with missing lines Patch % Lines
dissect/util/compression/snappy.py 0.00% 7 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #153   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         31      31           
  Lines       2180    2179    -1     
=====================================
+ Misses      2180    2179    -1     
Flag Coverage Δ
unittests 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 56.93%

1 warning

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
✅ 37 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_benchmark_snappy_decompress[large] 1,148.3 µs 596.9 µs +92.4%
⚡ test_benchmark_snappy_decompress[basic] 69.7 µs 54.5 µs +28%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing falklindner:fix/snappy-bytearray (c1aa3ee) with main (dd93fb4)

Open in CodSpeed

Since fox-it#148, snappy releases its memoryview slice with a with
statement, so every match pays for two context managers, and CodSpeed
measures the snappy benchmarks 12 to 28% slower. A bytearray needs no
memoryview: a match is a plain slice of the output, so there is no
export left for PyPy's GC to release before the output grows.

The large benchmark takes 85 us on CPython 3.13, down from 157 us now
and 116 us before fox-it#148, and 16 us on PyPy 8.0.1, down from 265 us.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJvjcGbjsG74UunzfT5zNE
@yunzheng
yunzheng force-pushed the fix/snappy-bytearray branch from 2430557 to c1aa3ee Compare October 27, 2026 19:37
@yunzheng
yunzheng merged commit 2e15883 into fox-it:main Oct 27, 2026
61 of 63 checks passed
@falklindner
falklindner deleted the fix/snappy-bytearray branch November 14, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snappy decompression is slower since #148

3 participants