Call for attention - context handlers and validation procs

Call for attention - context handlers and validation procs

Postby thomthom » Mon Oct 18, 2010 7:43 pm

I hope the various scripters here can take a moment and look into this.

While working on a large siteplan where I had ~200-300K edges I noticed that when I had selected everything and right-clicked SU would freeze up for several seconds before poping up the window. Often the SU window would flicker as it returned to a responsive state and cause the right click menu to disappear.

I tried with all plugins disabled and found that there was then no lag at all.

It occurred to me that some plugins might be trying to process the whole selection in the context handler. Checking my own plugin I found Selection Toys to do so - which of course is a naught thing to do. I modified it so it'd only inspect the selection if the selection was less than 1000 entities. When the selection is over 1000 it makes the assumption that the selection can contain anything and display all menus.

That cut down the lag a little, but there's still many seconds lag. So there is more plugins. Initial scan of my plugins I found no more, so now I ask the rest of you to review your context menu handlers.

And I expect one should be just as careful when it comes to validation procs. (I'm a wee bit unsure to exactly when these triggers - as toolbar buttons also can have these.)

Summary:
Don't process the whole selection in context handlers or validation procs. Place size limitations or remove the validation all together.

Test the right click menu and it's performance on large models with large selections when adding context handlers.




Debug Script for Benchmarking

#tt_context_handler.rb

Open the Ruby Console, when right-clicking performance data will be outputted.

To list all attached handlers:
TT.list_context_handlers
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby tbd » Tue Oct 19, 2010 3:38 am

maybe we should create a checklist for releasing ruby scripts, something like http://lite.launchlist.net
0
SketchUp Ruby Consultant | Podium 1.x developer
http://plugins.ro
User avatar
tbd 
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Tue Oct 19, 2010 7:27 am

I think that would be a good idea. :thumb:
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby AdamB » Tue Oct 19, 2010 6:08 pm

I'm half finished with a plugin called "Snitch" which collates the time each plugin's Observers take so we can start pointing fingers.

Guidelines are fine, but witchhunts / naming and shaming has much better results. :-)
0
Developer of LightUp Click for website
User avatar
AdamB 
LightUp Support
LightUp Support
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Tue Oct 19, 2010 6:40 pm

How do you manage to track other observers?
Can it be translated into validation procs and context handlers?
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby Chris Fullmer » Tue Oct 19, 2010 8:46 pm

AdamB wrote:Guidelines are fine, but witchhunts / naming and shaming has much better results. :-)



Woohoo!, let the games begin. I have a feeling I'm gonna score big!!!! (I hope its good to score big :mrgreen: )
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Tue Oct 19, 2010 8:50 pm

0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby honoluludesktop » Tue Oct 19, 2010 9:01 pm

Are the witches hunting, or are we hunting witches?-)

Don't know what the following has to do with this topic, but it seemed like the thing to do:-)

0
Last edited by honoluludesktop on Tue Oct 19, 2010 9:05 pm, edited 1 time in total.
User avatar
honoluludesktop 
In Remembrance
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Tue Oct 19, 2010 9:03 pm

uh... both maybe :D

0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby honoluludesktop » Tue Oct 19, 2010 9:14 pm

That's rich! The opening scene strikes a cord, it's me writing an app:-)

temp00.jpg
0
User avatar
honoluludesktop 
In Remembrance
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Thu Oct 28, 2010 1:39 pm

I made a little sniffer script that will log the scripts that creates context handlers. Lets one easier inspect which scripts are adding context handlers.

I found xLine to be processing the whole selection. I'll be looking further into what scripts have inefficient context handlers. At the moment it takes many seconds for me when I right click a large set of selected entities.

(Removed - See first post)

Type TT.list_context_handlers to get a list of attached context handlers in the Ruby Console.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Fri Oct 29, 2010 11:24 am

I just updated the first post with the debug script - it now benchmarks the handlers, outputting the time they take to process to the Ruby Console.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Fri Oct 29, 2010 11:28 am

Sample output for a selection of about 100K entities:

### Context Handler ###
2D#loader.rb:181:in `activate' [...] 2D#.rb:44
0.0 seconds

### Context Handler ###
bezier.rb:501 [...] bezier.rb:501
0.006 seconds

### Context Handler ###
parametric.rb:320 [...] (eval):2696
0.0 seconds

### Context Handler ###
(eval):103:in `load' [...] pb_loader.rb:9
0.0 seconds

### Context Handler ###
tt_bitmap2mesh.rb:29 [...] tt_proxy_loader.rb:28
0.0 seconds

### Context Handler ###
tt_image_opacity.rb:30 [...] tt_proxy_loader.rb:28
0.0 seconds

### Context Handler ###
ui_manager.rb:261:in `build_ui' [...] tt_selection_toys.rb:240
0.004 seconds

### Context Handler ###
xLine.rb:51 [...] xLine.rb:51
0.0 seconds

### Context Handler ###
Lib6Plugin.rb:656:in `build_config_handlers' [...] ZLoader__FredoScale.rb:24
0.0 seconds

### Context Handler ###
Lib6Plugin.rb:656:in `build_config_handlers' [...] ZLoader__OnSurface.rb:26
0.489 seconds

### Context Handler ###
(eval):299:in `initialize' [...] dynamiccomponents.rb:38
0.0 seconds

### Context Handler ###
webtextures_loader.rb:886 [...] webtextures.rb:22
0.0 seconds

### Context Handler ###
bezierspline_main.rb:2413:in `load_all_menus' [...] extensions.rb:36:in `load'
5.657 seconds


(Note I had modified xLine and Selection Toys prior to this test)
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby fredo6 » Sun Nov 07, 2010 8:16 am

thomthom wrote:Sample output for a selection of about 100K entities:

### Context Handler ###
bezierspline_main.rb:2413:in `load_all_menus' [...] extensions.rb:36:in `load'
5.657 seconds[/ruby]

I fixed the one for BezierSpline, with an upgrade.
see http://forums.sketchucation.com/viewtopic.php?f=323&t=13563&p=100509#p100509

Fredo
0
User avatar
fredo6 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Sun Nov 07, 2010 11:07 am

:thumb:
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby Pout » Wed Nov 10, 2010 3:02 pm

Reminds me of something simular I seem to have in big models when rightclicking a material.
The rightclick window just doesn't pop-up
0

Pout 
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Wed Nov 10, 2010 3:31 pm

Pout wrote:Reminds me of something simular I seem to have in big models when rightclicking a material.
The rightclick window just doesn't pop-up

Yea - I've noticed that too. Very annoying. But that menu isn't accessible to ruby plugins. So I think that one is on Google's shoulders.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby Jim » Sun Jan 23, 2011 5:25 pm

Fredo6 wrote:
thomthom wrote:Sample output for a selection of about 100K entities:

### Context Handler ###
bezierspline_main.rb:2413:in `load_all_menus' [...] extensions.rb:36:in `load'
5.657 seconds[/ruby]

I fixed the one for BezierSpline, with an upgrade.
see http://forums.sketchucation.com/viewtopic.php?f=323&t=13563&p=100509#p100509

Fredo


Bezierspline_main is still sort-of slow for me - it takes 8 seconds for the context menu to pop-up for 75,000 selected entities. (I admit to having a sub-standard pc.)
0
Hi

Jim 
Global Moderator
 

Re: Call for attention - context handlers and validation pro

Postby fredo6 » Sun Jan 23, 2011 10:19 pm

Jim wrote:Bezierspline_main is still sort-of slow for me - it takes 8 seconds for the context menu to pop-up for 75,000 selected entities. (I admit to having a sub-standard pc.)

Jim,

I made a change in the script.
see main post on BezierSpline

Is is better with this release

Thanks

Fredo
0
User avatar
fredo6 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Sun Jan 23, 2011 10:24 pm

:thumb:
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby mitcorb » Sun Jan 23, 2011 10:43 pm

Are you saying that each and every plugin is "polled" each time you wish to do something whether you "invoke" that/those plugins or not? If so, is that efficient? Keep in mind I don't know the terminology, and I certainly don't fully understand.
0
I take the slow, deliberate approach in my aimless wandering.
User avatar
mitcorb 
Top SketchUcator
 

Re: Call for attention - context handlers and validation pro

Postby thomthom » Sun Jan 23, 2011 10:56 pm

mitcorb wrote:Are you saying that each and every plugin is "polled" each time you wish to do something whether you "invoke" that/those plugins or not? If so, is that efficient? Keep in mind I don't know the terminology, and I certainly don't fully understand.

Not every plugin, but when a plugin want to add a context menu a function is run - and if the plugin tried to evaluate the whole selection or do any processor expensive calculations in this function it'll delay the context menu.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Call for attention - context handlers and validation pro

Postby mitcorb » Mon Jan 24, 2011 4:50 am

Ok, that makes some sense, thanks. Evidently, the context menu is lower in priority?
0
I take the slow, deliberate approach in my aimless wandering.
User avatar
mitcorb 
Top SketchUcator
 

Re: Call for attention - context handlers and validation pro

Postby Dan Rathbun » Mon Jan 24, 2011 6:41 am

not really... the context menu is "built on the fly"...

The menu needs to know what items and submenus it will need to display. It cannot know what they will be until Sketchup processes all the context_menu_handlers.
0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    SketchUcation One-Liner Adverts

    by Ad Machine » 5 minutes ago



    Ad Machine 
    Robot
     



     

    Return to Developers' Forum

    Who is online

    Users browsing this forum: No registered users and 7 guests

    Visit our sponsors: