Skip to content

perf(crypto): run MD5 implCompress0 as a native, as HotSpot intrinsifies it - #90

Merged
Project516 merged 2 commits into
masterfrom
p516/md5-native
Nov 10, 2026
Merged

Project516 merged 2 commits into
masterfrom
p516/md5-native

Conversation

@Project516

Copy link
Copy Markdown
Owner

What this changes

sun.security.provider.MD5.implCompress0 runs as a native, as HotSpot intrinsifies it, next to the SHA ones in src/natives/crypto.ts. It reads the same state int[4] and the input little-endian. The round constants are RFC 1321's table rather than computed with Math.sin, which is not exact in every engine.

Tests

  • New program Md5Digest, same output as HotSpot: empty input, "abc", sizes around every block boundary up to 1,000,000 bytes, updates split at odd offsets and from an offset, a chained digest, and UUID.nameUUIDFromBytes of six strings including multi-byte UTF-8.
  • MD5 of 64 MB in 8 KB updates, 7 alternating runs: 3366 ms (3247 to 3650) on master, 254 ms (248 to 298) on the branch, same digest every run.
  • UUIDTest: no change beyond the spread (141 s against 147 s median, ranges overlap); most of its time is not MD5.
  • passing.txt tests under java/security, sun/security and java/util/UUID: 39 of 39 pass. Full suite: 259 pass, 0 fail, 3 skipped.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 0321dbdb-5609-4572-8299-530586c4a9b5
Commits

Reviewing files that changed from the base of the PR and between 688c5d8 and c712a81.

Files selected for processing: 2

  • src/natives/crypto.ts
  • test/java/Md5Digest.java
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@project516-review-bot project516-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds a native implementation for MD5's implCompress0 method in src/natives/crypto.ts, using RFC 1321's precomputed constants and little-endian input reading, matching HotSpot's intrinsic behavior. A comprehensive test Md5Digest.java verifies empty input, "abc", block boundaries up to 1MB, split/offset updates, chained digests, and UUID.nameUUIDFromBytes with UTF-8. The implementation correctly follows the MD5 specification across all four rounds with proper rotation amounts, g-index permutations, and boolean functions.


review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve

@Project516
Project516 enabled auto-merge (squash) November 10, 2026 21:07
@Project516
Project516 merged commit e5f74b4 into master Nov 10, 2026
12 checks passed
@Project516
Project516 deleted the p516/md5-native branch November 10, 2026 21:10
@Project516 Project516 mentioned this pull request Nov 10, 2026
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.

1 participant