[squeak-dev] The Inbox: Traits-pre.312.mcz

patrick.rein at hpi.uni-potsdam.de patrick.rein at hpi.uni-potsdam.de
Thu Jun 13 19:36:06 UTC 2019

There might be a couple more of this as I saw some symptoms of this during debugging the other performance issue. My approach was quite primitve logging with the Transcript by instrumenting CurrentReadOnlySourceFIles like so:

cacheDuring: aBlock
	"Cache the read only source files on the first request and use them on subsequent requests during the evaluation of aBlock."
	| currentReadOnlySouceFiles |
	currentReadOnlySouceFiles := nil.
		on: self
		do: [ :exception |
+			Transcript showln: 'cached'.
			exception resume: (currentReadOnlySouceFiles ifNil: [
				currentReadOnlySouceFiles := exception defaultAction ]) ]
	"Return a read-only copy of SourceFiles."
+	Transcript showln: 'create new'.

	^SourceFiles collect: [ :each |
		each ifNotNil: [
			[ each readOnlyCopy ]
				on: FileDoesNotExistException
				do: [ :ex | nil "file does not exist happens in secure mode" ] ] ]
And then digging deeper using the Profiler. However, this only became necessary as the editing of Traits and the TraitsTest became unbearingly slow at one point. (The main issue is currently categorizing the trait methods, not the compilation itself).


>Hi, there.
>Thanks for finding this! +1
>Are there more places where CurrentReadOnlySourceFiles >> #cacheDuring: should be used? How to find out?
>Am 12.06.2019 17:59:59 schrieb commits at source.squeak.org <commits at source.squeak.org>:Patrick Rein uploaded a new version of Traits to project The Inbox:
>==================== Summary ====================
>Name: Traits-pre.312
>Author: pre
>Time: 12 June 2019, 5:59:48.264868 pm
>UUID: f2ec63fa-f6e8-0347-a2c6-fb8623cb4a92
>Ancestors: Traits-nice.311
>This speeds up the compilation of methods in traits or in classes using traits by caching subsequent reads to the changes file.
>=============== Diff against Traits-nice.311 ===============
>Item was changed:
>----- Method: ClassDescription>>updateTraits (in category '*Traits-NanoKernel') -----
>"Recompute my local traits composition"
>+ CurrentReadOnlySourceFiles cacheDuring: [
>+ self installTraitsFrom: self traitComposition]!
>- self installTraitsFrom: self traitComposition.
>- !
>Item was changed:
>----- Method: TraitDescription>>addSelectorSilently:withMethod: (in category 'operations') -----
>addSelectorSilently: selector withMethod: compiledMethod
>"Overridden to update the users of this trait"
>+ CurrentReadOnlySourceFiles cacheDuring: [
>+ super addSelectorSilently: selector withMethod: compiledMethod.
>+ self users do:[:each| each updateTraits]]!
>- super addSelectorSilently: selector withMethod: compiledMethod.
>- self users do:[:each| each updateTraits].!

More information about the Squeak-dev mailing list