Repository navigation
multiprocess_safe_cache - #4404
Conversation
…loses emscripten-core#3850. Also fix an issue from earlier commit where at least on Windows, calling pool.terminate / pool.join might not succeed, but instead throws an "Access is denied" exception.
…delete the cache lock file, in the case that a previous forcibly killed process had left it lying around.
| self.dirname = dirname | ||
| self.debug = debug | ||
|
|
||
| def reverse_chop(thestring, ending): |
There was a problem hiding this comment.
the name seems surprising? perhaps "try_remove_ending"?
There was a problem hiding this comment.
Ok, that's a good name.
|
Do all tests (including and especially We should also add a test for this, in Could we show a warning to the console when blocking on the lock, so that if a problem happens and the locker is stuck or slow, the user knows what's going on? Or maybe the stack trace from control-c would be enough, if there is something useful on the stack. |
|
Seeing some issues in sanity (#4416), but not related to this pull request. Working on the test. |
…ipten process invokes Emscripten again as a child process, and the parent has the lock, but child also tries to acquire it.
…iprocess lock works properly.
|
Added a warning print if accessing the lock takes more than 60 seconds. Also added a test |
|
60 seconds seems like a lot. I think people would assume it hangs and kill it much sooner. However, in EMCC_DEBUG mode we'd have logging shown, if I read this PR right? So I guess that's ok. But it seems dangerous to wait 60 seconds and stop. How about after 60 seconds we show a warning (not just in debug output), and continue waiting? So if it frees up later it still works. But the user has an error message telling them why the delay, and maybe also saying how to manually kill the lock if necessary. |
|
In debug mode there is a print before attempting to take the lock. The warning is printed after having waited for 60 seconds, but the code doesn't stop at the 60 seconds mark, but keeps waiting by re-attempting to take the lock without any timeout set (line 46, The trouble with choosing a timeout is that building libc and/or any other thing to the cache can easily take more than 60 seconds on a slower computer or a VM, so anything smaller at least doesn't sound safe. Also, this lock will not change performance or throughput in any way, so with respect to the performance/timing characteristics the behavior should be identical. The only thing this will delay is the 2nd and subsequent processes will not start each to stomp on building libc and other things to the same cache at the same time. The only thing that I could think of where performance can get degraded is if two independent Emscripten processes wanted to build two completely different things to the cache, say e.g. build 1 wanted to build SDL2, and build 2 wanted to build freetype, although I expect such circumstances would be extremely rare. |
|
Ok, sounds good. My last concern is the question in the other thread, why we need to catch new windows errors now. |
|
Thanks, merging. I'm hopeful that Windows would go green on the default run mode after this. |
|
Great. Btw, maybe worth posting to the mailing list to ask for people to test this? |
|
Good idea, let me advertise a bit in there. |
Implement a file-based lock mechanism to access the Emscripten cache. Closes #3850. Also fix an issue from earlier commit where at least on Windows, calling pool.terminate / pool.join might not succeed, but instead throws an "Access is denied" exception.