-
Notifications
You must be signed in to change notification settings - Fork 74
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
perf(marshal): Replace XS-expensive string operations #2001
Conversation
d74ddb8
to
d02889a
Compare
const tagpayload = decodeArray(encoded.substring(1), decodePassable); | ||
// Skip the ":" inside `decodeArray` to avoid slow `substring` in XS. | ||
// https://github.com/endojs/endo/issues/1984 | ||
const tagpayload = decodeArray(encoded, decodePassable, 1); |
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.
const tagpayload = decodeArray(encoded, decodePassable, 1); | |
const tagPayload = decodeArray(encoded, decodePassable, 1); |
Or do you have a convention for when you avoid midcaps? Why? I also notice keysvals
above.
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.
No, it was preexisting (and git blame
git praise
) identifies introduction in the landmark Agoric/agoric-sdk#4468). But worth fixing here, which I have done for both sites.
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.
(FWIW I'm surprised I did that and have no idea why I did. Glad to see it fixed, thanks!)
Fail`Unexpected character after u0001 escape: ${c2}`; | ||
elemChars.push(c2); | ||
inEscape = true; | ||
// eslint-disable-next-line no-continue |
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.
Not a comment on this PR, but curious: Do you think we should turn off warning on continue
? I don't see the value in it.
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.
I would love to disable that warning; continue
is as useful as break
and early return
and I don't see any value in discouraging it.
} | ||
elemChars.length === 0 || Fail`encoding terminated early: ${encoded}`; | ||
!inEscape || Fail`unexpected end of encoding ${encoded.slice(skip)}`; |
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.
Good point! Expensive operations in that position are fine.
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.
LGTM, thanks!
decodePassable with need these same changes, yes?
d02889a
to
3745bab
Compare
Both are in the same file and included in this PR (and in fact most of the changes affect decoding). |
Ref #1982 Speeds up XS by 21% decoding a representation of the following CopyRecord: ``` { primitives: [undefined, null, true, false, 0, 1, 0n, 1n, "foo", Symbol.for("bar")], arrays: [[], [{}]], records: { empty: {}, singular: { array: [] } }, } ``` (and speeds up decoding a CopyArray containing 10 copies thereof by about 100%)
3745bab
to
dac5bc0
Compare
Oops. I mean |
Ah, yes. I'll do that in the next round of updates to #1594 this week. |
Ref #1982
Description
Speeds up by 21% decoding a representation of the following CopyRecord:
(and speeds up decoding a CopyArray containing 10 copies thereof by about 100%)
No significant effects in Node.js.
Security Considerations
n/a
Scaling Considerations
As stated on the tin.
Documentation Considerations
n/a
Testing Considerations
n/a
Compatibility Considerations
n/a
Upgrade Considerations
n/a