We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The reason seems to be that obj_counter is never reset to zero, so extern_resize_position_table is called on every invocation.
obj_counter
extern_resize_position_table
Here is a dirty proof (another way to observe is to run similar program and put breakpoint on extern_resize_position_table):
$ ocamlopt q_stubs.c q.ml -o q $ ./q 0) obj_counter 111 reachable_words 333 1) obj_counter 222 reachable_words 333 2) obj_counter 333 reachable_words 333 3) obj_counter 444 reachable_words 333 4) obj_counter 555 reachable_words 333 5) obj_counter 666 reachable_words 333 6) obj_counter 777 reachable_words 333 7) obj_counter 888 reachable_words 333 8) obj_counter 999 reachable_words 333 9) obj_counter 1110 reachable_words 333
$ cat q.ml external obj_counter : unit -> int = "ml_obj_counter" let () = let a = Array.init 10 (fun _ -> List.init 111 (fun _ -> 'a')) in Array.iteri (fun i l -> Printf.printf "%d) obj_counter %d reachable_words %d\n%!" i (obj_counter ()) (Obj.reachable_words @@ Obj.repr l)) a $ cat q_stubs.c #include "caml/memory.h" uintnat reference; value ml_obj_counter(value v) { return Val_int(*(uintnat *)((char *)&reference - 0xc0928 + 0xbc178)); }
magic numbers are addresses of reference and obj_counter as shown by nm - quick way to access obj_counter w/o rebuilding ocaml
reference
nm
The text was updated successfully, but these errors were encountered:
Fix performance bug in Obj.reachable_words (#10731)
18c4d16
Fixes: #10730
alainfrisch
Successfully merging a pull request may close this issue.
The reason seems to be that
obj_counter
is never reset to zero, soextern_resize_position_table
is called on every invocation.Here is a dirty proof (another way to observe is to run similar program and put breakpoint on extern_resize_position_table):
magic numbers are addresses of
reference
andobj_counter
as shown bynm
- quick way to access obj_counter w/o rebuilding ocamlThe text was updated successfully, but these errors were encountered: