ocamlfind icon indicating copy to clipboard operation
ocamlfind copied to clipboard

Performance of `Fl_dynload.load_packages` degrades heavily on large OPAM switches

Open ejgallego opened this issue 5 months ago • 1 comments

Dear ocamlfind devs,

I've noticed a large (super-linear) performance degradation of Fl_dynload.load_packages in large OCaml switches, for example, using a bare-bones opam swtich for coq-lsp, we have:

Fl_dynload.load_packages: coq-lsp.serlib.ltac , 0.028070 ms
Fl_dynload.load_packages: coq-lsp.serlib.number_string_notation , 0.025253 ms
Fl_dynload.load_packages: coq-lsp.serlib.tauto , 0.025031 ms
Fl_dynload.load_packages: coq-lsp.serlib.cc_core , 0.025120 ms
Fl_dynload.load_packages: coq-lsp.serlib.cc , 0.024681 ms
Fl_dynload.load_packages: coq-lsp.serlib.firstorder_core , 0.025205 ms
Fl_dynload.load_packages: coq-lsp.serlib.firstorder , 0.025410 ms

if I do opam install memtrace_viewer, I get:

Fl_dynload.load_packages: coq-lsp.serlib.ltac , 0.554432 ms
Fl_dynload.load_packages: coq-lsp.serlib.number_string_notation , 0.567631 ms
Fl_dynload.load_packages: coq-lsp.serlib.tauto , 0.547607 ms
Fl_dynload.load_packages: coq-lsp.serlib.cc_core , 0.550585 ms
Fl_dynload.load_packages: coq-lsp.serlib.cc , 0.549075 ms
Fl_dynload.load_packages: coq-lsp.serlib.firstorder_core , 0.583141 ms
Fl_dynload.load_packages: coq-lsp.serlib.firstorder , 0.558694 ms

If I install more packages Fl_dynload.load_packages become unusable. You can reproduce with simple file calling Fl_dynload.load_packages.

cc: https://github.com/ejgallego/coq-lsp/issues/968

ejgallego avatar Jun 03 '25 08:06 ejgallego

It seems like Fl_package_base.requires_deeply is the function taking a large runtime.

ejgallego avatar Jun 03 '25 09:06 ejgallego