[squeak-dev] The Inbox: Collections-ct.996.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Mar 25 15:32:14 UTC 2022


A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ct.996.mcz

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

Name: Collections-ct.996
Author: ct
Time: 25 March 2022, 4:31:59.285695 pm
UUID: 0f9c32cc-b215-d24e-8836-18a71efebc0f
Ancestors: Collections-mt.995

Accelerates Symbol cleanUp/shutDown if there are no new or uncompacted symbols. Treats Collections-ct.995.

To do this, introduce non-thread-safe #condenseNewSymbolsIfNeeded which checks #needsToCondenseNewSymbols first. Also adds HashedCollection>>#isCompact. Documents atomical assignments in #condenseNewSymbols.

Thanks to Levente (ul) for the feedback!

=============== Diff against Collections-mt.995 ===============

Item was added:
+ ----- Method: HashedCollection>>isCompact (in category 'testing') -----
+ isCompact
+ 
+ 	| newArraySize |
+ 	newArraySize := self class sizeFor: self slowSize.
+ 	^ array size = newArraySize!

Item was added:
+ ----- Method: Heap>>isCompact (in category 'growing') -----
+ isCompact
+ 	"Grow to the requested size."
+ 
+ 	| newArraySize |
+ 	newArraySize := self size max: tally.
+ 	^ array size = newArraySize!

Item was changed:
  ----- Method: Symbol class>>cleanUp (in category 'class initialization') -----
  cleanUp
  	"Flush caches"
  
+ 	self condenseNewSymbolsIfNeeded.!
- 	self condenseNewSymbols!

Item was changed:
  ----- Method: Symbol class>>condenseNewSymbols (in category 'private') -----
  condenseNewSymbols
+ 	"Move all symbols from NewSymbols to SymbolTable, and compact SymbolTable. Thread-safe."
- 	"Move all symbols from NewSymbols to SymbolTable, and compact SymbolTable."
  
  	| originalNewSymbols originalSymbolTable newNewSymbols newSymbolTable |
+ 	"both assignments must be done atomically"
  	originalNewSymbols := NewSymbols.
  	originalSymbolTable := SymbolTable.
+ 	
  	newNewSymbols := WeakSet new.
  	newSymbolTable := originalSymbolTable copy
  		addAll: originalNewSymbols;
  		compact;
  		yourself.
  	originalNewSymbols == NewSymbols ifFalse: [
  		"Some other process has modified the symbols. Try again."
  		^self condenseNewSymbols ].
+ 	
+ 	"both assignments must be done atomically"
  	NewSymbols := newNewSymbols.
  	SymbolTable := newSymbolTable!

Item was added:
+ ----- Method: Symbol class>>condenseNewSymbolsIfNeeded (in category 'private') -----
+ condenseNewSymbolsIfNeeded
+ 
+ 	self needsToCondenseNewSymbols ifTrue: [self condenseNewSymbols].!

Item was added:
+ ----- Method: Symbol class>>needsToCondenseNewSymbols (in category 'private') -----
+ needsToCondenseNewSymbols
+ 
+ 	NewSymbols ifNotEmpty: [^ true].
+ 	SymbolTable isCompact ifFalse: [^ true].
+ 	^ false!

Item was changed:
  ----- Method: Symbol class>>shutDown: (in category 'private') -----
  shutDown: aboutToQuit
  
+ 	self condenseNewSymbolsIfNeeded.!
- 	self condenseNewSymbols!



More information about the Squeak-dev mailing list