Merge pull request #9670 from lpw25/stat-full-major-collections
Report full major collections in Gc statsmaster
commit
6302b1e0cc
3
Changes
3
Changes
|
@ -62,6 +62,9 @@ Working version
|
|||
(Xavier Leroy, review by Jacques-Henri Jourdan, Damien Doligez, and
|
||||
Stephen Dolan)
|
||||
|
||||
- #9670: Report full major collections in Gc stats.
|
||||
(Leo White, review by Gabriel Scherer)
|
||||
|
||||
- #9675: Remove the caml_static_{alloc,free,resize} primitives, now unused.
|
||||
(Xavier Leroy, review by Gabriel Scherer)
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ DOMAIN_STATE(intnat, stat_major_collections)
|
|||
DOMAIN_STATE(intnat, stat_heap_wsz)
|
||||
DOMAIN_STATE(intnat, stat_top_heap_wsz)
|
||||
DOMAIN_STATE(intnat, stat_compactions)
|
||||
DOMAIN_STATE(intnat, stat_forced_major_collections)
|
||||
DOMAIN_STATE(intnat, stat_heap_chunks)
|
||||
/* See gc_ctrl.c */
|
||||
|
||||
|
|
|
@ -562,6 +562,7 @@ void caml_compact_heap_maybe (void)
|
|||
caml_gc_message (0x200, "Automatic compaction triggered.\n");
|
||||
caml_empty_minor_heap (); /* minor heap must be empty for compaction */
|
||||
caml_finish_major_cycle ();
|
||||
++ Caml_state->stat_forced_major_collections;
|
||||
|
||||
fw = caml_fl_cur_wsz;
|
||||
fp = 100.0 * fw / (Caml_state->stat_heap_wsz - fw);
|
||||
|
|
|
@ -69,6 +69,7 @@ void caml_init_domain ()
|
|||
Caml_state->stat_heap_wsz = 0;
|
||||
Caml_state->stat_top_heap_wsz = 0;
|
||||
Caml_state->stat_compactions = 0;
|
||||
Caml_state->stat_forced_major_collections = 0;
|
||||
Caml_state->stat_heap_chunks = 0;
|
||||
|
||||
Caml_state->backtrace_active = 0;
|
||||
|
|
|
@ -233,9 +233,10 @@ static value heap_stats (int returnstats)
|
|||
intnat majcoll = Caml_state->stat_major_collections;
|
||||
intnat heap_words = Caml_state->stat_heap_wsz;
|
||||
intnat cpct = Caml_state->stat_compactions;
|
||||
intnat forcmajcoll = Caml_state->stat_forced_major_collections;
|
||||
intnat top_heap_words = Caml_state->stat_top_heap_wsz;
|
||||
|
||||
res = caml_alloc_tuple (16);
|
||||
res = caml_alloc_tuple (17);
|
||||
Store_field (res, 0, caml_copy_double (minwords));
|
||||
Store_field (res, 1, caml_copy_double (prowords));
|
||||
Store_field (res, 2, caml_copy_double (majwords));
|
||||
|
@ -252,6 +253,7 @@ static value heap_stats (int returnstats)
|
|||
Store_field (res, 13, Val_long (cpct));
|
||||
Store_field (res, 14, Val_long (top_heap_words));
|
||||
Store_field (res, 15, Val_long (caml_stack_usage()));
|
||||
Store_field (res, 16, Val_long (forcmajcoll));
|
||||
CAMLreturn (res);
|
||||
}else{
|
||||
CAMLreturn (Val_unit);
|
||||
|
@ -292,9 +294,10 @@ CAMLprim value caml_gc_quick_stat(value v)
|
|||
intnat heap_words = Caml_state->stat_heap_wsz;
|
||||
intnat top_heap_words = Caml_state->stat_top_heap_wsz;
|
||||
intnat cpct = Caml_state->stat_compactions;
|
||||
intnat forcmajcoll = Caml_state->stat_forced_major_collections;
|
||||
intnat heap_chunks = Caml_state->stat_heap_chunks;
|
||||
|
||||
res = caml_alloc_tuple (16);
|
||||
res = caml_alloc_tuple (17);
|
||||
Store_field (res, 0, caml_copy_double (minwords));
|
||||
Store_field (res, 1, caml_copy_double (prowords));
|
||||
Store_field (res, 2, caml_copy_double (majwords));
|
||||
|
@ -311,6 +314,7 @@ CAMLprim value caml_gc_quick_stat(value v)
|
|||
Store_field (res, 13, Val_long (cpct));
|
||||
Store_field (res, 14, Val_long (top_heap_words));
|
||||
Store_field (res, 15, Val_long (caml_stack_usage()));
|
||||
Store_field (res, 16, Val_long (forcmajcoll));
|
||||
CAMLreturn (res);
|
||||
}
|
||||
|
||||
|
@ -504,6 +508,7 @@ CAMLprim value caml_gc_set(value v)
|
|||
caml_empty_minor_heap ();
|
||||
caml_finish_major_cycle ();
|
||||
caml_finish_major_cycle ();
|
||||
++ Caml_state->stat_forced_major_collections;
|
||||
caml_compact_heap (newpolicy);
|
||||
caml_gc_message (0x20, "New allocation policy: %"
|
||||
ARCH_INTNAT_PRINTF_FORMAT "u\n", newpolicy);
|
||||
|
@ -583,6 +588,7 @@ CAMLprim value caml_gc_full_major(value v)
|
|||
if (Is_exception_result(exn)) goto cleanup;
|
||||
caml_empty_minor_heap ();
|
||||
caml_finish_major_cycle ();
|
||||
++ Caml_state->stat_forced_major_collections;
|
||||
test_and_compact ();
|
||||
// call finalisers
|
||||
exn = caml_process_pending_actions_exn();
|
||||
|
@ -617,6 +623,7 @@ CAMLprim value caml_gc_compaction(value v)
|
|||
if (Is_exception_result(exn)) goto cleanup;
|
||||
caml_empty_minor_heap ();
|
||||
caml_finish_major_cycle ();
|
||||
++ Caml_state->stat_forced_major_collections;
|
||||
caml_compact_heap (-1);
|
||||
// call finalisers
|
||||
exn = caml_process_pending_actions_exn();
|
||||
|
|
|
@ -130,6 +130,7 @@ CAMLprim value caml_sys_exit(value retcode_v)
|
|||
intnat heap_chunks = Caml_state->stat_heap_chunks;
|
||||
intnat top_heap_words = Caml_state->stat_top_heap_wsz;
|
||||
intnat cpct = Caml_state->stat_compactions;
|
||||
intnat forcmajcoll = Caml_state->stat_forced_major_collections;
|
||||
caml_gc_message(0x400, "allocated_words: %.0f\n", allocated_words);
|
||||
caml_gc_message(0x400, "minor_words: %.0f\n", minwords);
|
||||
caml_gc_message(0x400, "promoted_words: %.0f\n", prowords);
|
||||
|
@ -146,6 +147,9 @@ CAMLprim value caml_sys_exit(value retcode_v)
|
|||
top_heap_words);
|
||||
caml_gc_message(0x400, "compactions: %"ARCH_INTNAT_PRINTF_FORMAT"d\n",
|
||||
cpct);
|
||||
caml_gc_message(0x400,
|
||||
"forced_major_collections: %"ARCH_INTNAT_PRINTF_FORMAT"d\n",
|
||||
forcmajcoll);
|
||||
}
|
||||
|
||||
#ifndef NATIVE_CODE
|
||||
|
|
|
@ -31,6 +31,7 @@ type stat = {
|
|||
compactions : int;
|
||||
top_heap_words : int;
|
||||
stack_size : int;
|
||||
forced_major_collections: int;
|
||||
}
|
||||
|
||||
type control = {
|
||||
|
@ -70,9 +71,10 @@ open Printf
|
|||
|
||||
let print_stat c =
|
||||
let st = stat () in
|
||||
fprintf c "minor_collections: %d\n" st.minor_collections;
|
||||
fprintf c "major_collections: %d\n" st.major_collections;
|
||||
fprintf c "compactions: %d\n" st.compactions;
|
||||
fprintf c "minor_collections: %d\n" st.minor_collections;
|
||||
fprintf c "major_collections: %d\n" st.major_collections;
|
||||
fprintf c "compactions: %d\n" st.compactions;
|
||||
fprintf c "forced_major_collections: %d\n" st.forced_major_collections;
|
||||
fprintf c "\n";
|
||||
let l1 = String.length (sprintf "%.0f" st.minor_words) in
|
||||
fprintf c "minor_words: %*.0f\n" l1 st.minor_words;
|
||||
|
|
|
@ -72,6 +72,10 @@ type stat =
|
|||
|
||||
stack_size: int;
|
||||
(** Current size of the stack, in words. @since 3.12.0 *)
|
||||
|
||||
forced_major_collections: int;
|
||||
(** Number of forced full major collections completed since the program
|
||||
was started. @since 4.12.0 *)
|
||||
}
|
||||
(** The memory management counters are returned in a [stat] record.
|
||||
|
||||
|
|
Loading…
Reference in New Issue