Live data from Hacker News

Spice: Fine-grained parallelism with sub-nanosecond overhead in Zig

github.com

11–20 of 56 posts

Re: Spice: Fine-grained parallelism with sub-nanosecond overhead in Zig

#11
post #4

I haven’t read through the code in detail but I can tell you “sub-nanosecond overhead” is misleading and marketing fluff. On first look, the measure seems to be some convoluted “time per thing” where the number of threads is far far smaller than the number of “thing”s

> I can tell you “sub-nanosecond overhead” is misleading and marketing fluff

If and only if (1-thread Spice - non-parallelized baseline) > 1ns, which their tests back up their claims.

https://github.com/judofyr/spice/tree/main/bench

Re: Spice: Fine-grained parallelism with sub-nanosecond overhead in Zig

#12
post #9

cooperative scheduling is the basis for so many patterns with great metrics :)

But it's not very cooperative, as in tasks yielding to each other. They mostly cooperate by letting some tasks to be given to other threads, and not all the time, but once in a heartbeat. The scheduling happens rarely, so its amortized cost is low.

Re: Spice: Fine-grained parallelism with sub-nanosecond overhead in Zig

#13
post #4

I haven’t read through the code in detail but I can tell you “sub-nanosecond overhead” is misleading and marketing fluff. On first look, the measure seems to be some convoluted “time per thing” where the number of threads is far far smaller than the number of “thing”s

That is the ecological niche of Rayon (cited) as well, isn’t it? You need to process a lot of things (thousands to millions), you want to parallelize that processing as much as possible (couple dozen of cores tops), you want to not get killed by scheduling overhead. So you account for the per-thing overhead.

Anything can have its overhead amortized, but claiming that amortization as your actual overhead is just a lie.

Re: Spice: Fine-grained parallelism with sub-nanosecond overhead in Zig

#14
I'm not terribly familiar with this space, but I do like the concurrency model presented here.

I think the README here is very well written, and I have a good idea of what's going on just from reading it, but there are a few areas where I'm left scratching my head. Thankfully the code is fairly easy to read.

Re: Spice: Fine-grained parallelism with sub-nanosecond overhead in Zig

#15
post #12
post #9

cooperative scheduling is the basis for so many patterns with great metrics :)

But it's not very cooperative, as in tasks yielding to each other. They mostly cooperate by letting some tasks to be given to other threads, and not all the time, but once in a heartbeat. The scheduling happens rarely, so its amortized cost is low.

sure, but that's all details, and there are other cooperative scheduling models which aren't excessively eager. this isn't to be a downer on this implementation, or other implementations, but just generally pointing at cooperative advantages, of which there are many, with one particular implicit and major downside, which is starvation when the cooperation contract is not adhered to.

Re: Spice: Fine-grained parallelism with sub-nanosecond overhead in Zig

#16

Earlier quoted context omitted.

That is the ecological niche of Rayon (cited) as well, isn’t it? You need to process a lot of things (thousands to millions), you want to parallelize that processing as much as possible (couple dozen of cores tops), you want to not get killed by scheduling overhead. So you account for the per-thing overhead.

Anything can have its overhead amortized, but claiming that amortization as your actual overhead is just a lie.

Most engineers aren't precise with throughput vs latency. Ideally you should report both figures (and anything else salient in performance-sensitive spaces), but it's less a lie and more an extremely commonplace mode of thinking and speaking.

Moreover, I think that mode of thought comes from the fact that most programming problems don't have hard latency bounds, so throughput dominates the conversation. If I'm spending 10us on average while handling a 10ms soft deadline, every single component can easily be occasionally 100x more expensive (latency) without me caring, and if it buys me another 1us on average (throughput) then I'll save gobs of money in compute.

Re: Spice: Fine-grained parallelism with sub-nanosecond overhead in Zig

#17
post #4

I haven’t read through the code in detail but I can tell you “sub-nanosecond overhead” is misleading and marketing fluff. On first look, the measure seems to be some convoluted “time per thing” where the number of threads is far far smaller than the number of “thing”s

Yesterday, he posted on Reddit and I expressed some concern with the benchmarks. The benchmarks are claiming 0.36 ns of overhead per call, but only the computing function. There is a second thread running doing the schedule that the overhead numbers don't include. It seems pretty clear he's running on a hyperthreaded 8 core machine (so 16 threads), I was guessing 3 Ghz, so that literally a single cycle of overhead.

Each extra thread adds more overhead from lock contention. At 16 threads overhead is up to 3.6 ns (so 10 times more). I'm guessing, but that would mean the 0.36 ns of overhead included an uncontested lock? That's not possible. There's some other weirdness going on in the benchmark data too. So either I'm not understanding what he's actually timing or maybe there is a bug in the benchmark code.

Also, if you multiply all the values out, I think he's timing in milliseconds (when runtime is calculated and converted to millis, they come out as whole numbers). Don't most benchmarkers have better precision than that? Maybe he's just using `time prog` and the data is just really dirty. Or maybe he's just choosing really, really bad metrics that totally useless for this (this is probably correct, just not sure if there are more issues).

Re: Spice: Fine-grained parallelism with sub-nanosecond overhead in Zig

#18
post #16

Earlier quoted context omitted.

Anything can have its overhead amortized, but claiming that amortization as your actual overhead is just a lie.

Most engineers aren't precise with throughput vs latency. Ideally you should report both figures (and anything else salient in performance-sensitive spaces), but it's less a lie and more an extremely commonplace mode of thinking and speaking. Moreover, I think that mode of thought comes from the fact that most programming problems don't have hard latency bounds, so throughput dominates the conversation. If I'm spendi…

Most engineers aren't precise with throughput vs latency.

Anyone making claims about performance should know the difference.

This isn't even about either, it's lying about overhead by not counting it correctly.

If someone asks what your cable bill is and you say it's only $2.50 a month because you have 32 TVs, no one is going to say that makes sense.

Re: Spice: Fine-grained parallelism with sub-nanosecond overhead in Zig

#20
post #16

Earlier quoted context omitted.

Anything can have its overhead amortized, but claiming that amortization as your actual overhead is just a lie.

Most engineers aren't precise with throughput vs latency. Ideally you should report both figures (and anything else salient in performance-sensitive spaces), but it's less a lie and more an extremely commonplace mode of thinking and speaking. Moreover, I think that mode of thought comes from the fact that most programming problems don't have hard latency bounds, so throughput dominates the conversation. If I'm spendi…

If you're trying to split a sub-second task across multiple threads, then latency is probably your main concern.
Post reply on HN