Ticket #1258 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

hash table shrinks following clrhash

Reported by: gz Owned by:
Priority: normal Milestone:
Component: Runtime (threads, GC) Version: trunk
Keywords: Cc:

Description

See  http://lists.clozure.com/pipermail/openmcl-devel/2015-January/010839.html

The problem seems to be the lock-free version of clrhash not resetting nhash.grow-threshold.

? (let ((h (make-hash-table :size 100)))
    (format t "~&initial: ~s" (ccl::nhash.grow-threshold h))
    (dotimes (i 7) (setf (gethash i h) i))
    (format t "~&after use: ~s" (ccl::nhash.grow-threshold h))
    (clrhash h)
    (format t "~&after clrhash: ~s" (ccl::nhash.grow-threshold h)))
initial: 100
after use: 93
after clrhash: 93

Non-lock-free version works fine:

? (let ((h (make-hash-table :size 100 :lock-free nil)))
    (format t "~&initial: ~s" (ccl::nhash.grow-threshold h))
    (dotimes (i 7) (setf (gethash i h) i))
    (format t "~&after use: ~s" (ccl::nhash.grow-threshold h))
    (clrhash h)
    (format t "~&after clrhash: ~s" (ccl::nhash.grow-threshold h)))
initial: 100
after use: 93
after clrhash: 100

Change History

comment:1 Changed 2 years ago by gz

  • Status changed from new to closed
  • Resolution set to fixed

(In [16340]) In lock-free-rehash, never shrink the vector below the current capacity, or below the size originally specified to make-hash-table. In lock-free-clrhash, create a new vector instead of clearing the old if the remaining capacity would be too small.

Fixes ticket:1258

Note: See TracTickets for help on using tickets.