3 ms·
But at least in C/C++ you can fix it. That is, I can control how my data lines up with the cache in C/C++, with sufficient care and effort. Doing the same thi
by AnimalMuppet 7y ago
But at least in C/C++ you can fix it. That is, I can control how my data lines up with the cache in C/C++, with sufficient care and effort. Doing the same thing in Haskell or OCaml would be considerably harder.
- lmm 7y ago> That is, I can control how my data lines up with the cache in C/C++, with sufficient care and effort. Doing the same thing in Haskell or OCaml would be considerably harder. Would it really? The OCaml compiler is pretty simple and consistent; there was a story here not so long ago where some OCaml users diagnosed a CPU bug that people using C/C++ hadn't noticed.
- kragen 7y agoI don't know if the problem is that you don't know OCaml or that you don't know C, but yes, it is considerably harder; in OCaml you cannot embed objects in other objects as you can in C (and C++, and Golang), because OCaml uses the Lisp memory model, as described in http://canonical.org/~kragen/memory-models http://canonical.org/~kragen/memory-models. Consequently you end up with things which are perhaps conceptually a single object potentially strewn around the heap at random, however the allocator and the garbage collector choose to arrange them, and linked together by pointers. There's a lot of payoff for this — it's safe and trivially easy to write parametrically polymorphic code in OCaml, while it ranges from fiddly and error-prone to overwhelming to impossible in different languages in the C family — but it's a major fundamental difference, and it does have some runtime efficiency costs.