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

remove install-metering-and-ses from apps and most unit tests #3393

Merged
merged 6 commits into from
Jun 22, 2021

Conversation

warner
Copy link
Member

@warner warner commented Jun 22, 2021

At this point, any dynamic vats that need to be metered should be run under xsnap, not local, which means we no longer need to use @agoric/install-metering-and-ses to wrap the globals with metered versions. Those wrappers cause a significant slowdown in all Node.js-side code (like the kernel), even when metering is not enabled, so it's nice to remove them.

This changes spawner and zoe tests which need to exercise metering to use an xsnap worker. All instances of import '@agoric/install-metering-and-ses' have been changed to import '@agoric/install-ses'. This reduces the runtime of those tests by 4x-6x (in one case, Zoe's test-crashingContract.js, reducing it from 340s to 60s).

Most importantly, this changes our two main applications (cosmic-swingset and the solo node) in the same way. We don't have measurements on the performance changes, but we expect them to be noticeable.

refs #3373

Probably doesn't close it yet, there are still some swingset internal tests that exercise that metering code which needs to be changed.

warner added 4 commits June 21, 2021 19:20
The tests that actually need to exercise metering now use `xs-worker` instead
of enabling global metering. This speeds those tests up by 4x-6x.

refs #3373
All metered vats should now be using xsnap, so we no longer need to meter
'local' vats, and can remove the performance-costly global metering wrapper.

refs #3373
All metered vats should now be using xsnap, so we no longer need to meter
'local' vats, and can remove the performance-costly global metering wrapper.

refs #3373
@warner
Copy link
Member Author

warner commented Jun 22, 2021

I ran my testnet-load-generator recipe to test this (agoric start local-chain and agoric start local-solo). I didn't see any complaints by the chain node, but the solo node said:

agoric: deploy: running /home/warner/stuff/agoric/agoric-sdk/packages/dapp-svelte-wallet/api/deploy.js
2021-06-22T02:36:27.314Z SwingSet: kernel: note: makeGetMeter() cannot enable global metering, app must import @agoric/install-metering-and-ses

which makes me think the wallet deploy is using the spawner (which does not make a new dynamic vat? I forget) and the within-vat metering code (the other thing we want to rip out). I suspect that means whatever code is being loaded is subject to the metering transform but not running with meter-transformed globals, so it's even less meter-confined than before. @michaelfig can you imagine this being a problem for the next week? I'm guessing it's ok.

The loadgen sequence seemed to run without problems. I haven't yet investigated how performance might have changed.

@warner warner self-assigned this Jun 22, 2021
@warner warner added Zoe package: Zoe spawner Spawner and contractHost cosmic-swingset package: cosmic-swingset labels Jun 22, 2021
@warner warner added this to the Testnet: Stress Test Phase milestone Jun 22, 2021
Copy link
Contributor

@katelynsills katelynsills left a comment

Choose a reason for hiding this comment

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

LGTM!

@michaelfig
Copy link
Member

michaelfig commented Jun 22, 2021

the wallet deploy is using the spawner (which does not make a new dynamic vat? I forget)

The spawner does make a new dynamic vat.

The problem is apparently that the defaultManagerType in packages/solo/* is 'local'. Can you please change this to 'xs-worker'? Then I suspect there will be no more warnings, and all our code will use xsnap unless overridden with SWINGSET_WORKER_TYPE.

$ rg "'local'" ../solo/src/
../solo/src/init-basedir.js
24:    defaultManagerType = env.SWINGSET_WORKER_TYPE || 'local',

../solo/src/main.js
81:          defaultManagerType: process.env.SWINGSET_WORKER_TYPE || 'local',

../solo/src/vat-http.js [irrelevant]

Copy link
Member

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

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

Looks good, just needs to update packages/solo to use 'xs-worker'.

This changes the solo node to use xs-worker (xsnap) vats instead of local
ones, which has a secondary effect of silencing a warning from the spawner as
it attempts to create a metered vat without the Node.js globals having been
wrapped for metering.

refs #3393
@warner
Copy link
Member Author

warner commented Jun 22, 2021

@michaelfig I'm cool with switching solo to xs-worker.. I think we hesitated on doing that for the previous phase, but I'm feeling good about it now.

I made the two changes you recommended, but I'm still seeing that warning message on the client:

Open CapTP connection to ws://127.0.0.1:8000/private/captp...oooooo2021-06-22T04:43:25.300Z chain-cosmos-sdk: could not find peer mailbox - agoric1ne5c4yqe07hgtg6fccpxraxdm7ws2hs48kug6r: rpc error: code = Unknown desc = could not get peer mailbox: unknown request
2021-06-22T04:43:25.344Z chain-cosmos-sdk: gas estimate: 48763
oo
agoric: deploy: running /home/warner/stuff/agoric/agoric-sdk/packages/dapp-svelte-wallet/api/deploy.js
2021-06-22T04:43:27.937Z SwingSet: kernel: note: makeGetMeter() cannot enable global metering, app must import @agoric/install-metering-and-ses
2021-06-22T04:43:30.045Z chain-cosmos-sdk: gas estimate: 44547

I'm wondering if something in agoric deploy is trying to meter the deploy script it's loading? Probably not a big deal, but it might point to a place where we're actually expecting metering under Node.js and probably have to make a decision to let that go.

But, I'll land this once CI passes.

@michaelfig
Copy link
Member

I'm still seeing that warning message on the client

Maybe:

$ rg '"local"' ../solo
../solo/solo-config.json
3:  "defaultManagerType": "local",

???

@warner
Copy link
Member Author

warner commented Jun 22, 2021

That did the trick, thanks!

Will land as soon as CI finishes.

@warner warner enabled auto-merge June 22, 2021 05:29
@warner warner merged commit f3f299b into master Jun 22, 2021
@warner warner deleted the 3373-remove-global-metering branch June 22, 2021 05:30
kriskowal pushed a commit that referenced this pull request Jun 22, 2021
This changes the solo node to use xs-worker (xsnap) vats instead of local
ones, which has a secondary effect of silencing a warning from the spawner as
it attempts to create a metered vat without the Node.js globals having been
wrapped for metering.

refs #3393
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cosmic-swingset package: cosmic-swingset spawner Spawner and contractHost Zoe package: Zoe
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants