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

Delay instantiation of cachedValues to save memory #831

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

holzensp
Copy link
Contributor

I'm putting this up as a discussion piece, more than anything. Wins are minimal, at best.

The thinking was that every VmObject gets its cachedValues initialised by default, but only the ones that are forced get those values filled. However, cachedValues.entries is null by default. There appears to be a bigger possible win to address the fact that a lot of EconomicMaps have entries be an oversized array (Object[8] by default).

@odenix
Copy link
Contributor

odenix commented Nov 27, 2024

If the wins are minimal, I'm not sure they are worth the additional code and runtime checks. For typed objects, cachedValues could probably be removed altogether by switching to Truffle's static object model.

Speaking of small wins, there are several places in the codebase where EconomicMap.create() could be safely replaced with EconomicMap.emptyMap() because the map is effectively read-only. I tried this a few weeks ago but didn't send a PR because I had too many pending PRs.

@holzensp
Copy link
Contributor Author

holzensp commented Dec 2, 2024

I agree. I am still looking into replacing members with something a little more compact, because of frequent over-allocation there. I'm skeptical it'll be significant, but it's worth the experiment, at least.

@odenix
Copy link
Contributor

odenix commented Dec 2, 2024

How do you do your memory profiling? members is often shared between objects created by the same new/amend expression. Are specific code constructs, such as for-generators, responsible for what you're seeing?

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.

2 participants