ocamldoc: reimplement a slow function#8836
Conversation
With this minor change to a naively-implemented function, manpage generation for the compiler (stdlib + compiler-libs) goes from 1.8s to 0.4s on my machine.
dra27
left a comment
There was a problem hiding this comment.
LGTM - perhaps we need an attribute to mark List.mem as banned within the compiler codebase!
|
The various list reversals all look correct - is the compiler manual a good enough test to diff before or after, or are there already relevant tests in the testsuite which would catch the search list ending up in the wrong order? |
|
That's a good point, I wanted to compare the (Initially I had inlined the deduplication code in the function itself, which saves two list reversals, but there is no performance impact in doing so, so I went for the more separated code.) (Note: the timings above are given when generating the documentation with |
|
Re. |
|
All good - I'd initially wondered about suggestion the inlining of the reversal, but it sounds as though having to append short lists to a long list dominates the saving of the two overall list reversals. We need the TRMC patch 🙂 |
|
The initial algorithm was quadratic and the new one is linear, so the constant factors don't matter much -- the new runtime is negligible. |
|
I confirm that the produced manpages are exactly identical. On my machine today, the current make rule (using bytecode ocamldoc instead of native ocamldoc) goes from 16s to 14s with the patch -- not much of a difference. I guess I'll look at using the native ocamldoc by default when available, in another PR. |
With this minor change to a naively-implemented function, manpage generation
for the compiler (stdlib + compiler-libs) goes from 1.8s to 0.4s on my machine.