Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005290OCaml~DO NOT USE (was: OCaml general)public2011-06-17 01:002015-07-24 10:39
ReporterBoris Yakobowski 
Assigned Toxleroy 
PlatformOSOS Version
Product Version3.12.0 
Target VersionFixed in Version4.00.0 
Summary0005290: Hashing of custom blocks
DescriptionHashtbl.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.)
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
Boris Yakobowski (reporter)
2011-06-17 11:55

A precision: the custom blocks are on Nats, not on bigints.
xleroy (administrator)
2011-06-20 19:03

*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.
xleroy (administrator)
2011-07-23 12:25

Tentative fix in SVN trunk, will go in 3.13.

- Issue History
Date Modified Username Field Change
2011-06-17 01:00 Boris Yakobowski New Issue
2011-06-17 10:55 Pascal Cuoq Note Added: 0006014
2011-06-17 10:56 Pascal Cuoq Note Deleted: 0006014
2011-06-17 11:55 Boris Yakobowski Note Added: 0006015
2011-06-20 19:03 xleroy Note Added: 0006018
2011-06-20 19:03 xleroy Status new => assigned
2011-06-20 19:04 xleroy Assigned To => xleroy
2011-07-23 12:25 xleroy Note Added: 0006058
2011-07-23 12:25 xleroy Status assigned => resolved
2013-06-15 09:29 xleroy Resolution open => fixed
2013-06-15 09:29 xleroy Fixed in Version => 4.00.0
2015-07-24 10:39 xleroy Status resolved => closed
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker