Skip to content

get heap statistics from deno#558

Merged
Geal merged 4 commits intomainfrom
geal/get_heap_statistics
Aug 8, 2024
Merged

get heap statistics from deno#558
Geal merged 4 commits intomainfrom
geal/get_heap_statistics

Conversation

@Geal
Copy link
Copy Markdown
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 a review from a team as a code owner August 6, 2024 15:20
@Geal Geal requested a review from a team 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
@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
Copy Markdown
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
Copy Markdown
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