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

perf: exclude source maps from ContractData #8022

Merged
merged 1 commit into from
Jun 1, 2024
Merged

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented May 31, 2024

Motivation

ref #8014

Since #7937 ContractData stored entire CompactBytecode instead of just bytecode bytes. CompactBytecode includes source maps and thus results in increased memory usage to store those in known_contracts when running tests.

Solution

Introduce separate BytecodeData struct which does not keep source maps as we don't need them for bytecode identification.

cc @grandizzy

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

How does this help? Are we cloning this structure?

@klkvr
Copy link
Member Author

klkvr commented May 31, 2024

How does this help? Are we cloning this structure?

Yes, we build and keep separate ContractsByArtifact for each test suite since #7685

@grandizzy
Copy link
Collaborator

confirming memory does not exceed 4.5G with this PR (prev was 13G) 🎉

@DaniPopes
Copy link
Member

Sure but it's Arc'd, if I remove derive(Clone) from ContractData or ContractsByArtifact only forge script related code is affected

@klkvr
Copy link
Member Author

klkvr commented Jun 1, 2024

Sure but it's Arc'd, if I remove derive(Clone) from ContractData or ContractsByArtifact only forge script related code is affected

yeah we don't clone it in tests, the memory usage is coming from us building it for each test contract here and then not dropping till the end of test run

@DaniPopes
Copy link
Member

Ah it's kept in suite result

@klkvr
Copy link
Member Author

klkvr commented Jun 1, 2024

yep, we can optimize this by not linking test contracts separately and ensuring deterministic library addresses instead, will look into this

@DaniPopes
Copy link
Member

Clearing it in tests should be fine, it's skipped in serde and not used after f8145ed

@mattsse mattsse merged commit 8e9fca8 into master Jun 1, 2024
19 checks passed
@mattsse mattsse deleted the klkvr/rm-source-maps branch June 1, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants