-
Notifications
You must be signed in to change notification settings - Fork 179
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
Optimise merge registers for migrations - Revert of Revert #5613
Optimise merge registers for migrations - Revert of Revert #5613
Conversation
This reverts commit 7503026.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/stable-cadence #5613 +/- ##
==========================================================
- Coverage 55.89% 55.85% -0.05%
==========================================================
Files 1049 1049
Lines 103232 103305 +73
==========================================================
- Hits 57706 57696 -10
- Misses 41132 41219 +87
+ Partials 4394 4390 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Currently, storage health check always fails with "slabs not referenced from account storage" because storage maps are not loaded in Cadence runtime storage even though payloads are loaded. This commit fixes this problem by loading storage map explicitly after loading payloads in storage.
5632f10
to
e7a6377
Compare
@janezpodhostnik Awesome work! What was the problem with the old, reverted variant, and what is the fix for it in this PR? |
The registers loaded in the test (from emulator) were not unique. So creating the mapping in a different order created different test results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Should this also be on master?
Might be good to get more eyes on it. Also, it would be great to test this exhaustively with the race detector on.
@turbolent this is only for migrations so it does not need to be ported back to master. I will test it with the race detector! |
@janezpodhostnik right, I assumed we wanted to also use it in the atree register inlining migration? |
Actually no. This optimisation is relevant for the cases where the amount of changed registers is a smaller portion of all the registers in a snapshot. If used in the atree migration it makes it worse. |
Tested this with the race detector on, and looks good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I left some comments.
type IndexMapSnapshot struct { | ||
reverseMap map[flow.RegisterID]int | ||
payloads []*ledger.Payload | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to unexport IndexMapSnapshot
, since mapSnapshot
isn't exported?
MapBased MigrationSnapshotType = iota | ||
// IndexMapBased is more efficient when the number of payloads that are going to change is small | ||
// compared to the total number of payloads (less than 30% of the current number of payloads). | ||
IndexMapBased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: MapBased
and IndexMapBased
can be confusing to differentiate without reading comments. Maybe we can rename them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't have any good ideas I renamed them according to suggested usage. Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like this to help user to choose the snapshot type (without implementation detail):
ReadOnlySnapshotType
LargeChangeSetSnapshotType
SmallChangeSetSnapshotType
Both ReadOnlySnapshotType
and LargeChangeSetSnapshotType
create MapBased
snapshot.
SmallChangeSetSnapshotType
creates IndexMapBased
snapshot.
This just an idea, so please feel free to choose any name you prefer.
f5b20c5
to
7295f3f
Compare
@janezpodhostnik Sorry about all the conflicts, I didn't realize we were touching a lot of the same code. Happy to help with resolving the conflicts if you want to! |
Oh, no :) Its ok I think its not that bad. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Mainly reviewed the changes to the existing code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 👍
This reverts commit 7503026.
This adds a fix for flakey tests.
I called the two snapshot types: