Most active commenters
  • bob1029(3)
  • bsenftner(3)
  • vlovich123(3)

←back to thread

151 points ibobev | 38 comments | | HN request time: 1.351s | source | bottom
1. bob1029 ◴[] No.45653379[source]
I look at cross core communication as a 100x latency penalty. Everything follows from there. The dependencies in the workload ultimately determine how it should be spread across the cores (or not!). The real elephant in the room is that oftentimes it's much faster to just do the whole job on a single core even if you have 255 others available. Some workloads do not care what kind of clever scheduler you have in hand. If everything constantly depends on the prior action you will never get any uplift.

You see this most obviously (visually) in places like game engines. In Unity, the difference between non-burst and burst-compiled code is very extreme. The difference between single and multi core for the job system is often irrelevant by comparison. If the amount of cpu time being spent on each job isn't high enough, the benefit of multicore evaporates. Sending a job to be ran on the fleet has a lot of overhead. It has to be worth that one time 100x latency cost both ways.

The GPU is the ultimate example of this. There are some workloads that benefit dramatically from the incredible parallelism. Others are entirely infeasible by comparison. This is at the heart of my problem with the current machine learning research paradigm. Some ML techniques are terrible at running on the GPU, but it seems as if we've convinced ourselves that GPU is a prerequisite for any kind of ML work. It all boils down to the latency of the compute. Getting data in and out of a GPU takes an eternity compared to L1. There are other fundamental problems with GPUs (warp divergence) that preclude clever workarounds.

replies(7): >>45660423 #>>45661402 #>>45661430 #>>45662310 #>>45662427 #>>45662527 #>>45667568 #
2. bsenftner ◴[] No.45660423[source]
Astute points. I've worked on an extremely performant facial recognition system (tens of millions of face compares per second per core) that lives in L1 and does not use the GPU for the FR inference at all, only for the display of the video and the tracked people within. I rarely even bother telling ML/DL/AI people it does not use the GPU, because I'm just tired of the argument that "we're doing it wrong".
replies(4): >>45663377 #>>45663434 #>>45663730 #>>45666183 #
3. kiitos ◴[] No.45661402[source]
> I look at cross core communication as a 100x latency penalty

if your workload is majority cpu-bound then this is true, sometimes, and at best

most workloads are io (i.e. syscall) bound, and io/syscall overhead is >> cross-core communication overhead

4. dist-epoch ◴[] No.45661430[source]
The thing with GPUs is that for many problems really dumb and simple algorithms (think bubble sort equivalent) are many times faster than very fancy CPU algorithms (think quick sort equivalent). Your typical non-neural-network GPU algorithm is rarely using more than 50% of it's power, yet still outperforms carefully written CPU algorithms.
replies(2): >>45665642 #>>45668021 #
5. anyfoo ◴[] No.45662310[source]
> If everything constantly depends on the prior action you will never get any uplift.

I mean... that's kind of a pathological case, no?

replies(1): >>45666724 #
6. pron ◴[] No.45662427[source]
That's fine, but a work-stealing scheduler doesn't redistribute work willy-nilly. Locally-submitted tasks are likely to remain local, and are generally stolen when stealing does pay off. If everything is more-or-less evenly distributed, you'll get little or no stealing.

That's not to say it's perfect. The problem is in anticipating how much workload is about to arrive and deciding how many worker threads to spawn. If you overestimate and have too many worker threads running, you will get wasteful stealing; if you're overly conservative and slow to respond to growing workload (to avoid over-stealing), you'll wait for threads to spawn and hurt your latencies just as the workload begins to spike.

replies(1): >>45662804 #
7. Archit3ch ◴[] No.45662527[source]
> If everything constantly depends on the prior action you will never get any uplift.

Not always. For differential equations with large enough matrices, the independent work each core can do outperforms the communication overhead of core-to-core latency.

replies(1): >>45663138 #
8. vlovich123 ◴[] No.45662804[source]
There’s secondary costs though - because you might run on any thread you have to sprinkle atomics and/or mutexes all over the place (in Rust parlance the tasks spawned must be Send) which have all sorts of implicit performance costs that stack up even if you never transfer the task.

In other words, you could probably easily do 10m op/s per core on a thread per core design but struggle to get 1m op/s on a work stealing design. And the work stealing will be total throughput for the machine whereas the 10m op/s design will generally continue scaling with the number of CPUs.

replies(2): >>45663406 #>>45664068 #
9. jayd16 ◴[] No.45663138[source]
If its independent work then it's work that doesn't rely on the prior action... At least not in the way the parent means.
replies(1): >>45663576 #
10. zipy124 ◴[] No.45663377[source]
How are you doing tens of millions of faces per second per core, first of all assuming a 5ghz processor, that gives you 500 cycles per image if you do ten million a second, that's not nearly enough to do anything image related. Second of all L1 cache is at most in the hundreds of kilobytes, so the faces aren't in L1 but must be retrieved from elsewhere...??
replies(4): >>45663801 #>>45663834 #>>45663907 #>>45666117 #
11. zipy124 ◴[] No.45663406{3}[source]
What about using something like https://github.com/judofyr/spice?
replies(1): >>45663658 #
12. rdedev ◴[] No.45663434[source]
Could you tell me a bit about how you were able to ensure the model is close to the cache?
replies(1): >>45663780 #
13. Archit3ch ◴[] No.45663576{3}[source]
State can depend on the previous time point, or even the same time point. I see this misconception often in audio programming "you cannot parallelise work because it depends on the previous sample". As long as you can find parallelism somewhere and it's less than the overhead, you can benefit. Obviously if there's zero parallelism in the problem, no amount of cores will help.
14. vlovich123 ◴[] No.45663658{4}[source]
These aren’t task queues as are being discussed here. It’s more like rayon - I have a par_iter and I want that to go as fast as possible on a large number of elements. Slightly different use case than thread per core vs work stealing runtime.
15. kcb ◴[] No.45663730[source]
No shot are you doing tens of millions of anything useful per second per core. That's like beyond HFT numbers.
replies(1): >>45666053 #
16. izabera ◴[] No.45663780{3}[source]
the secret is to keep things ˢᵐᵒˡ
17. Keyframe ◴[] No.45663801{3}[source]
You can't look at it like _that_. Biometrics has its own "things". I don't know what OP is actually doing, but it's probably not classical image processing. Most probably facial features are going through some "form of LGBPHS binarized and encoded which is then fed into an adaptive bloom filter based transform"[0].

Paper quotes 76,800 bits per template (less compressed) and with 64-bit words it's what, 1200 64-bit bitwise ops. at 4.5 Ghz it's 4.5b ops per second / 1200 ops per per comparison which is ~3.75 million recognitions per second. Give or take some overhead, it's definitely possible.

[0] https://www.christoph-busch.de/files/Gomez-FaceBloomFilter-I...

Cache locality is a thing. Like in raytracing and the old confucian adage that says "Primary rays cache, secondary trash".

