Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005555OCamlstandard librarypublic2012-03-26 09:272015-12-11 19:04
ReporterChristoph Bauer 
Assigned Tolefessan 
PrioritynormalSeverityminorReproducibilityhave not tried
PlatformOSOS Version
Product Version3.12.1 
Target VersionFixed in Version4.00.0+dev 
Summary0005555: Hashtbl.remove/clear never shrink the internal bucket array
DescriptionThe internal bucket array of an hashtable grows in Hashtbl.add/replace,
but neither Hashtbl.remove nor Hashtbl.clear shrink the table.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
lefessan (developer)
2012-05-15 11:01

A new function Hashtbl.reset has been added to resize the bucket table to its initial size.
rixed (reporter)
2012-05-15 13:03

It's not quite resizing. So the user is supposed to track the size of the hash and reset it when judged appropriate ?
lefessan (developer)
2012-05-15 15:58

True, it's not resizing, it is clearing and resetting to the initial size. Users should only use it if they need to recover some space, otherwise, they probably want to keep the current size and just clear all entries.
rixed (reporter)
2012-05-15 16:12

Oh, reading your comment then the actual diff I realize that reset also clears the hashtbl.

I then respectfully disagree with closing this ticket, then.
That's very nice to have both clear and reset behavior (but I'd favor to add an optional boolean argument to clear that would additionnally shrinks the hash size).

It seams to me that the initial concern was that when using long lived hashtables which sizes may vary in great proportion then the overall size of all hashtable growth continuously, which hurts memory and thus performances.

I understand that shrinking dynamically a hash is a tedious topic (one must avoid to continuously grow/shrink), though.
Christoph Bauer (reporter)
2012-06-06 13:35

I would have expect, that Hashtbl.remove calls resize like add, if the table is less than 3/8 (or 1/4) full.

- Issue History
Date Modified Username Field Change
2012-03-26 09:27 Christoph Bauer New Issue
2012-03-26 14:26 lefessan Assigned To => lefessan
2012-03-26 14:26 lefessan Status new => assigned
2012-05-15 11:01 lefessan Note Added: 0007431
2012-05-15 11:01 lefessan Status assigned => resolved
2012-05-15 11:01 lefessan Fixed in Version => 4.00.0+dev
2012-05-15 11:01 lefessan Resolution open => fixed
2012-05-15 13:03 rixed Note Added: 0007433
2012-05-15 15:58 lefessan Note Added: 0007434
2012-05-15 16:12 rixed Note Added: 0007436
2012-06-06 13:35 Christoph Bauer Note Added: 0007519
2015-12-11 19:04 xleroy Status resolved => closed
2017-02-23 16:43 doligez Category OCaml standard library => standard library

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker