Better support for read operations on out-of-date resources
Closed this issue · 3 comments
We have a project with a custom builder (Xtext based) that has many many files (10k-100k range)
reading this files in the builder thread is quite slow (io bottleneck)
if the file is in sync, then reading on other threads work fine
thus we currently use this pattern
reader thread: if (file.isSychronized) readFile, put result to queue, else put "cannot read result" to queue.
workspace lock holding thread: pull from queue, if "cannot read result", refresh and read here.
this works fine most of the time
but if the file gets modified exaclty between the
file.isSychronized call and the read file call
the reader thread will block until the build is does.
we bypass this by on the builder thread poll the queue with timeout, and if there is a timeout, we will stop.
thus the block gets resolved
it would be nice if there were better ways of achieving this, e.g.
having a file.getContentsWorkspaceLockSafe, that will return null or throw an exception, so that we can work with that.
Would be nice to see thread stack from the "reader" thread that tries to read not-in-sync file, at the moment where it blocks. You can omit product specific part, just platform ome is interesting. May be small snippet from related reader thread code would be also good, doesn't need to be compilable, just to see which API and locks etc are used.
And for the API needed please provide at least full signature with the contract defined, otherwise it is hard to understand what exactly the requirements here.
need to further investigate, could be an emf problem
update: it is
Isn't there a flag to refresh outdated resources when you read them?