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

statemanager: re architect shallow copy to improve tree shaking #3596

Merged
merged 2 commits into from
Aug 15, 2024

Conversation

gabrocheleau
Copy link
Contributor

@gabrocheleau gabrocheleau commented Aug 15, 2024

This PR restructures shallowCopy method of the DefaultStateManager. This improves bundle size significantly (tested with the statemanager/examples/basicUsage.ts file :

Before the change

  • Root: 419.81kb
  • statemanager: 63.52kb

After the change

  • Root: 364.83kb
  • statemanager: 35.34kb

The improvement comes from the removal of the Caches class dependency from the shallowCopy method.

import { modifyAccountFields } from './util.js'

import { CODEHASH_PREFIX, Caches, type DefaultStateManagerOpts } from './index.js'
Copy link
Member

Choose a reason for hiding this comment

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

👀

Ah, ok, now I get it.

So seems my observation was correct (?).

Cool, great dive and find! 🎉 🙂

code: codeCacheOpts,
storage: storageCacheOpts,
}),
caches: this._caches?.shallowCopy(downlevelCaches),
Copy link
Member

Choose a reason for hiding this comment

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

🤯

Ugh. That's really a brilliant separation!

Copy link

codecov bot commented Aug 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (4470cc3) to head (cb3ab6e).
Report is 10 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (4470cc3) and HEAD (cb3ab6e). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (4470cc3) HEAD (cb3ab6e)
block 1 0
tx 1 0
wallet 1 0
Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block ?
client 0.00% <ø> (ø)
tx ?
wallet ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

LGTM

@holgerd77 holgerd77 merged commit 66d5993 into master Aug 15, 2024
35 of 36 checks passed
@holgerd77 holgerd77 deleted the statemanager/caches-tree-shaking-improvements branch August 15, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants