Skip to content

Commit 29a3c72

Browse files
authored
Fix under-reporting of custom block sizes in runtime4 Gc.Memprof (ocaml-flambda#3520)
The custom block sizes should be rounded *up* to words, not down. (Already correct in runtime5)
1 parent b3ce767 commit 29a3c72

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

runtime4/memprof.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,9 @@ void caml_memprof_track_custom(value block, mlsize_t bytes)
777777
CAMLassert(Is_young(block) || Is_in_heap(block));
778778
if (lambda == 0 || local->suspended) return;
779779

780-
maybe_track_block(block, rand_binom(Wsize_bsize(bytes)),
781-
Wsize_bsize(bytes), SRC_CUSTOM);
780+
uintnat wsize = Wsize_bsize(bytes + sizeof(value) - 1);
781+
maybe_track_block(block, rand_binom(wsize),
782+
wsize, SRC_CUSTOM);
782783
}
783784

784785
/* Shifts the next sample in the minor heap by [n] words. Essentially,

0 commit comments

Comments
 (0)