3 ms·
The hardest part of parallel programming is tricking yourself into believing you need to worry about it at all. 9/10 times, if you use the right tools & techni
by bob1029 6y ago
The hardest part of parallel programming is tricking yourself into believing you need to worry about it at all.
9/10 times, if you use the right tools & techniques, a single x86 core (assuming you have access to a 'real' one) can easily chew through millions of business transactions per second and easily satisfy all technical requirements for whatever business system.
Latency is the ultimate devil. Getting your synchronous state to fit into L1/2 and processing transactions in (micro)batches of contiguous data is how you win the game. The closer your data is to your compute, the faster you can go.
The biggest problem most developers are struggling with right now is that they got tricked into scattering their business systems across many computers and potentially across multiple physical regions. The latency in L1 is measured in nanoseconds. The latency between 2 datacenters is measured in milliseconds. This is SIX orders of magnitude difference. Even if you squander 3 of those to some bad programming practices, you are still 1000x better off on a single box using a single thread than if you scattered your infra to the seven winds.
See: LMAX Disruptor for a case study in what the opposite end of the "infrastructure isnt my problem" spectrum looks like.
- VHRanger 6y agoA problem here is that people interpreted some common sense advice like SOLID into "break everything into classes pointing to each other". Which creates maximally cache hostile code very fast -- any operation is often several pointer dereferencing (eg. back-and-forth to RAM).
- flukus 6y agoEven in code like this just being aware of cache levels and there relative timings can sometimes produce some impressive speedups with simple things like sorting the initial data to make it cache friendly. A recent one I improved was along the lines of: for t in transactions t.client = clients[t.ClientId] t.product = products[t.ProductId] In this case sorting transactions by ClientId, ProductId was an orders of magnitude speedup because client and product were already in cache in L1/L2 cache most of the time. It could have been faster again with less SOLID but improvements like this are often easy and politically achievable because it keeps the sacrifice to the OO gods. Treating Big O as the be all of performance has quite a lot to answer for in real world code, often constants aren't so constant.
- tmotwu 6y agoParallel programming is not what you think it is. You're right that parallelism is not the answer to everything, but parallel programming is not even a paradigm people use to write basic business transaction logic. Distributed computing, yes, not parallel programming. Amdahl's law has more to do with diminishing returns in parallel processing moreso than physical proximity to memory. 9/10 times the hundred cycles you save from leveraging your caches vs memory accesses is eclipsed by millions/billions of extra cpu cycles you have to perform for certain computations. Not to mention not every application has predictable memory access patterns that would benefit from LRU/LFU policies. Now that Moore's law is no longer the bible in computer architecture research, CPU designers have to resort to increasing core count. With the advent of machine learning and big data workloads, you'll spend thousands of years crunching numbers on a single threaded application.