Repeated calls to find_in_path degrades performances #5551
Original bug ID: 5551
In Env.find_pers_struct, when the the .cmi file is not found, this outcome is not cached. The same lookup can thus occur over and over again with the same module name if the .cmi file is not found. This can happen in two cases:
I propose to define Env.persistent_structures as:
let persistent_structures =
and store None when the .cmi file is missing.
We have seen huge speedups by applying this change (under Windows). (E.g. a 6-times speedup for a series of tests calling the toplevel on large files, from 3 minutes to 30 seconds.)
The text was updated successfully, but these errors were encountered:
Comment author: @alainfrisch
FWIW, this micro benchmark:
for i = 1 to 500000 do ignore (Sys.file_exists "foobar") done;;
takes about 18s under Windows (Intel Core i5, 2.4 Ghz), and 0.8 under Linux (VIA Nano U2250, 1.6Ghz). (When "foobar" does not exist. Results are quite close when it does.)
As a side note, it seems that "_access" is about twice as fast as "stat" under Windows. Should we use it in sys.c (under Windows)?