Skip to content

perf(hash): avoid heap allocations in hash#10060

Merged
ahabhgk merged 1 commit intoweb-infra-dev:mainfrom
quininer:perf/hash-no-heap
Apr 17, 2025
Merged

perf(hash): avoid heap allocations in hash#10060
ahabhgk merged 1 commit intoweb-infra-dev:mainfrom
quininer:perf/hash-no-heap

Conversation

@quininer
Copy link
Copy Markdown
Contributor

@quininer quininer commented Apr 17, 2025

Summary

There are currently 3 unnecessary heap allocations in hash. This PR will remove as many of them as possible.

Since md4 output is larger than smol_str capacity, a heap allocation still occurs when using md4. We use xxhash by default, so no further optimization is done here.

data-encoding is suitable for size-sensitive scenarios, but because it shares an impl with encodings such as base64, it is not usually inlined. here we replace it with our own simple impl.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions bot added the release: performance release: performance related release(mr only) label Apr 17, 2025
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 17, 2025

Deploy Preview for rspack canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit bb92f54
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/680082cb892f2900081e1a1f

@quininer quininer force-pushed the perf/hash-no-heap branch from 290aa5c to 703bcc2 Compare April 17, 2025 02:04
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 17, 2025

CodSpeed Performance Report

Merging #10060 will not alter performance

Comparing quininer:perf/hash-no-heap (bb92f54) with main (5a49a01)

Summary

✅ 11 untouched benchmarks

@quininer quininer force-pushed the perf/hash-no-heap branch 4 times, most recently from a09a0e1 to ff201da Compare April 17, 2025 04:23
@quininer quininer force-pushed the perf/hash-no-heap branch from ff201da to bb92f54 Compare April 17, 2025 04:25
@ahabhgk ahabhgk merged commit 096b97a into web-infra-dev:main Apr 17, 2025
27 checks passed
@quininer quininer deleted the perf/hash-no-heap branch April 17, 2025 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: performance release: performance related release(mr only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants