-
Notifications
You must be signed in to change notification settings - Fork 23
feat: add canonical cache for live sync #114
Conversation
a9106ae
to
d080d77
Compare
d080d77
to
acd701c
Compare
36bcfd1
to
cb5290d
Compare
let mut to_wipe = false; | ||
for storage in &change_set.storage { | ||
if storage.wipe_storage { | ||
to_wipe = true; |
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.
storage.wipe_storage
seems only mean to the storage of an account, but why we clean all storage cache here?
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.
The reason is that: the quick cache is very simple there is no function for iterate or find keys with a prefix.
One way is that we can make storage cache to use nested structure, e.g., a map or another layer of cache. However, it seems a bit complex. Do you think should we implement in this way?
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 think we should have some test, like create/destroy a contract to ensure our cache works well
a837f30
to
d121876
Compare
Description
Add cache layer to cache historical committed accounts & storages.
Rationale
To improve the execution of live sync.
Example
Test Result - Live sync 20K blocks on BSC, from 41413200 to 41433100.
Note: There are reboots before each tests, to make sure the test environment is clean.
account hit rate (the l3 account in the figure): 36.2%
storage hit rate (the l3 storage in the figure): 43.3%
Note: l1 account & storage caches refer to the revm state cache.
The time decreases about 21% after steady. (due to reboot, at the beginning, the performance is bad for both).
The time to apply bundle state to cache (update cache after db commit) is included for the cached version.
The cached version is 356 Mgas/s for execution on avg, while the original version is 277 Mgas/s.
The gas throughput increases about 28%. Why it is not aligned to the execution time?
Changes
Notable changes:
Potential Impacts