You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5290 Reporter:@yakobowski Assigned to:@xavierleroy Status: closed (set by @xavierleroy on 2015-07-24T08:39:01Z) Resolution: fixed Priority: normal Severity: major Version: 3.12.0 Fixed in version: 4.00.0 Category: ~DO NOT USE (was: OCaml general) Monitored by: "Pascal Cuoq" @ygrek
Bug description
Hashtbl.hash returns 0 on custom blocks, at least those of the standard library (verified on bigints, channels, and by a cursory grep). This is consistent with its documentation "associates a positive integer to any value of any type". However, it is IMHO a very poor choice, as this will always silently lead to abysmal performances when this function is used on such values. It would be more logical to have this function fail, just as polymorphic equality and comparison. Since Hashtbl are about to undergo a massive rewrite in 3.13, please consider deprecating the old behavior and have the function fail.
(For the record, this really bit us. After some reorganization, we started using the polymorphic hashing function, and Frama-C performances dropped terribly. It took us one afternoon to track the culprit.)
(Also, providing a good hash function for bigints/nats, one bound in the custom block, would be great. For example, keep only the 2^(n-1) lowest or highest bits. This cannot be done efficiently in pure Caml.)
The text was updated successfully, but these errors were encountered:
Some standard library types have proper hash functions, e.g. Int32.t, Nativeint.t and Int64.t, but you are correct that channels and nats don't while they should. I put that on my to do list.
Original bug ID: 5290
Reporter: @yakobowski
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2015-07-24T08:39:01Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.12.0
Fixed in version: 4.00.0
Category: ~DO NOT USE (was: OCaml general)
Monitored by: "Pascal Cuoq" @ygrek
Bug description
Hashtbl.hash returns 0 on custom blocks, at least those of the standard library (verified on bigints, channels, and by a cursory grep). This is consistent with its documentation "associates a positive integer to any value of any type". However, it is IMHO a very poor choice, as this will always silently lead to abysmal performances when this function is used on such values. It would be more logical to have this function fail, just as polymorphic equality and comparison. Since Hashtbl are about to undergo a massive rewrite in 3.13, please consider deprecating the old behavior and have the function fail.
(For the record, this really bit us. After some reorganization, we started using the polymorphic hashing function, and Frama-C performances dropped terribly. It took us one afternoon to track the culprit.)
(Also, providing a good hash function for bigints/nats, one bound in the custom block, would be great. For example, keep only the 2^(n-1) lowest or highest bits. This cannot be done efficiently in pure Caml.)
The text was updated successfully, but these errors were encountered: