When typing something in a SpoofaxLang editor, it seems background jobs get queued really fast. Sometimes a lot faster than the speed at which they are processed.

The effect is that sometimes after doing a bunch of editing, you have to wait a long time for all pending background jobs to get processed, before you can do a compile. (Or you can restart Eclipse as a workaround :-))

Might be nice if there is some limit on the queue size, though maybe this bug will be obsoleted by other index work.

Submitted by Tobi Vollebregt on 7 March 2012 at 15:54

On 7 March 2012 at 15:55 Tobi Vollebregt tagged spoofaxlang

On 7 March 2012 at 18:18 Adil Akhter tagged runtime

On 9 March 2012 at 12:18 Lennart Kats commented:

This is likely interaction with the new file system notifications: Spoofax/224. Since SpoofaxLang currently has its own file system notification, maybe FileNotificationServer should ignore .spx files?

On 9 March 2012 at 12:19 Lennart Kats tagged @adil

On 11 March 2012 at 17:31 Tobi Vollebregt commented:

No, I watched it a bit closer, and the job spam happens in particular when SpoofaxLang is generating files. So .spx need not be ignored, but everything in .shadowdir needs to be ignored. (Or whichever dir is configured in spx.config as target for code generation, or maybe in all hidden directories?)

On 11 March 2012 at 17:36 Lennart Kats commented:

But .shadowdir should already be ignored in the FileNotificationServer class. Plus it would only trigger if Eclipse actually manually or automatically gets a refresh event.

On 11 March 2012 at 17:55 Tobi Vollebregt commented:

Hmm, yeah, I just noticed that.

Nevertheless I doubt the number of threads rising rapidly while generating code is accidental :-)
Also there happen to be ~750 threads created when generating ~750 files in .shadowdir. (even needed to lower stack size to get this far ;-))

When putting a breakpoint in FileNotificationServer, I see that isIgnoredChange is invoked, and returns true for the files in .shadowdir.

Plus it would only trigger if Eclipse actually manually or automatically gets a refresh event.

Hmm, so that may happen for me cause I always set ‘Refresh using native hooks or polling’ and ‘Refresh on access’ on in the Eclipse workspace settings. I’ll experiment a little with those settings later on.

Also, I think I may be talking about a different issue now, than the one I originally posted.
In particular the issue is now that n threads seem to be spawned when n files are generated, which tends to cause OOM errors etc.

On 12 March 2012 at 11:06 Tobi Vollebregt commented:

The background job / worker thread spam is solved, now that Adil changed the code generator to not invoke SSL_EXT_refreshresource for every generated file.

Unfortunately I think this was a separate issue than what I originally posted, so I’ll leave this open for now.

On 12 March 2012 at 12:34 Adil Akhter commented:

Great that the background job/worker thread spam is now fixed! Now, the .shadowdir is refreshed just once in every build. Hence, SSL_EXT_refreshresource is invoked once in every build.

On 12 March 2012 at 13:01 Adil Akhter commented:

Regarding the open issue: the trunk version of SpoofaxLang does not have an additional file event listener. Therefore, it seems to be same issue related to editor-analyze of spoofax-based language editor : every key stroke is initiating a new analysis.

In case of SpoofaxLang, it is performing just one additional step. It is setting error/warning markers for the packages that are dependent on the current package. However, it seems like SSL_EXT_set_markers is not spawning a new background job/thread for that.

I will investigate further to see why it is creating many background jobs.

On 12 March 2012 at 15:39 Tobi Vollebregt commented:

Indeed, in the open issue, there are many analysis jobs queued, but the worker threads are managed well: there is no thread spam. The jobs are really only queued, and it takes a while for the single (?) worker to go through them all.

This is particularly frustrating as Eclipse locks up (not the UI thread, but nearly everything else) from the moment you save the file you are working on, until the moment all queued jobs are finished.

At the moment I suspect this is a runtime issue, and not really specific to SpoofaxLang (except that SpoofaxLang analysis jobs take relatively much time). That is:

  • Analysis jobs may be queued a bit too often
  • Maybe pending analysis jobs should be cancelled as soon as a new analysis job for the same file is added to the queue. That way, there can be at most two jobs for the same file in the queue: one currently running analysis, and one queued analysis.

This hypothesis is supported by the fact that if I put a breakpoint in StrategoAnalysisQueue and inspect the queue after I’ve typed a bit in some file, then the queue easily contains 100s of StrategoAnalysisQueue$UpdateJobs for the same .spx file.

On 13 March 2012 at 10:48 Lennart Kats tagged !nathanbruning

On 13 March 2012 at 10:48 Lennart Kats commented:

IIRC Nathan said that the queue avoids duplicate jobs like that. But it might depend on what kind of job is queued.

On 13 March 2012 at 10:57 Tobi Vollebregt commented:

Yeah, I recall from reading the code some months back that only manually queued jobs (using queue-analysis) are ignored if a job for the same file is already present. But automatically queued analysis jobs can have duplicates.

On 13 March 2012 at 10:57 Gabriël Konat commented:

Background analyses avoid duplicate jobs, only one analysis can be active per path.

On 13 March 2012 at 11:33 Adil Akhter commented:


Apparently, editor-analyze invokes StrategoAnalysisQueue.queue(StrategoObserver observer, IParseController parseController, long delay). Unlike StrategoAnalysisQueue.queueAnalysis, it does not verify if an update job is already pending with the path.

On 8 January 2013 at 14:39 Eelco Visser tagged wontfix

On 8 January 2013 at 14:40 Eelco Visser closed this issue.

Log in to post comments