-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Domain: document clearly that creating more domains than recommended is a terrible idea #11921
Comments
As part of that, it's probably worth mentioning that it's because of the GC that you never want to do this (i.e. we strengthen the advice and also explain why it's different from the user's preconceptions about how OS threads normally work) |
If we never want to do it then shouldn't we just make it the |
No, for example because we don't fully trust Remember that Domain is intended to be a first building block for parallel code, not the user-facing abstraction. We should document its assumptions carefully, but the module is not the right place to reduce flexibility in exchange for convenience. |
I stumbled into this while investigating a performance problem, so my apologies for resurrecting this, but some relevant notes from a person who is new to OCaml:
|
@dclements I agree. Would you like to submit PRs to improve the documentation in various places? There is no recommended pooling library because early 5.x releases were designed as "early adopter" releases, with an understanding that the concurrency library ecosystem is incomplete. The Domains module is a low-level abstraction, and we are waiting for userland to provide better abstractions -- faster, hopefully, than we users observe our manual/documentation updates (every six months on new releases). To my knowledge the current pooling implementations are:
but I fully expect most large programs adopting 5.0 to come up with their own, bespoke solutions to this problem. |
We have succesfully communicated that domains are heavy-weight abstractions, there should be a few of them, about the same number as hardware threads running on the machine. What most users do not realize is that having just a bit more domains than hardware threads is generally a terrible idea for performance. (I only learned of this myself a couple month ago.) They may rather be thinking of "pthread with some more runtime overhead", the kind you can have 100s but not 10000s.
Currently the OCaml manual says:
and domain.mli says:
What we probably want to say is more like "never ever spawn more domains than recommended; always always use a domain pool". Otherwise people just get confused and write bad code, and the documentation is partly to blame.
Related issues:
Domain.recommended_domain_count
#11649 (comment), Clarify docs forDomain.recommended_domain_count
#11649 (comment)The text was updated successfully, but these errors were encountered: