printtyp: cache short path data in wrap_env#9889
Conversation
|
The gap between how simple the code looks and how delicate it is to review is quite baffling for this PR. The rest of this comment is going to be a brain dump of where I am in my review.
|
|
In term of dependencies, the However, since the set of modules loaded in the persistent environment only grows with time, knowing that this snapshot is equal to the current set of persistent modules is enough to know that the persistent environment did not change between the snapshot and the exit of The two variables One consequence is that with the current PR, we lose some progress in the computation of the |
|
Thanks! Here is what I understand now. We are doing key/value caching with just one cache slot, where
with the subtlety that the value is not constant for a given key, it changes over time, but monotonically: it always correct to reset the cached value of a key to a previous state.
The new |
|
With what I understand now, I believe the PR is correct. Still, don't you think that it would be useful to codify some of this now-shared knowledge into code comments? |
|
Wrapping with an identity Would the following avoid the reset? let wrap_env fenv ftree arg =
let old_env = !printing_env in
let old_depth = !printing_depth in
let old_cont = !printing_cont in
let old_pers = !printing_pers in
let old_map = !printing_map in
let new_env = fenv old_env in
set_printing_env new_env;
let tree = ftree arg in
printing_pers := old_pers;
printing_old := old_env;
if old_env != new_env then begin
printing_map := old_map;
printing_depth := old_depth;
printing_cont := old_cont;
end;
(* set_printing_env checks that persistent modules did not change *)
set_printing_env env;
treeI also have a new naive question: why are we calling |
if old_env != new_env then beginin fact this should probably be if old_env != !printing_env then beginor if !printing_old != !printing_env then begin |
|
I would suggest the slightly less efficient: if not (same_printing_env old_env) then ...
set_printing_env old_envI could certainly add comments that we are snapshotting the short-path cache, with printing_old and printing_pers as keys. Did you have other points in mind? |
|
I trust you to add the right amount of comments; I would leave it to you so that we can go back to reviewing the rest of this exciting codebase. |
|
Above I meant that you should rebase your PR with comments as you deem them necessary, but that I'm not necessarily planning to do a careful pass of re-review on them, so you should feel free to go ahead and merge. On the other hand, I feel like a Changes entry would be good to have. The entire reason you are doing this work is to avoid a possible performance regression. If we screwed up and a regression there is, having a Changes entry will help our angry users track us down faster. |
|
I agree that that a changelog entry is a good idea, since the change is not that trivial. Concerning the use of |
You spent time reading Jacques' code, and somehow it changed you. |
d27e1ae to
5d7663a
Compare
This PR makes
Printtyp.wrap_envcache the short-path data associated with the input environment .Extracted from #8929 .