Skip to content
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

fix(xsnap)!: avoid O(n^2) Array, Map, Set growth #3560

Merged
merged 3 commits into from
Jul 30, 2021
Merged

fix(xsnap)!: avoid O(n^2) Array, Map, Set growth #3560

merged 3 commits into from
Jul 30, 2021

Conversation

dckc
Copy link
Member

@dckc dckc commented Jul 29, 2021

TODO:

  • tests to verify performance improvements

BREAKING CHANGE: xs-meter-9 represents XS Map/Set optimizations

see also https://github.com/agoric-labs/moddable/tree/ag-testnet-5 ; this time, I merged Moddable's public branch into our "vendor branch" rather than rebasing.

commit 4372617 is work that we would have gotten for free if we had integrated Moddable's refactor of xsnap.c into platform and application. endojs/endo#681

fixes #3012

@dckc dckc requested review from warner and kriskowal July 29, 2021 21:03
@dckc dckc marked this pull request as ready for review July 29, 2021 22:46
@dckc dckc force-pushed the 3012-xs-perf branch 2 times, most recently from 080c0d8 to b93a534 Compare July 30, 2021 21:57
dckc added 3 commits July 30, 2021 16:58
Moddable commit ff1bfaf04249 rendered mxMapEntriesIteratorPrototype
obsolete in favor of mxMapIteratorPrototype and likewise several
others.

style: use standard return type for main()
to avoid a warning that may distract from security review
XS implementation now has conventional O(n log(n)) algorithm.

 - xs-meter-9 represents XS Map/Set optimizations
 - style: update indentaion in test-xs-perf.js

fixes #3012
@dckc dckc requested a review from warner July 30, 2021 22:00
@kriskowal
Copy link
Member

For release management, the *BREAKING CHANGE:* line must appear in one of the commit messages, possibly the merge commit, with the asterisks, for Lerna to pick it up and recommend a version appropriately.

Copy link
Member

@kriskowal kriskowal left a comment

Choose a reason for hiding this comment

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

Neat, thanks.

Comment on lines -831 to +833
mxFreezeBuiltInCall; mxPush(mxMapKeysIteratorPrototype); mxFreezeBuiltInRun;
mxFreezeBuiltInCall; mxPush(mxMapValuesIteratorPrototype); mxFreezeBuiltInRun;
mxFreezeBuiltInCall; mxPush(mxMapIteratorPrototype); mxFreezeBuiltInRun;
mxFreezeBuiltInCall; mxPush(mxModulePrototype); mxFreezeBuiltInRun;
mxFreezeBuiltInCall; mxPush(mxRegExpStringIteratorPrototype); mxFreezeBuiltInRun;
mxFreezeBuiltInCall; mxPush(mxSetEntriesIteratorPrototype); mxFreezeBuiltInRun;
mxFreezeBuiltInCall; mxPush(mxSetKeysIteratorPrototype); mxFreezeBuiltInRun;
mxFreezeBuiltInCall; mxPush(mxSetValuesIteratorPrototype); mxFreezeBuiltInRun;
mxFreezeBuiltInCall; mxPush(mxSetIteratorPrototype); mxFreezeBuiltInRun;
Copy link
Member

Choose a reason for hiding this comment

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

Story checks out:

$ node
> new Map().keys().__proto__ === new Map().entries().__proto__
true

@@ -138,7 +139,9 @@ test('metering can be switched off / on at run-time', async t => {
const opts = options(io);
const vat = xsnap(opts);
t.teardown(() => vat.terminate());
const { meterUsage: { compute: noUnMeteredCompute } } = await vat.evaluate(`
const {
meterUsage: { compute: noUnMeteredCompute },
Copy link
Member

Choose a reason for hiding this comment

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

nit: Maybe fullyMeteredCompute to cancel the negatives. I want to love giving Un its own camel hump, and also MoDem, TeleType, and TransCoder.

Comment on lines +243 to +244
t.true(r2.rate / r1.rate >= 1);
t.true(r3.rate / r2.rate >= 1);
Copy link
Member

Choose a reason for hiding this comment

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

What do these assertions verify?

Copy link
Member Author

Choose a reason for hiding this comment

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

that the data structure manipulation rate (computed above as n * logn / delta_t) stays comparable as the (binary) order of magnitude grows.

It used to be >= 0.85. Now that it's >= 1, it could just be r2.rate >= r1.rate, I suppose.

@dckc dckc merged commit fa5e3ea into master Jul 30, 2021
@dckc dckc deleted the 3012-xs-perf branch July 30, 2021 23:03
@dckc dckc changed the title feat!(xsnap): Map/Set/Array optimizations fix(xsnap)!: avoid O(n^2) Array, Map, Set growth Jul 30, 2021
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.

xs performance investigation (array, Map/Set optimizations)
3 participants