Repository navigation
buffer: use typed arrays for 64-bit BigInt accessors - #67549
Merged
Merged
Conversation
readBig(U)Int64{LE,BE}() and writeBig(U)Int64{LE,BE}() assembled and
split values with BigInt arithmetic, allocating intermediate BigInts on
every call. Copy the bytes through BigInt64Array and BigUint64Array
views over the existing 8-byte scratch buffer instead, as the double
accessors already do.
Range and bounds checks are unchanged, and the value is masked with
`& -1n` before the store so non-BigInt values still throw the same
TypeError instead of being coerced by the typed array.
benchmark/buffers/buffer-read.js now uses the value it reads. The
loop discarded it, which let V8 remove side-effect-free reads
altogether.
Assisted-by: claude:opus-5.5
Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67549 +/- ##
==========================================
+ Coverage 90.66% 90.68% +0.01%
==========================================
Files 799 800 +1
Lines 280245 280963 +718
Branches 54121 54287 +166
==========================================
+ Hits 254097 254800 +703
+ Misses 16277 16254 -23
- Partials 9871 9909 +38
🚀 New features to boost your workflow:
|
Collaborator
jasnell
approved these changes
Nov 18, 2026
Collaborator
Collaborator
|
Landed in 41918c1 |
snovader
added a commit
to snovader/tafla
that referenced
this pull request
Nov 19, 2026
readInt64() and readUint64() added a value's two 32-bit words as bigints, which allocated a bigint for each. They now copy the bytes to a scratch DataView and read the value from it, as readFloat64() does, and as nodejs/node#67549 changed Buffer's accessors to.
aduh95
pushed a commit
that referenced
this pull request
Nov 20, 2026
readBig(U)Int64{LE,BE}() and writeBig(U)Int64{LE,BE}() assembled and
split values with BigInt arithmetic, allocating intermediate BigInts on
every call. Copy the bytes through BigInt64Array and BigUint64Array
views over the existing 8-byte scratch buffer instead, as the double
accessors already do.
Range and bounds checks are unchanged, and the value is masked with
`& -1n` before the store so non-BigInt values still throw the same
TypeError instead of being coerced by the typed array.
benchmark/buffers/buffer-read.js now uses the value it reads. The
loop discarded it, which let V8 remove side-effect-free reads
altogether.
Assisted-by: claude:opus-5.5
Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
PR-URL: #67549
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
readBig(U)Int64{LE,BE}() and writeBig(U)Int64{LE,BE}() assembled and split values with BigInt arithmetic, allocating intermediate BigInts on every call. Copy the bytes through BigInt64Array and BigUint64Array views over the existing 8-byte scratch buffer instead, as the double accessors already do
benchmark/buffers/buffer-read.js(30 runs):buffer=fastbuffer=slowThe other types are within noise (−1.48 % to +1.88 %).
benchmark/buffers/buffer-write.js(30 runs):buffer=fastbuffer=slow