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
Rakudo hangs with shell processes in Promises after reaching max_threads #2834
Comments
This is due to exhaustion of the thread pool, which is a shared resource. The default thread limit is not 2, but 64. I don't consider the problem here a particularly practical one, since by the time a program exhausts 64 OS threads just on running concurrent processes, that's well past the point where it should have been written in terms of If one insists on using One potential way to make this kind of program Just Work would be for us to decide that Either way, so far as the language as defined today goes, there's not a Rakudo bug here. |
Ah, and since it looks like the only way anything is likely to change here is a language design change, the appropriate forum for further proposals on that would be the problem solving repo, so I'll close this one. |
@jnthn If I use |
i don't see a simple way to figure out how much cpu resources the spawned processes are consuming - getrusage and times, for example, will only report on child processes that have already terminated - but if you find a sensible method of measurement, you can use SIGSTOP and SIGCONT to switch processes on and off to conserve cpu time if your spawned processes can be made to cooperate, i.e. you can change their source code, setrlimit will allow you to set a soft limit on cpu time, which when exceeded will have the kernel send SIGXCPU to the child process; if you have a signal handler installed in that process, you can have it communicate with the spawning process that it will now wait for more cpu time to be allocated to it; the spawning process would then raise the soft cpu limit and tell the process to continue tbh, i don't think there's anything simpler than cgroups or something like that |
@molecules you can create your own scheduler to use fewer threads.
|
@molecules If you're looking to limit the number of running procs, then see these slides from around slide 34. |
@jnthn If you don't mind posting your answer (i.e. #2834 (comment)) I'll accept it for my question at Stackoverflow (https://stackoverflow.com/questions/55265176). |
@molecules Will do so shortly. :-) |
@jnthn I was hoping you'd answer in time to claim raiph's bounty on the question. There is only seven or eight hours left. By the way, thank you for all of your work on Perl 6! It's definitely my favorite language. |
@molecules Done! :-) |
The Problem
When multiple
Promise
s containshell
, rakudo hangs upon awaiting the nth one, where n = max scheduler threads.Expected Behavior
Actual Behavior
Steps to Reproduce
Run the attached script (foo_bar_baz.p6) thus:
perl6 foo_bar_baz.p6
Here is the script as well:
Simply change
max_threads
to 4 and the problem disappears.Environment
Operating system:
CentOS Linux release 7.4.1708 (Core)
Compiler version (
perl6 -v
):Rakudo Star version 2018.06 built on MoarVM version 2018.06 implementing Perl 6.c.
Rakudo Star version 2018.10 built on MoarVM version 2018.10 implementing Perl 6.c.
Rakudo Star version 2019.03.1 built on MoarVM version 2019.03 implementing Perl 6.d.
The text was updated successfully, but these errors were encountered: