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

Save 1.3 GB of RAM with finalizeCacheableObjectPrototype #592

Merged
merged 6 commits into from
Jan 13, 2025

Conversation

towerofnix
Copy link
Member

Rewrites the guts of CacheableObject so that property setters/getters are configured on each subclass' prototype, rather than on each instance. In practice this obliterates many hundreds of thousands of thin wrappers around compute/transform behavior defined in properties' descriptors. That saves a lot of memory! There also appear to be speed improvements (in general around 20s to boot live-dev-server, against 30s, on miniminimini/M1).

This approach was suggested by natalias posting. She also wrote the code for tracking total process memory usage at each step, which we've put behind --show-step-memory (used alongside --show-step-summary).

We have generally replaced Object.hasOwn(thing, 'key') behavior with thing.constructor.hasPropertyDescriptor('key'). Listings need a bit of mockery to make this work, until they're made into proper things. (Nudge nudge #424)

External behavior and interfacing for CacheableObject is otherwise identical... except that we now only mark a cached value as, you know, cached, if we were successfully able to compute it. That means if foo.x throws an error, accessing foo.x again will throw the same error again, instead of just returning undefined (the "successfully" cached value). This has no bearing on general wiki code but should make debugging on the REPL a bit nicer.

@towerofnix towerofnix force-pushed the cacheable-constructors branch from 0f10fd2 to dffcfd7 Compare January 13, 2025 20:43
@towerofnix towerofnix merged commit dffcfd7 into preview Jan 13, 2025
@towerofnix towerofnix deleted the cacheable-constructors branch January 13, 2025 20:43
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.

1 participant