New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use jsbi
for internal 64bit integer calculations
#980
Conversation
cf2a759
to
e666077
Compare
parser.readUInt32LE(next); | ||
} else { | ||
parser.readBigUInt64LE((rowCount) => { | ||
next(JSBI.toNumber(rowCount)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If more than Number.MAX_SAFE_INTEGER
(9007199254740991
) rows are transferred, this conversion might result in an incorrect rowcount. I'm not sure if that's something we have to care about - this limit seems hardly reachable. 🤷♂
Codecov Report
@@ Coverage Diff @@
## master #980 +/- ##
==========================================
- Coverage 83.34% 83.22% -0.12%
==========================================
Files 87 86 -1
Lines 4274 4250 -24
Branches 373 366 -7
==========================================
- Hits 3562 3537 -25
- Misses 594 597 +3
+ Partials 118 116 -2
Continue to review full report at Codecov.
|
e666077
to
12e7aca
Compare
12e7aca
to
bf7b574
Compare
bf7b574
to
1a740aa
Compare
🎉 This PR is included in version 6.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This switches the code that is used for doing internal 64bit number calculations from our own custom code over to
jsbi
.jsbi
is based on theBigInt
type available in Node.js 12 and newer, but works in all Node.js versions that we want to be supported bytedious
.Context
Some parts of the TDS protocal use 64-bit integers. Examples for this are the
rowcount
in theDONE
token, or everything related to thebigint
data type.The code that was used for this was adapted from different other libraries (e.g.
node-int64
), but was never optimized for speed nor correctness (see #973). By replacing this code withjsbi
, we should be able to improve performance, reduce the code we need to maintain, and also ensure correctness.Note: This only changes internals. All external code reading / writing to
bigint
columns will be unaffected (but should be much faster than before).