-
Notifications
You must be signed in to change notification settings - Fork 6
Explicitly manage FIFO thread resource #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
fea2db8 to
2c52f47
Compare
2c52f47 to
173863e
Compare
173863e to
7f0869a
Compare
|
FWIW, this is just to spur discussion. No expectations! |
|
Hi, Your code is really nice, it works and I'm glad for it! I'm reluctant, because I'm not sure we should introduce complexity in our code for the sake of a warning in a unit test output (which I can't reproduce in the Docker image, nor on my machine). Reproducability actually doesn't matter. Even if this always happened everywhere, I would rather adjust these two testcases than introduce complexity in the code. We already have "sleep hacks" in other unit tests too. Actually it's always for waiting file creation. I guess, we could create a Or if you can give a reason outside of unit tests, where this added complexity to fifo would pay of, let me know! Thanks again for the PR and the thought provoking! |
|
Thanks for the feedback!
That said, if we consider implementing dynamic settings, I think this makes sense. Ideally, if a user changes the state of We might also want to set a thread alias, to make thread interaction easy for users, but maybe there's a better way. |
Test "setup_fifo + (already exists)" would sometimes error with ENOENT on `/tmp/test-fifo`. We noticed that it was intermittent and nailed it down to a race condition between "setup_fifo +" and "setup_fifo + (already exists)" both racing to create and delete `/tmp/test-fifo`. Previously, we were creating the FIFO thread in a detached state, which made verification and management challenging. Tests were spawning multiple copies of the thread, forcing workarounds and the issue above. This commit introduces explicit management for the FIFO thread, which allows us to be more direct and precise in the previously-failing tests.
7f0869a to
6ec3ccd
Compare
Valid point. That would definitely require us storing the thread ID.
Yes. If I delete the fifo file and re-create it later, plwm can pick up processing it with your solution, but not with mine. However, this particular implementation (i.e. trying This can be solved by changing the The bigger problem however is that if I indeed delete the fifo file, than plwm spins up the CPU to around 135% until it's re-created. This is because in this case plwm could also try re-creating the fifo, but I think we'd mostly land in this state if it couldn't create it in the first place during startup. It probably couldn't do it later either. If I add a A proper solution would be if we could distinguish between the actual (call_with_time_limit(5.0, open(FifoPath, read, Fifo)),
(read_terms(Fifo, Jobs) ->
jobs_notify(Jobs)
; true),
close(Fifo)
), Ex, (Ex \= time_limit_exceeded(_) -> sleep(5))The problem though is that error(existence_error(source_sink,/tmp/plwm_fifo),context(system:open/3,Interrupted system call))Not sure why this is the case when it comes from call_with_time_limit/3. It should be a tl;dr We're in good direction, but should solve this performance problem, otherwise plwm goes brrrr exactly in the situation we're trying to mend. |
Yikes! Good catch.
Probably
Indeed. This is why I originally went with Arguably, the timeout is a hack and
The disadvantage is that it complicates the architecture some, and now every time we update dynamic settings, somehow Good discussion. Thoughts? |
Yeah I think, you're right on this.
I'm currently working on the configuration redesign that will let us dynamically change any setting. A separate thread that watches for changes won't be needed, I think. I'd also avoid multi-threading as much as possible. Though this fifo handling will be a special case indeed, so I'm not dismissing this approach just yet. I'll get back to this once I'm done with the config redesign. I'll let you know and ask for feedback as soon as I have a working state. Then we can continue this from there. Thanks for the ideas! ^^ |
Test "setup_fifo + (already exists)" would sometimes error with ENOENT
on
/tmp/test-fifo. We noticed that it was intermittent and nailed itdown to a race condition between "setup_fifo +" and "setup_fifo +
(already exists)" both racing to create and delete
/tmp/test-fifo.Previously, we were creating the FIFO thread in a detached state,
which made verification and management challenging. Tests were spawning
multiple copies of the thread, forcing workarounds and the issue above.
This commit introduces explicit management for the FIFO thread, which
allows us to be more direct and precise in the previously-failing tests.