From ce76f5f3619e2c4b5de1c4f61a8acbd271f37919 Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Wed, 23 Aug 2023 15:18:45 +0200 Subject: [PATCH 1/2] #12491: do not change GC pace when creating proxies of existing subarrays --- runtime/bigarray.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/bigarray.c b/runtime/bigarray.c index cd345048e233..e71e01ff9128 100644 --- a/runtime/bigarray.c +++ b/runtime/bigarray.c @@ -225,7 +225,7 @@ CAMLexport value caml_ba_alloc(int flags, int num_dims, void * data, intnat * dim) { uintnat num_elts, asize, size; - int i, is_managed; + int i, must_alloc; value res; struct caml_ba_array * b; intnat dimcopy[CAML_BA_MAX_NUM_DIMS]; @@ -242,14 +242,14 @@ caml_ba_alloc(int flags, int num_dims, void * data, intnat * dim) caml_ba_element_size[flags & CAML_BA_KIND_MASK], &size)) caml_raise_out_of_memory(); - if (data == NULL) { + must_alloc = (data == NULL); + if (must_alloc) { data = malloc(size); if (data == NULL && size != 0) caml_raise_out_of_memory(); flags |= CAML_BA_MANAGED; } asize = SIZEOF_BA_ARRAY + num_dims * sizeof(intnat); - is_managed = ((flags & CAML_BA_MANAGED_MASK) == CAML_BA_MANAGED); - res = caml_alloc_custom_mem(&caml_ba_ops, asize, is_managed ? size : 0); + res = caml_alloc_custom_mem(&caml_ba_ops, asize, must_alloc ? size : 0); b = Caml_ba_array_val(res); b->data = data; b->num_dims = num_dims; From f8a46a42be8dfb1c8203a38cc6c7f9b626ebb3dc Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Wed, 23 Aug 2023 15:20:16 +0200 Subject: [PATCH 2/2] Changes --- Changes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changes b/Changes index 3d8797d9b634..f214418e687a 100644 --- a/Changes +++ b/Changes @@ -302,6 +302,9 @@ Working version `Unix.create_process` (the one used when `posix_spawnp` is unavailable) (Xavier Leroy, report by Chris Vine, review by Nicolás Ojeda Bär) +- #12491: allocating subarrays or slices of bigarrays increases + GC speed wrongly -- as if new memory was allocated + (Gabriel Scherer, report by Ido Yariv, review by ???) OCaml 5.1.0 release branch --------------------------