Lockless algorithms for mere mortals
Lockless algorithms for mere mortals
Posted Jul 28, 2020 22:45 UTC (Tue) by excors (subscriber, #95769)In reply to: Lockless algorithms for mere mortals by warrax
Parent article: Lockless algorithms for mere mortals
Then later I found a third paper about a tool that checks C/C++ atomic code against a specification, which mentions their tool found a bug in that other paper's C11 implementation. I think I ended up with the correct code, but it's really very tricky even when trying to follow supposed experts on a pretty simple algorithm, and it would be very nice if those checking tools were in more widespread use.
Posted Jul 29, 2020 14:41 UTC (Wed)
by bgamari (subscriber, #102670)
[Link] (1 responses)
Do you have a reference to this paper? Indeed I have used the C11 paper's Chase-Lev implementation in the past so I'm very likely missing a barrier.
Posted Jul 29, 2020 15:14 UTC (Wed)
by excors (subscriber, #95769)
[Link]
Posted Jul 29, 2020 18:18 UTC (Wed)
by jezuch (subscriber, #52988)
[Link] (3 responses)
Note that Java has a formal memory model (that's how they can do anything performant without horrible memory unsafety), so it's likely that these memory barriers were not ignored, just... assumed. (But yeah, they should have at least mentioned which features of the memory model they rely on.)
Posted Jul 31, 2020 5:51 UTC (Fri)
by ncm (guest, #165)
[Link] (2 responses)
Posted Aug 2, 2020 7:02 UTC (Sun)
by jezuch (subscriber, #52988)
[Link] (1 responses)
Posted Aug 12, 2020 18:49 UTC (Wed)
by briangordon (guest, #135428)
[Link]
Posted Aug 1, 2020 17:23 UTC (Sat)
by anton (subscriber, #25547)
[Link] (1 responses)
It seems to me that all this difficult-to-program memory ordering is there because multi-processors originally come from the supercomputing area, where hardware is still more expensive than software, and hardware designers can get away with making hardware that's hard to program correctly and efficiently.
Posted Aug 3, 2020 10:12 UTC (Mon)
by farnz (subscriber, #17727)
[Link]
I would say that machine-checkability is necessary but not sufficient. If the rules are so complex to encode that a computer can't verify that you're getting them right, then they are also too complex for a human to get right, too, and they are certainly too complex for a human code reviewer to reliably check.
That said, this is a minimum requirement, as you can have rules that a computer can reliably verify, but that humans get wrong - see DEC Alpha ordering for the classic example.
Lockless algorithms for mere mortals
There's a corrected version of the buggy paper with C11 atomics: Correct and efficient work-stealing for weak memory models. The bug in the original published version was found by CDSChecker and CDSSpec, and their source repository has the original and bugfixed versions for comparison.
Lockless algorithms for mere mortals
Lockless algorithms for mere mortals
Lockless algorithms for mere mortals
Lockless algorithms for mere mortals
Lockless algorithms for mere mortals
Lockless algorithms for mere mortals
Machine-checkability does seem important.
Or one might consider such a requirement (as well as the article) to be an indication that the concepts are too difficult to use. In other cases (e.g., wrt. page colouring), Linus Torvalds has written that he targets hardware that performs well without such complications, and that other hardware deserves what it gets. I think that is a sensible approach for memory ordering as well. Have a model that's easy to understand and performs ok on nice hardware (not sure if nice hardware already exists, but weak consistency certainly does not look nice to me); then hardware designers have an incentive to make their hardware nicer.
Lockless algorithms for mere mortals