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

Record Upgrade Instructions for Classical Persistence #4676

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

luc-blaeser
Copy link
Contributor

Also support Prim.rts_upgrade_instructions() on classical persistence, to inspect the instructions consumed by the last upgrade (including stabilization plus destabilization) for performance measurements. This functionality is already supported with enhanced orthogonal persistence.

Mechanism

  1. The pre-upgrade records its consumed instructions, in particular for stabilization, in the stable memory metadata. The location depends on the stable memory version.
  2. The post-upgrade loads this information, if present, and adds its consumed instructions, in particular for destabilization.
  3. Prim.rts_upgrade_instructions() returns the sum of those costs.

Backwards Compatibility

The record of upgrade instructions is optional in the stable memory. This is to ensure backwards compatibility to older Motoko programs that do not record this information. When upgrading from such an older Motoko program, Prim.rts_upgrade_instructions() returns Nat64.maximumValue.

Notes

  • Prim.rts_upgrade_instructions() currently returns >0 after installation because some upgrade check needs to be performed there too.
  • This function is to be exposed to the Motoko base library together with the other diagnostic runtime information, since Prim is only intended for internal use.

Copy link

github-actions bot commented Aug 28, 2024

Comparing from 247aa05 to cd60245:
In terms of gas, no changes are observed in 5 tests.
In terms of size, 5 tests regressed and the mean change is +0.1%.

@luc-blaeser luc-blaeser marked this pull request as ready for review August 29, 2024 06:32
Copy link
Contributor

@crusso crusso left a comment

Choose a reason for hiding this comment

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

This looks ok to me but I don't quite understand why the number of instructions is so large?
Or is that just because its undefined and equal to UInt64.max = 18,446,744,073,709,551,615?

Copy link
Contributor

@crusso crusso left a comment

Choose a reason for hiding this comment

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

Ok, I get it now. LGTM. Nice work

test/run-drun/upgrade-instructions.mo Show resolved Hide resolved
Co-authored-by: Claudio Russo <[email protected]>
@luc-blaeser luc-blaeser added the automerge-squash When ready, merge (using squash) label Sep 11, 2024
@luc-blaeser
Copy link
Contributor Author

Thank you for the review, Claudio!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge-squash When ready, merge (using squash) enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants