Skip to content

Cache V8 heap stats instead of querying them on every call#4778

Merged
joshua-spacetime merged 5 commits intomasterfrom
joshua/cache-heap-statistics
Apr 14, 2026
Merged

Cache V8 heap stats instead of querying them on every call#4778
joshua-spacetime merged 5 commits intomasterfrom
joshua/cache-heap-statistics

Conversation

@joshua-spacetime
Copy link
Copy Markdown
Collaborator

Description of Changes

Previously we would invoke V8's GetHeapStatistics on every reducer call in order to compute the memory_allocation part of its ExecutionStats. We already sample heap statistics periodically, so now we cache the result after each sample and just read the cached value after each call. Memory allocation is used for energy tracking and so eventual consistency is fine.

API and ABI breaking changes

None

Expected complexity level and risk

1

Testing

Refactor/optimization

Copy link
Copy Markdown
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

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

Looks good, but I'd like to just embed your comment re. eventual consistency before we merge.

Comment thread crates/core/src/host/v8/mod.rs
joshua-spacetime and others added 2 commits April 13, 2026 09:19
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: joshua-spacetime <josh@clockworklabs.io>
@joshua-spacetime joshua-spacetime added this pull request to the merge queue Apr 14, 2026
Merged via the queue into master with commit f309d05 Apr 14, 2026
32 of 34 checks passed
@joshua-spacetime joshua-spacetime deleted the joshua/cache-heap-statistics branch April 14, 2026 04:55
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.

3 participants