8000 Gc stats fix by mdelvecchio-jsc · Pull Request #2825 · oxcaml/oxcaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Gc stats fix #2825

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ocaml/runtime/caml/gc_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ void caml_accum_alloc_stats(
void caml_collect_alloc_stats_sample(
caml_domain_state *local,
struct alloc_stats *sample);
void caml_collect_alloc_stats_live(
struct alloc_stats *live);

struct gc_stats {
struct alloc_stats alloc_stats;
Expand Down
14 changes: 5 additions & 9 deletions ocaml/runtime/gc_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,13 @@ CAMLprim value caml_gc_counters(value v)
CAMLlocal1 (res);

/* get a copy of these before allocating anything... */
double minwords = Caml_state->stat_minor_words
+ (double) Wsize_bsize ((uintnat)Caml_state->young_end -
(uintnat) Caml_state->young_ptr);
double prowords = Caml_state->stat_promoted_words;
double majwords = Caml_state->stat_major_words +
(double) Caml_state->allocated_words;
struct alloc_stats alloc_stats;
caml_collect_alloc_stats_live(&alloc_stats);

res = caml_alloc_3(0,
caml_copy_double (minwords),
caml_copy_double (prowords),
caml_copy_double (majwords));
caml_copy_double (alloc_stats.minor_words),
caml_copy_double (alloc_stats.promoted_words),
caml_copy_double (alloc_stats.major_words));
CAMLreturn (res);
}

Expand Down
10 changes: 9 additions & 1 deletion ocaml/runtime/gc_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ void caml_collect_alloc_stats_sample(
sample->forced_major_collections = local->stat_forced_major_collections;
}

void caml_collect_alloc_stats_live(
struct alloc_stats *live)
{
caml_collect_alloc_stats_sample(Caml_state, live);
live->minor_words += (double) (Caml_state->young_end - Caml_state->young_ptr);
live->major_words += (double) Caml_state->allocated_words;
}

void caml_reset_domain_alloc_stats(caml_domain_state *local)
{
local->stat_minor_words = 0;
Expand Down Expand Up @@ -155,7 +163,7 @@ void caml_compute_gc_stats(struct gc_stats* buf)
}
else {
struct alloc_stats alloc_stats;
caml_collect_alloc_stats_sample(Caml_state, &alloc_stats);
caml_collect_alloc_stats_live(&alloc_stats);
caml_accum_alloc_stats(&buf->alloc_stats, &alloc_stats);
caml_accum_heap_stats(&buf->heap_stats, &s->heap_stats);
//FIXME use live heap stats instead of sampled heap stats below?
Expand Down
12 changes: 4 additions & 8 deletions ocaml/runtime/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,8 @@ CAMLexport void caml_do_exit(int retcode)
if ((atomic_load_relaxed(&caml_verb_gc) & 0x400) != 0) {
caml_compute_gc_stats(&s);
{
/* cf caml_gc_counters */
double minwords = s.alloc_stats.minor_words
+ (double) (domain_state->young_end - domain_state->young_ptr);
double majwords = s.alloc_stats.major_words
+ (double) domain_state->allocated_words;
double allocated_words = minwords + majwords
double allocated_words = s.alloc_stats.minor_words
+ s.alloc_stats.major_words
- s.alloc_stats.promoted_words;
intnat heap_words =
s.heap_stats.pool_words + s.heap_stats.large_words;
Expand All @@ -162,11 +158,11 @@ CAMLexport void caml_do_exit(int retcode)
caml_gc_message(0x400, "allocated_words: %"ARCH_INTNAT_PRINTF_FORMAT"d\n",
(intnat)allocated_words);
caml_gc_message(0x400, "minor_words: %"ARCH_INTNAT_PRINTF_FORMAT"d\n",
(intnat) minwords);
(intnat) s.alloc_stats.minor_words);
caml_gc_message(0x400, "promoted_words: %"ARCH_INTNAT_PRINTF_FORMAT"d\n",
(intnat) s.alloc_stats.promoted_words);
caml_gc_message(0x400, "major_words: %"ARCH_INTNAT_PRINTF_FORMAT"d\n",
(intnat) majwords);
(intnat) s.alloc_stats.major_words);
caml_gc_message(0x400,
"minor_collections: %"ARCH_INTNAT_PRINTF_FORMAT"d\n",
(intnat) atomic_load(&caml_minor_collections_count));
Expand Down
0