Skip to content

Attempt to fix PR7157 (too many minor collections)#488

Merged
mshinwell merged 1 commit intoocaml:4.03from
mshinwell:pr7157-4.03-take2
Mar 3, 2016
Merged

Attempt to fix PR7157 (too many minor collections)#488
mshinwell merged 1 commit intoocaml:4.03from
mshinwell:pr7157-4.03-take2

Conversation

@mshinwell
Copy link
Copy Markdown
Contributor

d94f1da appears to have introduced a regression, with increased numbers of minor collections.

In the function realloc_generic_table there is pointer arithmetic, at first sight unchanged by this patch, that starts from e.g. "tbl->base". The units of the arithmetic will be the size of the underlying type (T when tbl->base has type T* ). In the 4.03 branch, T is just "char" (in the patch it was "void", but the common interpretation of that having the same size as "char" would have also produced the bug). As such, the result of calculations that add to the base pointer would be rather smaller than prior to the above patch, when the underlying type was "value*". Consequentially the ref table would become full more often and trigger more minor GCs (from line 510 of byterun/minor_gc.c).

This patch changes the underlying type to "void*" instead, which should restore the old behaviour.

I haven't yet tested this since others should probably give opinions first.

@mshinwell mshinwell added this to the 4.03.0 milestone Feb 29, 2016
@mshinwell
Copy link
Copy Markdown
Contributor Author

I've updated this to use Alain's patch from the Mantis issue. I forgot there was an explicit element_size already.

@mshinwell
Copy link
Copy Markdown
Contributor Author

Except that Alain's patch doesn't fix all the occurrences. Sigh. One moment

@mshinwell
Copy link
Copy Markdown
Contributor Author

Patch updated again.

@alainfrisch
Copy link
Copy Markdown
Contributor

I haven't yet tested this since others should probably give opinions first.

I only tested my (partial) patch on the specific benchmark and recovered the original performances. I think it's better to use the element_size, so as to keep the generality of the new implementation (allowing to define tables with elements of different sizes).

@mshinwell
Copy link
Copy Markdown
Contributor Author

I'm looking at the testsuite failure

@mshinwell
Copy link
Copy Markdown
Contributor Author

@bobot I can't see what's wrong with this. My suspicion is that the change to make the ephemeron ref_table function correctly has exposed some other, possibly unrelated, bug. Can you have a look?

@bobot
Copy link
Copy Markdown
Contributor

bobot commented Mar 2, 2016

OK I will. Today I hope.

@bobot
Copy link
Copy Markdown
Contributor

bobot commented Mar 2, 2016

I think there is still a problem with the generic code for ref_table: bobot/ocaml@b471067 adds assertions about an invariant of the caml_ephe_ref_elt: Assert(re->offset < Wosize_val(re->ephe)). It is verified when the elements are added but not when the elements are iterated.

@bobot
Copy link
Copy Markdown
Contributor

bobot commented Mar 2, 2016

In fact after more debugging, @mshinwell is right it is another bug: weak.ml is using Obj.truncate on weak pointers that are now ephemerons. I forgot about that. I'm impressed (and a little scared) that Obj.truncate is able to take care of the case when the discarded part is mentioned in ref_table (usual one not ephe_ref_table). I'm preparing a patch that fix the bug, in the simplest way.

@bobot
Copy link
Copy Markdown
Contributor

bobot commented Mar 3, 2016

The commit bobot/ocaml@c1801a8 should fix the other bug. @mshinwell you can take it with its parent (bobot/ocaml@b471067) or not (at the end it adds only one assert, the other is removed by the next commit). The testsuite is now ok.

@mshinwell mshinwell force-pushed the pr7157-4.03-take2 branch 2 times, most recently from 60edfc5 to 4c6acde Compare March 3, 2016 08:54
@mshinwell mshinwell force-pushed the pr7157-4.03-take2 branch from 4c6acde to fb84058 Compare March 3, 2016 08:56
@mshinwell
Copy link
Copy Markdown
Contributor Author

I've merged the changes from @bobot, and will now merge the whole thing.

mshinwell added a commit that referenced this pull request Mar 3, 2016
GPR#488: [Attempt to] Fix PR7157 (too many minor collections)
@mshinwell mshinwell merged commit 6e223fd into ocaml:4.03 Mar 3, 2016
stedolan pushed a commit to stedolan/ocaml that referenced this pull request May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants