Welcome to the main channel on the development of MoarVM, a virtual machine for NQP and Rakudo (moarvm.org). This channel is being logged for historical purposes.
Set by lizmat on 24 May 2021.
Kaiepi i tried using uv_timer_t to sleep(0) instead of yielding, but apparently that api forks? 16:46
i did manage to get sleep(0e0)/nanosleep(0) to work given recent changes, but it's rather slow
jnthn Kaiepi: What's the original goal here? Semaphore (along with similar classes) were really intended to expose the primitive kernel-supported locks/sempahores; if you want something a bit different and are willing to depend on yield and atomics, there's no reason to put it in MoarVM, because those are all available in Raku. 17:41
tellable6 2022-07-22T07:39:31Z #moarvm <Kaipii> jnthn, do you have any suggestions on how to benchmark semaphore ops reliably?
jnthn No yield/sleep/whatever is going to be as effective for longer waits as something where the OS schedule is aware of it. 17:42
*scheduler
Kaiepi jnthn, to get an implementation of Semaphore with some equivalent to sem_getvalue 17:54
so we can get a serializable, thread-safe counter for the MOP 17:55
(or at least a more efficient one) 17:56
jnthn Counter? Is an atomic integer not enough? 19:17
Kaiepi an atomic integer requires a container 19:18
jnthn Not quite, just a reference to an integer lexical/attribute/array elemnt
And if the concern is performance, one can create that reference once and use it many times 19:19
Ah, and if it's for the MOP, and nobody got around to it yet, there might be a little setup work to do to make those available in NQP 19:20
github.com/rakudo/rakudo/blob/a7e9....nqp#L1899 is a place to look at how the setup is done if wanting to do it for NQP 19:22