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

[Regression, View] 2x slower face construction than before #4554

Closed
hiiamboris opened this issue Jun 27, 2020 · 6 comments
Closed

[Regression, View] 2x slower face construction than before #4554

hiiamboris opened this issue Jun 27, 2020 · 6 comments
Assignees
Labels
GUI status.built A change in codebase has been done to address the ticket. type.bug Ticket describes an abnormal behavior, not conforming to the specs or expectation.

Comments

@hiiamboris
Copy link
Collaborator

Describe the bug

Happened between May 21st and May 27th, 2020. Didn't bisect more precisely.

Here's the script:

Red [needs: view]
do https://gitlab.com/hiiamboris/red-mezz-warehouse/-/raw/master/clock.red
recycle/off
clock [
	v: view/no-wait []
	probe stats
	print "creating faces"
	loop 500 [append v/pane make face! [type: 'text offset: 0x0 size: 10x10]]
	print "flushing events"
	loop 5000 [do-events/no-wait]
	probe stats
	print "closing the window"
	unview v
]

Results on build red-21may20-398d73317:

2388216                                                                       
creating faces                                                                
flushing events                                                               
11015572                                                                      
closing the window                                                            
8463 ms [v: view/no-wait [] probe stats print "creating faces" loop 500 [appen

Results on build red-27may20-cfb6d303f and all the later ones:

2265572                                                                               
creating faces                                                                        
flushing events                                                                       
13198928                                                                              
closing the window                                                                    
16222 ms        [v: view/no-wait [] probe stats print "creating faces" loop 500 [appen

200% slowdown, 32ms per single face!


Now the similar thing but with faces not really rendered (size: 0x0):

Red [needs: view]
do https://gitlab.com/hiiamboris/red-mezz-warehouse/-/raw/master/clock.red
recycle/off
clock [
	v: view/no-wait []
	probe stats
	print "creating faces"
	loop 500 [append v/pane make face! [type: 'text offset: 0x0 size: 0x0]]
	print "flushing events"
	loop 5000 [do-events/no-wait]
	probe stats
	print "closing the window"
	unview v
]

Results on build red-21may20-398d73317:

2387116                                                                       
creating faces                                                                
flushing events                                                               
11014472                                                                      
closing the window                                                            
1338 ms [v: view/no-wait [] probe stats print "creating faces" loop 500 [appen

Results on build red-27may20-cfb6d303f and all the later ones:

2274928                                                                       
creating faces                                                                
flushing events                                                               
13208516                                                                      
closing the window                                                            
2143 ms [v: view/no-wait [] probe stats print "creating faces" loop 500 [appen

160% slowdown, 4.3ms per face.

Expected behavior

Let's get the old timings back.

Platform version (please complete the following information)

Red 0.6.4 for Windows built 20-Jun-2020/20:24:25+03:00 commit #4d864b1
still just as slow, W7
@qtxie qtxie self-assigned this Jun 28, 2020
@qtxie
Copy link
Contributor

qtxie commented Jun 28, 2020

Happened just after fast-lexer branch merged into master.

@qtxie
Copy link
Contributor

qtxie commented Jun 28, 2020

Using a separate block fix it. So something wrong happened in on-deep-change* function or ownership system (lookup become slower?).

do https://gitlab.com/hiiamboris/red-mezz-warehouse/-/raw/master/clock.red
recycle/off
;system/view/auto-sync?: no
b: make block! 550
clock [
	v: view/no-wait []
	probe stats
	print "creating faces"
	loop 500 [append b make face! [type: 'text offset: 0x0 size: 0x0]]
	v/pane: b
	print "flushing events"
	loop 5000 [do-events/no-wait]
	probe stats
	print "closing the window"
	unview v
]

@qtxie qtxie added GUI status.built A change in codebase has been done to address the ticket. type.bug Ticket describes an abnormal behavior, not conforming to the specs or expectation. labels Jun 28, 2020
@hiiamboris
Copy link
Collaborator Author

A separate block triggers a single on-change of pane, while adding one by one is 500 on-deep-change events.

Regarding line 273, it was there for 4 years so I guess it's not the primary bug cause...

@qtxie
Copy link
Contributor

qtxie commented Jun 28, 2020

The cause is that after a series of changes those years, update-z-order get called unexpected each append happened.
There is another way to fix it, but I don't see the need of line 273 anymore. If there is a good reason to keep this line, I'll change the fix.

@hiiamboris
Copy link
Collaborator Author

745 ms [v: view/no-wait [] probe stats print "creating faces" loop 500 [appen
Fantastic. You made it 20 times faster ;)

@greggirwin
Copy link
Contributor

Woohoo! I love this kind of fix. Here the closing time went from 23'848ms to 1687 ms.

Thanks to both of you for finding and digging into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI status.built A change in codebase has been done to address the ticket. type.bug Ticket describes an abnormal behavior, not conforming to the specs or expectation.
Projects
None yet
Development

No branches or pull requests

3 participants