Performance of PSI write-operations

Hi,

it seems that PSI write-operations are/have become painfully slow. I'm currently using
IDEA to do some automated processing of java source code. The modifications are done to
javadoc comments by replace()-ing them with newly created ones. The target classes have
about 300-1200 lines and about 30-90 methods that are to be processed. For the larger
classes it takes about 10-14 seconds to process all methods and their comments which seems
too much for such relatively simple operations.

I've also seen reports* of basic IDEA actions being slow, so this seems to be a general
problem. Is there any way to enhance the performance of such operations?

TIA,
Sascha

4 comments
Comment actions Permalink

Sascha Weinreuter wrote:

it seems that PSI write-operations are/have become painfully slow. I'm currently using
IDEA to do some automated processing of java source code. The modifications are done to
javadoc comments by replace()-ing them with newly created ones. The target classes have
about 300-1200 lines and about 30-90 methods that are to be processed. For the larger
classes it takes about 10-14 seconds to process all methods and their comments which seems
too much for such relatively simple operations.


Just a generic question (I don't know much about PSI/Open API): Have you
done a quick check of # of methods vs. elapsed time for each class?
10-14 seconds just sounds way too high, so I suspect if you graph the
times in relation to # of methods, you'll get an O(n^2) or worse
performance graph. If that is indeed the case, it may be possible to
reorganize the algorithm so it's O(n) instead. Just a thought.

--
Rob Harwood
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

This is due to slow formatter performance.
We are aware of this problem, and will fix it ASAP.
Eugene.

"Sascha Weinreuter" <sascha.weinreuter@NOSPAM-cit.de> wrote in message
news:d7kn26$nkv$1@is.intellij.net...

Hi,

>

it seems that PSI write-operations are/have become painfully slow. I'm

currently using

IDEA to do some automated processing of java source code. The

modifications are done to

javadoc comments by replace()-ing them with newly created ones. The target

classes have

about 300-1200 lines and about 30-90 methods that are to be processed. For

the larger

classes it takes about 10-14 seconds to process all methods and their

comments which seems

too much for such relatively simple operations.

>

I've also seen reports* of basic IDEA actions being slow, so this seems to

be a general

problem. Is there any way to enhance the performance of such operations?

>

TIA,
Sascha

>



0
Comment actions Permalink

The 10-14 seconds for the largest classes are just the time it takes for the PSI-
modification, i.e. the creation of a new comment object, replacing the old one and
reformatting it. The time for the replace() and reformat() calls seem to heavily depend on
how much text there is in the comment to be replaced, not the number of methods. The time
per method is nearly constant.

That matches with Eugene's info about the formatter being a possible source of the
slowness. I guess I have to live with that for now, but since what I'm doing is a one-time
thing, that's not a big problem.

Sascha

0
Comment actions Permalink

Eugene Vigdorchik (JetBrains) wrote:

This is due to slow formatter performance.
We are aware of this problem, and will fix it ASAP.
Eugene.


Ah, thanks for the info. Now that you say it, I remember that once Maxim mentioned that
the formatter had some performance problems. I just thought that there might be a way to
speed up such bulk-operations in some way, like deferring the formatting until all changes
have been made. Something like that...

If you're interested in a CPU snapshot I can see if I can get one.

Sascha

0

Please sign in to leave a comment.