Skip to content

Drag scroll bar in a medium-sized string is too slow. #34

@tinchodias

Description

@tinchodias

Evaluate this script, then drag the scroll bar a few seconds.

editor := AlbEditorElement new.
editor text: (String loremIpsum: 50000) asRopedText.

vscrollBar := BlVerticalScrollbarElement new.
vscrollBar constraintsDo: [ :c |
	c ignoreByLayout.
	c ignored horizontal alignRight ].
vscrollBar attachTo: editor infinite.

vscrollBar thumb
	addEventHandlerOn: BlDragStartEvent do: [ :evt |
		profiler := AndreasSystemProfiler new.
		profiler startProfiling ];
	addEventHandlerOn: BlDragEndEvent do: [ :evt |
		profiler stopProfiling.
		profiler doReport ].

space := BlSpace new.
space root addChild: editor.
space root addChild: vscrollBar.
space extent: 300@900.
space show.

This shows a profiler report in text, from where I focus on:

[[[                                                  68.4 (3,493)  AlbTextEditorLineSegmentHolder  pieceForElemen...ent:ifAbsent:
[[[                                                    67.4 (3,441)  AlbTextEditorLineSegmentPieceMap  pieceForElemen...ent:ifAbsent:
[[[                                                      56.800000000000004 (2,900)  Dictionary  associations
[[[                                                        |56.800000000000004 (2,900)  Array class  new:streamContents:
[[[                                                        |  43.5 (2,221)  WriteStream class [PositionableStream class]  on:
[[[                                                        |  12.5 (638)  Dictionary  associations
[[[                                                        |    12.4 (633)  Dictionary  associationsDo:
[[[                                                        |      11.8 (603)  Array [SequenceableCollection]  do:
[[[                                                        |        7.800000000000001 (398)  Dictionary  associationsDo:

68% of time is spent searching on the values of dictionaries (i.e. not searching a key, a scenario where Dictionaries perform better... it's searching among the values).

Even worse, all this calculation is part of answering AlbPrimarySelectionElement>>#selectionRectangles. When I logged the result, it was always an empty array!!!

So, 68% of time while dragging the scroll bar it is used in obtaining again and again an empty collection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions