[Vm-dev] VM Maker: VMMaker.oscog-eem.1291.mcz

commits at source.squeak.org commits at source.squeak.org
Wed May 6 17:44:36 UTC 2015


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1291.mcz

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

Name: VMMaker.oscog-eem.1291
Author: eem
Time: 6 May 2015, 10:41:54.305 am
UUID: 522d9b4a-a938-488b-ae43-6b4ccdd13d5c
Ancestors: VMMaker.oscog-cb.1290

Change computeRefCountToShrinkRT to
- compute the ref counts and population in a single
  pass over the RT
- determine the ref count for tenuring based on
  half the population of remembered objects, /not/
  half the size of the RT.

=============== Diff against VMMaker.oscog-cb.1290 ===============

Item was changed:
  ----- Method: SpurGenerationScavenger>>computeRefCountToShrinkRT (in category 'remembered set') -----
  computeRefCountToShrinkRT
  	"Some time in every scavenger's life there may come a time when someone writes code that stresses
  	 the remembered table.  One might conclude that if the remembered table is full, then the right thing
  	 to do is simply to tenure everything, emptying the remembered table.  Bt in some circumstances this
  	 can be counter-productive, and result in the same situation arising soon after tenuring everything.
  	 Instead, we can try and selectively prune the remembered table, tenuring only those objects that
  	 are referenced by many objects in the remembered table.  That's what this algorithm does.  It
  	 reference counts young objects referenced from the remembered set, and then sets a threshold
  	 used to tenure objects oft referenced from the remembered set, thereby allowing  the remembered
  	 set to shrink, while not tenuring everything.
  
  	 Once in a network monitoring application in a galaxy not dissimilar from the one this code inhabits,
  	 a tree of nodes referring to large integers was in precisely this situation.  The nodes were old, and
  	 the integers were in new space.  Some of the nodes referred to shared numbers, some their own
  	 unique numbers.  The numbers were updated frequently. Were new space simply tenured when the
  	 remembered table was full, the remembered table would soon fill up as new numbers were computed.
  	 Only by selectively pruning the remembered table of nodes that shared data, was a balance achieved
  	 whereby the remembered table population was kept small, and tenuring rates were low."
  	<inline: #never>
+ 	| population |
+ 	<var: 'population' declareC: 'long population[MaxRTRefCount + 1]'>
+ 	self cCode: [self me: population ms: 0 et: (self sizeof: #long) * (MaxRTRefCount + 1)]
+ 		inSmalltalk: [population := CArrayAccessor on: (Array new: MaxRTRefCount + 1 withAll: 0)].
- 	| counts |
- 	<var: 'counts' declareC: 'long counts[MaxRTRefCount + 1]'>
- 	self cCode: '' inSmalltalk: [counts := CArrayAccessor on: (Array new: MaxRTRefCount + 1)].
  	self assert: self allNewSpaceObjectsHaveZeroRTRefCount.
+ 	self referenceCountRememberedReferents: population.
+ 	self setRefCountToShrinkRT: population
+ 
+ 	"For debugging:
+ 	(manager allNewSpaceObjectsDo: [:o| manager rtRefCountOf: o put: 0])"!
- 	self referenceCountRememberedReferents.
- 	self totalRememberedReferentCounts: counts.
- 	self setRefCountToShrinkRT: counts!

Item was removed:
- ----- Method: SpurGenerationScavenger>>referenceCountRememberedReferents (in category 'remembered set') -----
- referenceCountRememberedReferents
- 	"Reference count each referent of the remembered table using the rtRefCount
- 	 field comprised of isGrey,isPinned,isRemembered.  i.e. produce a reference
- 	 count from 1 to 7 in all objects accessible from the RT."
- 	<inline: true>
- 	0 to: rememberedSetSize - 1 do:
- 		[:i| | elephant |
- 		elephant := rememberedSet at: i.
- 		0 to: (manager numPointerSlotsOf: elephant) - 1 do:
- 			[:j| | referent refCount |
- 			referent := manager fetchPointer: j ofObject: elephant.
- 			(manager isReallyYoung: referent) ifTrue:
- 				[refCount := manager rtRefCountOf: referent.
- 				 (refCount := refCount + 1) <= MaxRTRefCount ifTrue:
- 					[manager rtRefCountOf: referent put: refCount]]]]!

Item was added:
+ ----- Method: SpurGenerationScavenger>>referenceCountRememberedReferents: (in category 'remembered set') -----
+ referenceCountRememberedReferents: population
+ 	"Both reference count young objects reachable from the RT,
+ 	 and count the populations of each ref count, in a single pass."
+ 	<var: 'population' declareC: 'long population[MaxRTRefCount + 1]'>
+ 	<inline: true>
+ 	0 to: rememberedSetSize - 1 do:
+ 		[:i| | elephant |
+ 		elephant := rememberedSet at: i.
+ 		0 to: (manager numPointerSlotsOf: elephant) - 1 do:
+ 			[:j| | referent refCount |
+ 			referent := manager fetchPointer: j ofObject: elephant.
+ 			(manager isReallyYoung: referent) ifTrue:
+ 				[refCount := manager rtRefCountOf: referent.
+ 				 refCount < MaxRTRefCount ifTrue:
+ 					[refCount > 0 ifTrue:
+ 						[population at: refCount put: (population at: refCount) - 1].
+ 					 refCount := refCount + 1.
+ 					 manager rtRefCountOf: referent put: refCount.
+ 					 population at: refCount put: (population at: refCount) + 1]]]].!

Item was changed:
  ----- Method: SpurGenerationScavenger>>setRefCountToShrinkRT: (in category 'remembered set') -----
+ setRefCountToShrinkRT: population
+ 	"Choose a refCount that should shrink the rt by at least  half.
+ 	 i.e. find the maximum reference count that half the population have at least."
+ 	<var: 'population' declareC: 'long population[MaxRTRefCount + 1]'>
- setRefCountToShrinkRT: counts
- 	"Choose a refCount that will shrink the rt by at least  half."
- 	<var: 'counts' declareC: 'long counts[MaxRTRefCount + 1]'>
  	<inline: true>
+ 	| entirePopulation i count |
+ 	self assert: (population at: 0) = 0.
+ 	entirePopulation := 0.
+ 	1 to: MaxRTRefCount do:
+ 		[:j| entirePopulation := entirePopulation + (population at: j)].
- 	| i count |
  	count := 0.
  	i := MaxRTRefCount + 1.
+ 	[count < (entirePopulation // 2) and: [(i := i - 1) >= 0]] whileTrue:
+ 		[count := count + (population at: i)].
- 	[count < (rememberedSetSize // 2)  and: [(i := i - 1) >= 0]] whileTrue:
- 		[count := count + (counts at: i)].
  	refCountToShrinkRT := i max: 0!

Item was removed:
- ----- Method: SpurGenerationScavenger>>totalRememberedReferentCounts: (in category 'remembered set') -----
- totalRememberedReferentCounts: counts
- 	<var: 'counts' declareC: 'long counts[MaxRTRefCount + 1]'>
- 	<inline: true>
- 	0 to: MaxRTRefCount do:
- 		[:i| counts at: i put: 0].
- 	0 to: rememberedSetSize - 1 do:
- 		[:i| | elephant |
- 		elephant := rememberedSet at: i.
- 		0 to: (manager numPointerSlotsOf: elephant) - 1 do:
- 			[:j| | referent refCount |
- 			referent := manager fetchPointer: j ofObject: elephant.
- 			(manager isReallyYoung: referent) ifTrue:
- 				[refCount := manager rtRefCountOf: referent.
- 				 counts at: refCount put: (counts at: refCount) + 1]]]!



More information about the Vm-dev mailing list