replies(1): >>45664454 #
18. dudeofea ◴[] No.45663834{3}[source]
I don't know the application, but just guessing that you don't need to compare an entire full-resolution camera image, but perhaps some smaller representation like an embedding space or pieces of the image
19. ekidd ◴[] No.45663907{3}[source]
Back in the old days of "Eigenfaces", you could project faces into 12- or 13-dimensional space using SVD and do k-nearest-neighbor. This fit into cache even back in the 90s, at least if your faces were pre-cropped to (say) 100x100 pixels.
20. pron ◴[] No.45664068{3}[source]
An occasional successful CAS (on an owned cache line) has very little cost, but if you have to sprinkle atomics/mutexes all over the place, then there's something that's clearly not scalable in your design regardless of the concurrency implementation (you're expecting contention in a lot of places).
replies(1): >>45664426 #
21. vlovich123 ◴[] No.45664426{4}[source]
An atomic add on a 6ghz high end desktop CPU (13900) is I believe on the order of 4-10ns. If it’s in your hot path your hot path can’t go faster than 50-100 million operations/s - that’s the cost of 1 such instruction in your hotpath (down from the 24 billion non-atomic additions your 6ghz could do otherwise). A CAS brings this down to ~20-50 Mops/s. So it’s quite a meaningful slowdown if you actually want to use the full throughput of your CPU. And if that cache line is cached on another CPU you pay an additional hidden latency that could be anywhere from 40-200ns further reducing your hotpath to a maximum of 5-25MHz (and ignoring secondary effects of slowing down those cores without them even doing anything). God forbid there’s any contention - you’re looking at a variance of 20x between the optimal and worst case of how much of a throughput reduction you see by having a single CAS in your hot loop. And this is just talking about the task scheduler - at least in Rust you’ll need to have thread-safe data structures being accessed within the task itself - that’s what I was referring to as “sprinkled”. If you really want to target something running at 10Mops/s on a single core, I don’t think you can possibly get there with a task stealing approach.
replies(1): >>45680136 #
22. reactordev ◴[] No.45664454{4}[source]
Correct, it’s probably distance of a vector or something like that after the bloom. Take the facial points as a vec<T> as you only have a little over a dozen and it’s going to fit nicely in L1.
replies(1): >>45668775 #
23. pjmlp ◴[] No.45665642[source]
Except it is only worth doing, if when taking into account loading data into the GPU and getting the results back, is still faster than total execution on the CPU.

It doesn't help that GPU beats the CPU in compute, if a plain SIMD approach outperforms the total execution time.

replies(2): >>45666924 #>>45667762 #
24. bob1029 ◴[] No.45666053{3}[source]
You can handle hundreds of millions of transactions per second if you are thoughtful enough in your engineering. ValueDisruptor in .NET can handle nearly half a billion items per second per core. The Java version is what is typically used to run the actual exchanges (no value types), so we can go even faster if we needed to without moving to some exotic compute or GPU technology.
replies(1): >>45667894 #
25. bob1029 ◴[] No.45666117{3}[source]
> assuming a 5ghz processor, that gives you 500 cycles per image if you do ten million a second

Modern CPUs don't quite work this way. Many instructions can be retired per clock cycle.

> Second of all L1 cache is at most in the hundreds of kilobytes, so the faces aren't in L1 but must be retrieved from elsewhere...??

Yea, from L2 cache. It's caches all the way down. That's how we make it go really fast. The prefetcher can make this look like magic if the access patterns are predictable (linear).

replies(1): >>45667555 #
26. immibis ◴[] No.45666183[source]
Do you work for Flock?
27. thaumasiotes ◴[] No.45666724[source]
I'd say it's pretty normal for a workflow. If you have a lot of things that can proceed independently of each other, you're likely to see that characterized as "multiple workflows".

Say you're making a four-course meal. In the abstract, each course is independent of the other three, but internally the steps of its preparation have exactly this kind of dependence, where step 3 is scheduled after step 2 because doing those steps in the other order will ruin the food.

If you ever want to make just one of those courses -- maybe you're going to a potluck -- now you've got an almost fully sequential workflow.

(And in practice, the full four-course meal is much more sequential than it appears in the abstract, because many of the steps of each course must contend for scarce resources, such as the stove, with steps of other courses.)

28. woooooo ◴[] No.45666924{3}[source]
Especially if you're saving watts in the process. And not utilizing a capital-intensive asset.
29. whizzter ◴[] No.45667555{4}[source]
The keyword is CAN, there can also be huge penalties (random main-memory accesses are over a cycles typically), the parent was probably considering a regular image transform/comparison and 20 pixels per cycle even for low resolution 100x100 images is way above what we do today.

As others have mentioned, they're probably doing some kind of embedding like search primarily and then 500 cycles per face makes more sense, but it's not a full comparison.

30. codetiger ◴[] No.45667568[source]
I was with a similar assumption that thread per core might be the best approach for one of my OpenSource Rust libraries that is a Workflow Orchestration engine. The engine is focused on payment processing. The perv version had thread local engine and focused on thread per core. When I moved to a pure async based engine using tokio runtime and all underlying libraries made thread safe, it improved the performance 2x. The entire workload being fully CPU driven with no IO. I was assuming tokio mostly does better only for IO based workloads, however my tests proved me wrong. Now am not moving away from async approach. https://github.com/GoPlasmatic/dataflow-rs
31. formerly_proven ◴[] No.45667762{3}[source]
The "GPU as accelerator" vs. "GPU-native software" split. The former usually results in or from poor, generic architectures.
32. jcelerier ◴[] No.45667894{4}[source]
It's so sad to see how many people not knowing how incredibly fast our CPUs are
33. sumtechguy ◴[] No.45668021[source]
That is application of the formula

Pre-work time + pack up time + send time + unpack time + work time + pack up time + send time + unpack time + post-work time.

All remote work has these properties. Even something 'simple' like a remote REST call. If 'remote work time' plus all that other stuff is less than your local calls then it is time wise worth sending it remote. If not local CPU would win.

That in many cases right now the GPU is 'winning' that race.

replies(1): >>45668465 #
34. EraYaN ◴[] No.45668465{3}[source]
There are some neat tricks to remove almost all the pack and unpack time. Apache Arrow can help a ton there (uses the same data format on both CPU and GPU or other accelerator). And on some unified memory systems even the send time can be very low.
35. bsenftner ◴[] No.45668775{5}[source]
NDA prevents me from saying anything beyond the compares are minimal representatives of a face template, and those stream through the core's caches.
replies(2): >>45669495 #>>45672890 #
36. reactordev ◴[] No.45669495{6}[source]
Queue the “If I were to build it…” ;)
37. bsenftner ◴[] No.45672890{6}[source]
A public report from the employer about the tech https://cyberextruder.com/wp-content/uploads/2022/06/Accurac... (I no longer work there.)
38. skavi ◴[] No.45680136{5}[source]
Is that best case latency? e.g., with only one thread adding to that location?