How do I save document not in EDT

I want to save document not in EDT because it makes IntellIj slow. I want to save file in background because it only has to read document. I'm using ExternalAnnotator and after modifications in InttellIJ I have to save file so compiler can compile file with latest changes. I'm using ExternalAnnotator

Btw, I noticed much difference in performance between Ubuntu and MacOSX. MacOSX is much faster so while typing I do not notice that cursor is lagging behind..

Help is much appreciated because I already spent a lot of time to try to solve this issue.

Thanks,

Rik

 

6 comments
Official comment

VFS changes (including saving documents) are currently allowed only from EDT. But usually this doesn't cause much trouble, because saving is usually very fast. I'd suggest to investigate why it's slow for you, with a profiler or thread dumps. How much time does it take?

Hi Peter,

Thanks for replying fast!

It's normally between 0 and 20 millis One time I noticed big variation in saving time, almost 300 millis. 

But I think the cause is the LocalInspectionTool. Probably that one is running in the background on the EDT. I notice big improvement in responsiveness when I  disable local inspection tool (powered by Hlint :-) )

For some reason I was misled.

Can you give me some hint how to improve this? 

 

 

 

0

I can run Hlint with executeOnPooledThread but still have to wait. Also doing the "PSI-work" within runReadAction seems to help but I like to see it faster.

Btw, I still see sometimes save times of around 300 millis.

0

Do you advice this to use for saving document?

"scheduleWithWriteActionPriority(@NotNull final ProgressIndicator progressIndicator,
@NotNull final Executor executor,
@NotNull final ReadTask readTask)"


0

You just can't save a document from non-EDT, you'll get an exception logged.

The freeze might be caused not by saving, but by unresponsive inspection that doesn't call checkCanceled regularly while holding read lock, so that write action(Save) has to wait on EDT for that lock to be freed. Please consider profiling this. You can also add the following to vmoptions (then a thread dump will be generated in system/log after 200ms of waiting for the lock):

-Ddump.threads.on.long.write.action.waiting=200
1

Hi Peter,

Many thanks!!

Cheers,

Rik

0

Please sign in to leave a comment.