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

get heap statistics from deno #558

Merged
merged 4 commits into from
Aug 8, 2024
Merged

get heap statistics from deno #558

merged 4 commits into from
Aug 8, 2024

Conversation

Geal
Copy link
Contributor

@Geal Geal commented Aug 6, 2024

This adds a planner event to request V8 heap statistics.

This data is gathered from the JS side because the related methods from the rust side require a &mut access to the runtime, which is impossible since it already runs in an infinite loop.
Since we elected to not run the prelude parts of deno which register functions like Deno.memory_usage, we intern the op_runtime_memory_usage function and import it directly as a host function, as we've done already with op_crypto_get_random_values. To avoid hosting too much code, the rss field is not filled (it needs platform specific functions), since that info can generally be obtained by other means.

@Geal Geal marked this pull request as ready for review August 6, 2024 15:20
@Geal Geal requested review from a team as code owners August 6, 2024 15:20
@Geal Geal marked this pull request as draft August 6, 2024 16:21
@Geal Geal marked this pull request as ready for review August 6, 2024 16:21
@Geal Geal merged commit 7ad0665 into main Aug 8, 2024
13 checks passed
@Geal Geal deleted the geal/get_heap_statistics branch August 8, 2024 09:17
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct MemoryUsage {
//rss: usize,
Copy link
Member

Choose a reason for hiding this comment

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

keep or go? (i commented on the release PR just now but it's the same question)

let mut s = v8::HeapStatistics::default();
scope.get_heap_statistics(&mut s);
MemoryUsage {
//rss: rss(),
Copy link
Member

Choose a reason for hiding this comment

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

same.

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.

4 participants