File tree 5 files changed +32
-4
lines changed
5 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -511,6 +511,9 @@ Next major version (4.05.0):
511
511
- GPR#1075: Ensure that zero-sized float arrays have zero tags.
512
512
(Mark Shinwell, Leo White)
513
513
514
+ * GPR#1088: Gc.minor_words now returns accurate numbers.
515
+ (Stephen Dolan)
516
+
514
517
Next minor version (4.04.1):
515
518
----------------------------
516
519
Original file line number Diff line number Diff line change @@ -47,15 +47,15 @@ external stat : unit -> stat = "caml_gc_stat"
47
47
external quick_stat : unit -> stat = " caml_gc_quick_stat"
48
48
external counters : unit -> (float * float * float ) = " caml_gc_counters"
49
49
external minor_words : unit -> (float [@ unboxed])
50
- = " caml_gc_minor_words" " caml_gc_minor_words_unboxed" [ @@ noalloc]
50
+ = " caml_gc_minor_words" " caml_gc_minor_words_unboxed"
51
51
external get : unit -> control = " caml_gc_get"
52
52
external set : control -> unit = " caml_gc_set"
53
53
external minor : unit -> unit = " caml_gc_minor"
54
54
external major_slice : int -> int = " caml_gc_major_slice"
55
55
external major : unit -> unit = " caml_gc_major"
56
56
external full_major : unit -> unit = " caml_gc_full_major"
57
57
external compact : unit -> unit = " caml_gc_compaction"
58
- external get_minor_free : unit -> int = " caml_get_minor_free" [ @@ noalloc]
58
+ external get_minor_free : unit -> int = " caml_get_minor_free"
59
59
external get_bucket : int -> int = " caml_get_major_bucket" [@@ noalloc]
60
60
external get_credit : unit -> int = " caml_get_major_credit" [@@ noalloc]
61
61
external huge_fallback_count : unit -> int = " caml_gc_huge_fallback_count"
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ external counters : unit -> float * float * float = "caml_gc_counters"
171
171
is as fast as [quick_stat]. *)
172
172
173
173
external minor_words : unit -> (float [@ unboxed])
174
- = " caml_gc_minor_words" " caml_gc_minor_words_unboxed" [ @@ noalloc]
174
+ = " caml_gc_minor_words" " caml_gc_minor_words_unboxed"
175
175
(* * Number of words allocated in the minor heap since the program was
176
176
started. This number is accurate in byte-code programs, but only an
177
177
approximation in programs compiled to native code.
@@ -219,7 +219,7 @@ val allocated_bytes : unit -> float
219
219
started. It is returned as a [float] to avoid overflow problems
220
220
with [int] on 32-bit machines. *)
221
221
222
- external get_minor_free : unit -> int = " caml_get_minor_free" [ @@ noalloc]
222
+ external get_minor_free : unit -> int = " caml_get_minor_free"
223
223
(* * Return the current size of the free space inside the minor heap.
224
224
225
225
@since 4.03.0 *)
Original file line number Diff line number Diff line change
1
+ type t = Leaf of int | Branch of t * t
2
+
3
+ let a = [| 0.0 |]
4
+
5
+ let rec allocate_lots m = function
6
+ | 0 -> Leaf m
7
+ | n -> Branch (allocate_lots m (n-1 ), allocate_lots (m+ 1 ) (n-1 ))
8
+
9
+ let measure f =
10
+ let a = Gc. minor_words () in
11
+ f () ;
12
+ let c = Gc. minor_words () in
13
+ c -. a
14
+
15
+ let () =
16
+ let n = measure (fun () -> a.(0 ) < - Gc. minor_words () ) in
17
+ (* Gc.minor_words should not allocate, although bytecode
18
+ generally boxes the floats *)
19
+ assert (n < 10. );
20
+ if Sys. backend_type = Sys. Native then assert (n = 0. );
21
+ let n = measure (fun () -> Sys. opaque_identity (allocate_lots 42 10 )) in
22
+ (* This should allocate > 3k words (varying slightly by unboxing) *)
23
+ assert (n > 3000. );
24
+ print_endline " ok"
Original file line number Diff line number Diff line change
1
+ ok
You can’t perform that action at this time.
0 commit comments