[squeak-dev] The Trunk: Collections-nice.1021.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Aug 17 13:55:47 UTC 2022


Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.1021.mcz

==================== Summary ====================

Name: Collections-nice.1021
Author: nice
Time: 17 August 2022, 3:55:41.813169 pm
UUID: cae7a6c2-091f-6f4a-a1f6-6acc3e5fa59c
Ancestors: Collections-cmm.1020

Align WeakIdentityDictionary comment with current implementation.

Since Collections-ul.897, the slots corresponding to reclaimed associations (those nilled out) are no longer recycled when scanning for a key.

They are recycled only when the dictionary grows, or possibly when we fix some collision after an explicit removal of a key (via removeKey:).

=============== Diff against Collections-cmm.1020 ===============

Item was changed:
  IdentityDictionary subclass: #WeakIdentityDictionary
  	instanceVariableNames: 'vacuum'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'Collections-Weak'!
  
+ !WeakIdentityDictionary commentStamp: 'nice 8/17/2022 15:45' prior: 0!
- !WeakIdentityDictionary commentStamp: 'nice 10/27/2016 20:00' prior: 0!
  I am a WeakIdentityDictionary, that is a dictionary pointing weakly to its associations of key->value pairs.
  I am especially usefull for handling undeclared bindings that will be naturally garbage collected without having to scan all the CompiledMethods.
  
  Instance variables:
      vacuum    <Object> a unique object used for marking empty slots
  
  Due to usage of WeakArray for my own storage, reclaimed slots will be nilled out.
+ I cannot consider a nil slot as empty because garbage collection does not fix collisions.
- I cannot consider a nil slot as empty because of garbage collection does not fix collisions.
  Thus I need to differentiate empty slots (vacuum) from garbaged collected slots (nil).
  
  If I did not reclaim the nil slots and make them vacuum again, then my capacity would grow indefinitely.
+ I skip those nil slots when growing in order to avoid such unbounded growth (see #growTo:).
- My strategy to avoid such growth is to randomly cleanup the garbage collected slot encountered when scanning for a key.
- It should mitigate the growth since this method is used when adding a new entry.
  
+ Due to those not yet cleaned-up nil slots I might over-estimate my size. See #slowSize to get a more relevant but slower answer.!
- Due to those not yet cleaned-up nil slots I might over-estimate my size. Don't take it too literally.!



More information about the Squeak-dev mailing list