Shapes: Add an option to share memo tables accros reductions#11020
Shapes: Add an option to share memo tables accros reductions#11020voodoos wants to merge 2 commits intoocaml:trunkfrom
Conversation
850aa64 to
013e724
Compare
Co-authored-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
|
Sharing the memoization table across reductions is only valid if the |
|
We discussed with @trefis and we think that:
However it is not clear to us how we should make this clear from the API. Given the rare use-cases for this it might be sufficient to document that clearly in the functor's signature ? |
|
I see three approaches that I think would be always correct:
|
|
Let me try to rephrase a bit what @voodoos just said, because there's a potential for a vocabulary clash. So, here's my version of his argument: reusing the cache across calls made with different A first thing to note (which is @voodoos's first point) is that Now, if we wanted to share the cache across compilation units, we don't have any such guarantee that a particular |
|
Yes, Params.find_shape is the only way to have a reduction depend on what I call the "global environment", and you call the "local environment". If your global environment is just an Env.t, I guess we could just compare/hash them by summaries, and maybe just moving to a pair |
While developing a new tool that indexes uids from cmt files we realised that performing so many shapes reductions would benefit from a shared memo table. (In the current implementation a new memo table is created for each call to
reduce.)In this PR I propose a new option that is passed during the functor instantiation to choose to use persistent memo tables instead of reduce-bound ones. In that case the memo tables are created during the functor instantiation and are thus shared by all subsequent
reducecalls.This led to a nice performance improvement when indexing the cmts of functor-hungry projects: on Irmin the indexing time for all the cmts of the main lib drops from 14.5s to 1.3s.