Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slowdown caused by dirty rectangles and explicitRequirements #608

Open
akevalion opened this issue Jan 5, 2024 · 0 comments
Open

Slowdown caused by dirty rectangles and explicitRequirements #608

akevalion opened this issue Jan 5, 2024 · 0 comments

Comments

@akevalion
Copy link
Contributor

There is a significant slowdown between between first and last commits in this new repo that seems to be caused by a combination of dirty rectangles and using explicitRequirements.

The slowdown is quite situational, but causes dragging elements in larger OpenPonk diagrams to degrade from quite fluent high-FPS experience to something hitting 1-3 FPS.

It is most noticable when dragging elements manually. Use RSRenderTreeExamples new example01BigVisualization131k
and try to drag a single element around. In current master (or 3a0cdc0) it is quite sluggish while in b508334 with all methods with explicitRequirements removed, it is completely fluent.

To have some automatically executed example, I created 2 examples and created 4 images based on Pharo 11.

  • Image "dirty-explicit" with commit 3a0cdc0 (after dirty rectangles) without any changes.
  • Image "dirty-cleared" with commit 3a0cdc0 with all methods with explicitRequirements removed.
  • Image "older-explicit" with commit b508334 (before dirty rectangles) without any changes.
  • Image "older-cleared" with commit b508334 with all methods with explicitRequirements removed.

These are the two examples:

Boxes example:

|canvas boxes lines|
canvas := RSCanvas new.
boxes := (1 to: 5000) collect: [:i | RSBox new translateBy: i @ i; yourself ].
canvas addAll: boxes.
canvas open.

Smalltalk garbageCollect.

[ 
  40 timesRepeat: [boxes do: [ :each | each translateBy: 1@1 ]. ]
] timeToRunWithoutGC

Lines example:

|canvas boxes lines|
canvas := RSCanvas new.
boxes := (1 to: 100) collect: [ :i | RSBox new ].
canvas addAll: boxes.
(1 to: 100) do: [ :i | 
	(i to: 100) do: [ :j | 
		canvas add: (RSArrowedLine new from: (boxes at: i); to: (boxes at: j); withBorderAttachPoint; yourself).
		canvas add: (RSArrowedLine new from: (boxes at: j); to: (boxes at: i); withBorderAttachPoint; yourself).
	 ]
].
canvas open.

Smalltalk garbageCollect.

[ boxes do: [ :each | each translateBy: 1@1 ] ] timeToRunWithoutGC

Boxes example:

  • "dirty-explicit": 1573 ms
  • "dirty-cleared": 570 ms
  • "older-explicit": 35 ms
  • "older-cleared": 34 ms

Lines example:

  • "dirty-explicit": 1605 ms
  • "dirty-cleared": 1256 ms
  • "older-explicit": 1099 ms
  • "older-cleared": 962 ms

Code that removes those explicitRequirements:

#( Roassal Numeric RTree ) do: [ :aPackageName |
	| regExp packages |
	regExp := '*' , aPackageName , '*'.
	packages := RPackageOrganizer default packages select: [ :each |
		            regExp match: each name ].
	packages do: [ :each |
		Transcript crShow:
			'Removing explicitRequirements from package ' , each name.
		each classes select: #isTrait thenDo: [ :eachClass |
			eachClass methods
				select: [ :eachMethod |
					eachMethod sourceCode includesSubstring:
						'self explicitRequirement' ]
				thenDo: #removeFromSystem ] ] ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant