New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove expensive debug assertion from dynlink #10184
Remove expensive debug assertion from dynlink #10184
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't decide if the intention of let _ = function_name
is more or less clear than switching off warning 32!
Equally if the check isn't useful, why not remove it entirely or, if it's potentially useful at some point in the future, change L278 to be if debugging_dynlink then State.invariant state;
?
otherlibs/dynlink/dynlink_common.ml
Outdated
@@ -71,6 +71,8 @@ module Make (P : Dynlink_platform_intf.S) = struct | |||
assert (String.Set.subset t.public_dynamically_loaded_units ifaces); | |||
assert (String.Set.subset t.public_dynamically_loaded_units implems) | |||
|
|||
let _ = invariant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not instead have let[@ocaml.warning "-32"] invariant t =
above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I prefer let _ = inveriant
or let () = ignore invariant
, which is a clear idiom (to me) and less visually noisy.
The invariant was added in 6526a0c (#1063).
Can you provide a bit more details?
|
I think the sets get very large. We have some cmxs files being loaded, that takes 14s and perf says that 53% of the time is spent in the
The function is only
The function is good documentation of the invariants of the data. It is a common idiom for a data-structure to include a function called |
I agree that these assertions should not be run by default. However, I don't like dead code left there just in case, with hacks to silence the "unused code" warning. In order of decreasing preference, I would rather
|
223e4ad
to
83617de
Compare
83617de
to
4e12f69
Compare
I went with option 1, rebased and added a Changes entry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks.
Dynlink_common.check
includes a call to aninvariant
function that just contains assertions. These assertions turn out to be expensive and don't really provide any benefit. This PR removes the call toinvariant
.