refactor(pass-style): faster passStyleOf
#2716
Merged
+44
−30
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.
Closes: #XXXX
Refs: Agoric/agoric-sdk#10975 Agoric/agoric-sdk#10982
Description
Using the benchmark tool from #10975 by @muhammadahmadasifbhatti as modified by #10982 to produce flamegraphs (interactive in vscode) I iterated on that benchmark test which already had very specific simple examples exercising
passStyleOf
. Together with the snippet at https://github.com/Agoric/agoric-sdk/blob/acbb5da3c5a52bab8db319fd696aed70146f9a89/.github/actions/restore-node/action.yml#L156 (which @gibson042 brought to my attention)and then clicking on the latest *.cpuprofile file, assuming you've already installed the https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-js-profile-flame vscode extension.
I was able to iterate and tinker on possible improvements, to see what made how much of a difference. This PR has the improvements to
passStyleOf
that I and my reviewers have came up with so far.@gibson042 suggested the main technique used: to avoid redundant checking by breaking up
assertValid
so we could still running the checks ofcanBeValid
twice.Security Considerations
I claim that this PR is a pure refactoring. If true, none. Reviewers, please review with a skeptical eye.
passStyleOf
is security critical, so any observable difference might lead to an opportunity for an adversary.Scaling Considerations
Even though I iterated on a specialized benchmark exercising
passStyleOf
, I believe I only made changes that would also be an improvement for the typical cases.Documentation Considerations
If this is a pure refactor, none.
Testing Considerations
If this is a pure refactor, none. In fact, this PR did not need to change any tests, providing some weak evidence that it is indeed a pure refactor.
Compatibility Considerations
If this is a pure refactor, none.
Upgrade Considerations
If this is a pure refactor, none.