Skip to content
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

Allow setting ThreadPoolScheduler's max_threads to semi-infinite value #4941

Merged
merged 3 commits into from Jun 3, 2022

Conversation

vrurg
Copy link
Member

@vrurg vrurg commented Jun 3, 2022

Extending PR #4931.

Aside of just setting $!max_threads to a specific number via RAKUDO_MAX_THREADS environment variable the following special cases are now supported too:

  • RAKUDO_MAX_THREADS= or RAKUDO_MAX_THREADS=0 to use the default value
  • RAKUDO_MAX_THREADS=-1, RAKUDO_MAX_THREADS=inf, or RAKUDO_MAX_THREADS=unlimited to use unlimited number of treads
  • RAKUDO_MAX_THREADS=<integer> works as it always was
  • Any other value would result in an error

Since a new scheduler is normally created at startup and exception handling is barely needed its constructor currently throws just X::AdHoc.

Note that the above special cases are now also supported for constructor's :max_threads named argument:

    ThreadPoolScheduler.new(:max_threads(-1)); # Inf
    ThreadPoolScheduler.new(:max_threads<unlimited>); # Inf
    ThreadPoolScheduler.new(:max_threads(0)); # Same as omitting the
                                              # argument

Super-micro-optimization: use of BUILDPLAN is considered too much for the ThreadPoolScheduler class. So, replaced it with new+!SET-SELF approach.

lizmat and others added 2 commits June 1, 2022 23:03
For those of us brave enough to not want to be stopped by a maximum
number of OS threads.  Specifying * or Inf will internally store the
value 9223372036854775807 (aka the current maximum value for an uint
attribute).  The accessor will return Inf if this value is found.
Extending PR #4931.

Aside of just setting `$!max_threads` to a specific number via
`RAKUDO_MAX_THREADS` environment variable the following special cases
are now supported too:

- `RAKUDO_MAX_THREADS=` or `RAKUDO_MAX_THREADS=0` to use the default
  value
- `RAKUDO_MAX_THREADS=-1`, `RAKUDO_MAX_THREADS=inf`, or
  `RAKUDO_MAX_THREADS=unlimited` to use unlimited number of treads
- `RAKUDO_MAX_THREADS=<integer>` works as it always was
- Any other value would result in an error

Since a new scheduler is normally created at startup and exception
handling is barely needed its constructor currently throws just
`X::AdHoc`.

Note that the above special cases are now also supported for
constructor's `:max_threads` named argument:

    ThreadPoolScheduler.new(:max_threads(-1)); # Inf
    ThreadPoolScheduler.new(:max_threads<unlimited>); # Inf
    ThreadPoolScheduler.new(:max_threads(0)); # Same as omitting the
                                              # argument

Super-micro-optimization: use of BUILDPLAN is considered too much for
the `ThreadPoolScheduler` class. So, replaced it with `new`+`!SET-SELF`
approach.
This would be more correct approach for MoarVM backend too.

- Removed `$.initial_threads` attribute because it is only used at the
  construction stage and is not needed otherwise.
@vrurg vrurg merged commit 77bc030 into master Jun 3, 2022
@vrurg vrurg deleted the vrurg-unlimited-threads branch June 4, 2022 00:06
melezhik added a commit to melezhik/r3tool that referenced this pull request Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants