Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005551OCamlOCaml generalpublic2012-03-20 22:092013-08-31 12:48
Reporterfrisch 
Assigned Tofrisch 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0005551: Repeated calls to find_in_path degrades performances
DescriptionIn 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:

  - The module name if "*predef*" (created internally by the compiler) --> in this case, find_pers_struct should fail immediatly.

  - A real module name, whose .cmi is not in the load path. This is not a fatal error if the module is only used to expand abbreviations (types are considered abstract).


I propose to define Env.persistent_structures as:

let persistent_structures =
  (Hashtbl.create 17 : (string, pers_struct option) Hashtbl.t)

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.)
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0007118)
frisch (developer)
2012-03-20 23:27
edited on: 2012-03-20 23:47

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)?

(0007121)
frisch (developer)
2012-03-21 10:39

We need to be careful in the toplevel, in interactive mode, because persistent_structures is not cleared between phrases, and one might want to use a .cmi file which became available only during the session.
(0007122)
frisch (developer)
2012-03-21 12:37
edited on: 2012-03-21 12:38

Commit 12251 (in trunk, not 4.00).

FWIW, the tests I was mentioning now runs in 8sec on another machine (Windows, with an SSD drive) where it used to take 300sec.

(0007176)
frisch (developer)
2012-03-26 20:20

Pushed to the trunk (r12279).

- Issue History
Date Modified Username Field Change
2012-03-20 22:09 frisch New Issue
2012-03-20 23:13 frisch Description Updated View Revisions
2012-03-20 23:27 frisch Note Added: 0007118
2012-03-20 23:42 frisch Note Edited: 0007118 View Revisions
2012-03-20 23:45 frisch Note Edited: 0007118 View Revisions
2012-03-20 23:47 frisch Note Edited: 0007118 View Revisions
2012-03-21 10:36 frisch Assigned To => frisch
2012-03-21 10:36 frisch Status new => assigned
2012-03-21 10:39 frisch Note Added: 0007121
2012-03-21 12:37 frisch Note Added: 0007122
2012-03-21 12:38 frisch Note Edited: 0007122 View Revisions
2012-03-22 06:27 frisch Status assigned => resolved
2012-03-22 06:27 frisch Resolution open => fixed
2012-03-26 20:20 frisch Note Added: 0007176
2013-08-31 12:48 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker