New issue
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
Allocating custom blocks become expensive with large major heaps #7676
Comments
Comment author: @xavierleroy Is this another incarnation of the familiar "allocation of custom objects mess up the speed of the major GC" problem? Or a distinct, new problem? |
Comment author: @alainfrisch
Of course it's in the same family of problems, but I believe it's distinct from other reports. What I find specifically weird here is the second condition: (caml_extra_heap_resources > (double) caml_minor_heap_wsz / 2.0 / (double) caml_stat_heap_wsz) which can ultimately lead to a major GC for every allocation of a custom block. I don't understand the rationale behind computing the ratio of the size of the two heaps and comparing it with "caml_extra_heap_resources". The first condition, OTOH, seems well understood (including its problems), and corresponds to the documented behavior. Other tickets are about:
|
Comment author: @alainfrisch The sample program now exihibits a much nicer behavior thanks to #1738 . That said, I believe it would still be worth revisiting the condition if (caml_extra_heap_resources which looks super weird to me, so I'm leaving this ticket open. |
Comment author: @damiendoligez |
Original bug ID: 7676
Reporter: @alainfrisch
Assigned to: @damiendoligez
Status: resolved (set by @damiendoligez on 2018-11-13T12:31:33Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.08.0+dev/beta1/beta2
Category: runtime system and C interface
Related to: #4108 #6133 #6294 #6962
Monitored by: @ygrek @dbuenzli @yakobowski
Bug description
Custom blocks allocated in or moved to the major heap add some "pressure" to trigger a major GC slice. The current criterion is such that a GC slice is triggered more often if the size of the major heap grows. This can result is noticeable slowdown.
The function implementing this strategy is:
The second criterion becomes easier and easier to satisfy as the size of the major heap grows. It is not clear to me why the ratio of the size of the minor and major heaps is taken into account, nor why the constant 2 was chosen.
See below for a program that illustrates the behavior. It runs two computations starting from different heap sizes. The first one allocates a large block (in the major heap), then does many small allocations (to trigger a minor GC). The second one create an in_channel (which is a custom block, with a "pressure ratio" of 1/1000, i.e. one asks to force a full GC cycle every 1000 allocations). The timings are:
n is proportional to the size of the initial heap. One sees clearly that the speed of the first computation does not depend on the heap size, while the speed of the second one is directly impacted.
The marginal cost of opening a channel raises to about 2ms and would continue to grow with larger major heaps.
This specific problem with in_channel could be addressed in part by reducing the ratio 1/1000, but the real issue here might be with the criterion above, which impacts all kinds of custom objects (that add "pressure").
Additional information
The text was updated successfully, but these errors were encountered: