Friday, January 25, 2008

Eclipse Jobs API and Pydev Optimizations

1st thing to learn: Don't use UIJobs unless it's imperative that you have access to the UI... From 1.3.9 to 1.3.10 I was doing some refactorings to use the Eclipse Jobs API instead of raw Threads...

After taking a look at the core options (Job, UIJob and WorkbenchJob), the WorkbenchJob was chosen, as things shouldn't run if the workbench was shutting down (the docs say that it'll do checks to see if the Workbench is running, before actually running the Job -- as the Job in case: code-analysis is not suitable to run at shutdown, it seemed a nice choice)

But the thing is that the workbench job ends up running in the UI Thread -- and thus gives a little halt to the user every time the job runs... (and only after going after it in a bug report I found out about it).

On the good side, I took some more time to profile the code-analysis / code-completion (mainly when interacting with large files) and was able to make some nice improvements that will surely be noticeable... even on smaller cases:

- a cache that works for the duration of a type-analysis request to hold non-direct tokens available at a module was added
- a cache to hold scope information within a module was also created...

In my tests it gave a 40x improvement on a type-analysis request, as many traverses of the ASTs are not needed anymore with those caches (those will have a higher impact when a given module is imported a lot from different places).

All in all, optimizing Pydev is becoming more and more challenging :)

p.s.: Those improvements will be available on Pydev 1.3.12 (which hopefully will be released in the beginning of the next week).

No comments: