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
PR#6217 Improve perf. of functional record update #538
Conversation
@@ -1235,7 +1235,8 @@ and transl_setinstvar self var expr = | |||
and transl_record env all_labels repres lbl_expr_list opt_init_expr = | |||
let size = Array.length all_labels in | |||
(* Determine if there are "enough" new fields *) | |||
if 3 + 2 * List.length lbl_expr_list >= size | |||
let no_init = match opt_init_expr with None -> true | _ -> false in | |||
if no_init || size > 255 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Config.max_young_wosize
rather than "255"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, thank you.
I'd be interested in seeing the benchmarks, if that's possible. Perhaps just attach the benchmark details to the PR? |
Hello, |
Thanks for the detailed measurements. I merged the pull request in trunk. |
(* Determine if there are "enough" fields (only relevant if this is a | ||
functional-style record update *) | ||
let no_init = match opt_init_expr with None -> true | _ -> false in | ||
if no_init || size >= Config.max_young_wosize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The direction of this test is wrong: should be size <= Config.max_young_wosize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops… sorry about that. Should I make a new pull request?
I believe "<" would be better since the caml_modify
method is already faster with a 256 fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A fix is part of #516
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will cause code bloat in pathological cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What cases do you have in mind? If the size is of the record is larger than 256 then it uses the "duplicate and modify" approach which requires less code.
PR#6217 Improve perf. of functional record update
Co-authored-by: Thibaut Mattio <thibaut.mattio@gmail.com>
See Mantis issue #6217. Benchmarking with
Core_bench
on a 2.5 GHz 64-bit Intel i5-2450M showed that fieldwise copy is always faster while the number of fields is smaller thanMax_young_wosize
(that is, 256); beyond that point the "duplication and modification" method becomes much faster.Benchmark details:
rfu_benchmarks.pdf
CSV results:
rfu_bench.zip