Skip to content
This repository

Long $tables are virtually unscrollable #679

Closed
k7f opened this Issue September 16, 2012 · 11 comments

2 participants

k7f John Benediktsson
k7f

After starting Factor GUI and running this

USING: calendar threads ui ui.baseline-alignment ui.gadgets ui.gadgets.worlds ui.text ui.tools.browser ui.tools.common ;
{ draw-world baseline pref-dim line-metrics } [ add-timing ] each
reset-word-timing "opengl.gl" about
6 seconds sleep
"open browser window:" print word-timing.
[ browser-gadget? ] find-window gadget-child
reset-word-timing dup com-scroll-down
2 seconds sleep
"scroll symbols:" print word-timing.
100 over [ com-scroll-down ] curry times
6 seconds sleep
reset-word-timing com-scroll-down
6 seconds sleep
"scroll words:" print word-timing.
"opengl.gl" words length .

I see this

open browser window:
draw-world   0.13626132
line-metrics 0.598836572
baseline     1.522879476
pref-dim     5.36578886
scroll symbols:
pref-dim     0.002194262
line-metrics 0.003438314
baseline     0.020049122
draw-world   0.046584801
scroll words:
pref-dim     0.233094069
line-metrics 1.389558236
draw-world   5.249826066
baseline     5.803143715
2129

using Ubuntu 12.04

git log -1
commit 3068da5a650191aad38412656977f49961d1a804
Author: John Benediktsson <mrjbq7@gmail.com>
Date:   Thu Aug 30 19:07:47 2012 -0700
John Benediktsson
Collaborator

The scrolling issue could be partly related to #606.

Also, #46 was a patch to speed up tables which are really slow, maybe you can try it and see if it improves anything? There was an open question of whether the relayout-1 calls were necessary.

John Benediktsson
Collaborator

Oh, you're on linux, so #606 wouldn't apply -- but maybe pango has a similar problem.

John Benediktsson
Collaborator

@k7f Thanks for the bug report - I made some fixes for you to try out!

Before 5371a8d, 300ee84, and d9fdd71:

open browser window:
draw-world   0.14332829
line-metrics 0.253642078
baseline     0.726249444
pref-dim     1.545042236
scroll symbols:
line-metrics 0.000704732
pref-dim     0.000815669
baseline     0.005123956
draw-world   0.03872129
scroll words:
pref-dim     0.050892475
line-metrics 0.555686245
draw-world   2.914738721
baseline     3.062785011
2129

After:

open browser window:
draw-world 0.134580678
baseline   0.175653235
pref-dim   0.570823752
scroll symbols:
baseline   0.000171076
pref-dim   0.000747382
draw-world 0.034392106
scroll words:
pref-dim   0.00475159
baseline   0.009911972999999999
draw-world 0.398822959
2129

There looks to be more that could be done pretty easily too...

John Benediktsson
Collaborator

@k7f, since baseline is generic, if you are interested in which generic method is slow, you can do something like this:

\ baseline "methods" word-prop values [ add-timing ] each
k7f

Great! Window with 2k+ lines is scrollable now (still not very smoothly, though). My results are

open browser window:
draw-world   0.105089229
line-metrics 1.434462428
baseline     1.43660762
pref-dim     2.193672441
scroll symbols:
line-metrics 0.000813531
baseline     0.001013101
pref-dim     0.001543765
draw-world   0.043810161
scroll words:
pref-dim     0.016144282
baseline     0.032105187
line-metrics 0.297209981
draw-world   0.959045469

obtained at

commit cb2e128e62d163f5007a534491da28a4fee55521
Author: John Benediktsson <mrjbq7@gmail.com>
Date:   Tue Sep 18 09:19:29 2012 -0700

    Revert "ui.gadgets.labels: use font-metrics directly."

Is the performance boost due mainly to paragraph caching? After git checkout master~5 (plus recompile and bootstrap), i.e. at

commit 300ee8428f8333a75741eab16efdb9d927e290d4
Author: John Benediktsson <mrjbq7@gmail.com>
Date:   Mon Sep 17 14:01:52 2012 -0700

    ui.gadgets.paragraphs: cache the wrapped paragraph for performance.

the results are quite similar:

open browser window:
draw-world   0.103464376
line-metrics 0.714163226
baseline     0.734582137
pref-dim     2.633762572
scroll symbols:
baseline     0.0007479020000000001
line-metrics 0.000833299
pref-dim     0.002176144
draw-world   0.053737593
scroll words:
pref-dim     0.016400483
baseline     0.03081105
line-metrics 0.297524032
draw-world   0.994943037

Running i7 CPU @ 1.60GHz, btw...

John Benediktsson
Collaborator

Try my latest patch (2d736c1).

It should improve things a bit more. The original speedup was mostly caching the result of wrapping the contents of the paragraph. This additional patch should provide for caching the results of a few more calculations that can sometimes be expensive and unnecessary to recalculate frequently.

John Benediktsson
Collaborator

Btw, I've been timing a few more methods to identify slow areas:

USING: calendar threads ui ui.baseline-alignment ui.gadgets ui.gadgets.worlds
ui.text ui.text.private ui.tools.browser ui.tools.common ui.render ;
{
    draw-world draw-gadget add-gadget baseline cap-height
    pref-dim line-metrics string-dim font-metrics
} [ add-timing ] each
{ pref-dim* text-dim layout* } [ "methods" word-prop values [ add-timing ] each ] each
M\ tuple hashcode* add-timing
M\ array hashcode* add-timing
John Benediktsson
Collaborator

I think if we fix #681 it will get a bit faster too.

k7f

Scrolling now feels nice and smooth... The results, too, are much better -- measured at 06d3b18:

open browser window:
line-metrics 0.066484154
baseline     0.131882398
draw-world   0.134676167
pref-dim     2.565550768
scroll symbols:
line-metrics 2.952e-05
baseline     0.00036263
pref-dim     0.001610578
draw-world   0.031340181
scroll words:
pref-dim   0.017410072
baseline   0.026805708
draw-world 0.28277366

although baseline and pref-dim timing was probably too pessimistic, cf #685.

John Benediktsson
Collaborator

Awesome! I'll close this bug for now, then - I love speeding things up if you have any other areas I should look into.

John Benediktsson mrjbq7 closed this September 19, 2012
John Benediktsson
Collaborator

This commit (70484f6) should speed it up a little more too...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.