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

add "run policy" object to controller.run() #3580

Merged
merged 2 commits into from
Aug 3, 2021
Merged

add "run policy" object to controller.run() #3580

merged 2 commits into from
Aug 3, 2021

Conversation

warner
Copy link
Member

@warner warner commented Aug 2, 2021

This allows the host application to control how much work c.run() does
before it returns. Depending upon the policy chosen, this can be a count of
cranks, or cumulative computrons used, with more details to be added in the
future.

closes #3460

@warner warner added the SwingSet package: SwingSet label Aug 2, 2021
@warner warner added this to the Testnet: Metering Phase milestone Aug 2, 2021
@warner warner requested a review from FUDCo August 2, 2021 23:13
@warner warner self-assigned this Aug 2, 2021
* `policy.crankFailed()`

All methods should return `true` if the kernel should keep running, or `false` if it should stop.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a little weird that if the return from crankFailed is true the vat should keep going.

Copy link
Member Author

Choose a reason for hiding this comment

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

Does it help to know that it's the kernel which should keep running, rather than the vat? Yeah, at that point the vat is dead. We don't get a lot of data about how long it took the vat to fail: if the vat exceeds its per-crank limit, the process terminates, and all we get is a unix exit status.

Copy link
Contributor

@FUDCo FUDCo Aug 3, 2021

Choose a reason for hiding this comment

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

There's an ambiguity in the interpretation of the name -- it could mean "what do I do if if the crank failed?" or it could mean "did the crank fail?"

Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

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

This seems fine, though I'm left with a lingering sense of engineering without a driving use case (i.e., "this sounds useful" rather than "we need this"). Maybe I've missed some discussions?

});
}

export function crankCounter(maxCranks, maxCreateVats) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like there's a role for something that counts cranks but really doesn't care about vat creations. I suppose you could get that by passing Number.MAX_INTEGER_VALUE for maxCreateVats, but I'm left wondering if there should be an explicit "don't care" signal, like 0 or -1 or something.

Copy link
Member Author

Choose a reason for hiding this comment

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

Eh, runPolicies.js is more about providing examples than trying to cover the full range of what sort of policy you might want to implement. Mostly I wanted something to establish the intuition that creating a whole new vat is tremendously more expensive than sending a message to an existing one.

@warner
Copy link
Member Author

warner commented Aug 3, 2021

This seems fine, though I'm left with a lingering sense of engineering without a driving use case (i.e., "this sounds useful" rather than "we need this"). Maybe I've missed some discussions?

Fair point. #2319 and #2299 contained some of it. Basically we've observed some very long blocks (60s) on the recent testnet phases, and we know that our current policy ("do all the remaining work, every time") isn't viable. At the very least, we know that without a limit on how much we do per block, there's not much point to doing any sort of scheduling / prioritization: none of the cranks we do matter until the block is committed, so the order of txns within a single block is irrelevant (from a priority point of view; certainly there are other benefits to running before/after other txns).

warner added 2 commits August 2, 2021 17:41
This allows the host application to control how much work `c.run()` does
before it returns. Depending upon the policy chosen, this can be a count of
cranks, or cumulative computrons used, with more details to be added in the
future.

closes #3460
@warner warner enabled auto-merge August 3, 2021 00:44
@warner warner merged commit a2f0b3a into master Aug 3, 2021
@warner warner deleted the 3460-run-policy branch August 3, 2021 01:14
@mhofman
Copy link
Member

mhofman commented Aug 10, 2021

A bit late to the party, but what I had imagined was to have 2 facets to the run policy. One that can be used by run to ask "should I keep going?", and another facet that can be passed down into the different process methods to inform the policy of actions taken (create vat, crank, etc.). It'd avoid plumbing the "policy input" all the way back up as a return value of process methods, and make some run policies like wall clock very straight forward (no-op for the process facet). The idea was to make the run facet similar to the DOM IdleDeadline API, where the program checks if it has time left to do remaining tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add runPolicy object to controller.run()
3 participants