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

Your feedback wanted! #7

Open
polytypic opened this issue Oct 31, 2023 · 3 comments
Open

Your feedback wanted! #7

polytypic opened this issue Oct 31, 2023 · 3 comments

Comments

@polytypic
Copy link
Collaborator

polytypic commented Oct 31, 2023

I'm creating this issue as a general request for feedback and discussion.

Feel free to add comments on Picos to this issue or open a discussion.

  • Questions on anything about Picos.
  • Comments on how you feel about Picos in general.
    • As a potential user of concurrent programming libraries in OCaml, how do you see Picos?
    • As a potential provider of concurrent programming libraries (schedulers etc), how do you see Picos?
  • Specifics in Picos that you find problematic.
  • Is something missing?
  • Should something be removed?
  • General suggestions for improvements.

Critique is welcome, but please keep a friendly tone! 🙇

Picos is not yet considered to be final, so changes are possible — even likely.

I will especially promise to try my best to explain the rationale and ideas behind the design. Much of it might not be immediately apparent or documented.

@francoisthire
Copy link

francoisthire commented Apr 9, 2024

I am reading the code, and I am wondering why is there an annotation @inline never there? What would be the issue if it was inlined? https://github.com/ocaml-multicore/picos/blob/main/lib/picos/bootstrap/picos_bootstrap.ml#L4

@francoisthire
Copy link

Another question: with a Trigger, why does an action takes two parameters instead of one? It does not sound obvious to me the kind of use-case for having two parameters, maybe performance reason to avoid allocating a tuple?

@polytypic
Copy link
Collaborator Author

polytypic commented Apr 9, 2024

why is there an annotation @inline never there?
with a Trigger, why does an action takes two parameters instead of one

Yes, both of those are for low level performance reasons. Note that the core picos framework is not intended for application level programming and it is important that higher level libraries can be built on top of it without having to significantly compromise performance.

The @inline never attribute can be useful, for example, with functions that are called from branches that are unlikely taken or not performance sensitive. The awaiting () function is only called in case a programming error is detected. Having @inline never there can slightly reduce the cache footprint of the normal execution path(s).

Note that Trigger.on_signal (and Trigger.from_action) should only be called by a scheduler (or in some special cases where you essentially want to attach a callback to a computation and cannot afford to use fibers). In normal use cases a Trigger is much like a kind of single use/sticky Condition variable and you use it as a simple first order abstraction and don't attach callbacks to it (that capability is for schedulers). The use of extra arguments can avoid having to allocate a closure (or tuple) for the action. Two extra arguments has been just enough in the practical cases and uses fewer words than a closure (or tuple) would. Admittedly it is a rather low level detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants