Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005845OCaml~DO NOT USE (was: OCaml general)public2012-12-05 10:262015-12-11 19:08
Assigned Tofrisch 
PrioritylowSeverityfeatureReproducibilityhave not tried
StatusclosedResolutionwon't fix 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0005845: Optimizing boolean arrays
DescriptionI don't know if it's possible but it seems that double arrays are optimized so maybe it could be possible to do so with boolean arrays.

I find to use bool array way more intuitive and flexible than ints, specially because I sometimes don't know the size of my array and don't want to risk an error. After all, 31 bits is small.

So, how difficult would it be to make a boolean array something like an array of ints and let the compiler handle the painful xor, lsr and friends ?
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
frisch (developer)
2012-12-05 10:43

I'm marking this ticket as "won't fix" since I'm pretty sure the request of adding a special "automatic" runtime representation for bool arrays will not be granted.

It would be much better to have a specialized "bit field" data structure (probably implemented on top of strings). Btw, one can argue that it's not so great to have a special representation for float arrays: it adds complexity to the runtime system, limits some optimizations (e.g. for shortcutting lazy values) and imposes a runtime overhead to all array operations (in polymorphic contexts, at least).
gasche (developer)
2012-12-05 11:40

Indeed: I believe there is a (weak) consensus that hardcoding the representation of float arrays was a mistake because it cause various pains in the compiler, runtime system and even metatheory (it's one of the reason why top types are not admissible in OCaml) of the language. We could instead use a specialize, monomorphic datastructures such as Bigarray which provides solid efficiency without the hacks.

The solution here is the same: use a specialized data structure. This can be developed as a third-party library so doesn't need to be in the compiler.

(On a slightly different note, integer bit operations are sometimes a bit disappointing in OCaml because the tagging logic makes them less efficient as they could be. If in the course of developping such a bit-packing library you discover situations where small specialized compile-time optimizations would make an important difference on real-world benchmark, you can contact Pierre Chambart which is interested in working on this kind of optimizations and, maybe, getting them integrated in the compiler.)

- Issue History
Date Modified Username Field Change
2012-12-05 10:26 thomasblanc New Issue
2012-12-05 10:43 frisch Note Added: 0008565
2012-12-05 10:43 frisch Status new => resolved
2012-12-05 10:43 frisch Resolution open => won't fix
2012-12-05 10:43 frisch Assigned To => frisch
2012-12-05 11:40 gasche Note Added: 0008567
2015-12-11 19:08 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