Skip to content

Avoid double allocating while hashing&serializing#496

Draft
dvdplm wants to merge 2 commits intomainfrom
dvdplm/chore/hashing-writer
Draft

Avoid double allocating while hashing&serializing#496
dvdplm wants to merge 2 commits intomainfrom
dvdplm/chore/hashing-writer

Conversation

@dvdplm
Copy link
Copy Markdown
Contributor

@dvdplm dvdplm commented Mar 31, 2026

Avoid the serialize-then-hash pattern by adding a HashingWriter that impls std::io::Writer. Now we can avoid passing a Vec buffer to safe_serialize and then hash that Vec; instead the HashingWriter hashes as it goes and finalizes in the end.

The performance impact is very minor, sadly, most likely because serialization still allocates a bunch. On my system I see memory consumption for one big test go down from ~9Gb to ~8Gb, so not useless I guess.

WIP because it's worth checking other call sites for the "serialize-then-hash" pattern.

@cla-bot cla-bot bot added the cla-signed The CLA has been signed. label Mar 31, 2026
@github-actions
Copy link
Copy Markdown

Consolidated Tests Results 2026-03-31 - 17:13:27

Test Results

passed 21 passed

Details

tests 21 tests
clock not captured
tool junit-to-ctrf
build build-and-test arrow-right test-reporter link #1110
pull-request Avoid double allocating while hashing&serializing link #496

test-reporter: Run #1110

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
21 21 0 0 0 0 0 not captured

🎉 All tests passed!

Tests

View All Tests
Test Name Status Flaky Duration
nightly_full_gen_tests_k8s_default_threshld_sequential_crs 33.2s
test_k8s_threshld_insecure 3m 19s
k8s_test_crs_uniqueness 33.1s
k8s_test_insecure_keygen_encrypt_and_public_decrypt 3m 23s
k8s_test_insecure_keygen_encrypt_multiple_types 3m 44s
k8s_test_keygen_and_crs 3m 19s
k8s_test_keygen_uniqueness 9m 4s
nightly_full_gen_tests_k8s_default_threshld_sequential_crs 33.2s
test_k8s_threshld_insecure 3m 19s
k8s_test_crs_uniqueness 33.1s
k8s_test_insecure_keygen_encrypt_and_public_decrypt 3m 23s
k8s_test_insecure_keygen_encrypt_multiple_types 3m 44s
k8s_test_keygen_and_crs 3m 19s
k8s_test_keygen_uniqueness 9m 4s
nightly_full_gen_tests_k8s_default_threshld_sequential_crs 33.2s
test_k8s_threshld_insecure 3m 19s
k8s_test_crs_uniqueness 33.1s
k8s_test_insecure_keygen_encrypt_and_public_decrypt 3m 23s
k8s_test_insecure_keygen_encrypt_multiple_types 3m 44s
k8s_test_keygen_and_crs 3m 19s
k8s_test_keygen_uniqueness 9m 4s

🍂 No flaky tests in this run.

Github Test Reporter by CTRF 💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The CLA has been signed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant