4 ms·
> and that occasionally surprises people But what did they want? They tell me they're not happy with 0% chance of some interleaving they need. Are they happy
by chrisseaton 5y ago
> and that occasionally surprises people
But what did they want?
They tell me they're not happy with 0% chance of some interleaving they need. Are they happy with 0.000000000001%? I'm not sure I understand the practical difference between that and 0%? Can I tell them it is possible, but rely on the death of the universe happening before they have a right to complain it didn't turn up yet? If they have some hard minimum they require, then what do they expect me to do? Completely abstract from the system scheduler to make it happen?
Doesn't seem a reasonable expectation from programmers on compiler writers, and likely wouldn't really be what they wanted even if I made it happen.
- dataflow 5y agoIt might be 0.000000000001% but it need not be, right? That's kind of the point. I'm pretty sure I could write you a program where the probability of observing that would be (say) 50% without the optimization, and with the optimization that would go to 0%, defeating the program. Should that be allowed? This is basically a statistical/probabilistic version of another problem: should a compiler be allowed to change the time complexity of an algorithm? If I write linear search, and the compiler proves the list is sorted, should it be allowed to switch to binary search—or vice-versa? Traditionally the answer might be 'yes', but it's not exactly hard to argue an answer of 'no' might also be desirable in a number of situations. Now in this case, it's not the time complexity that's changing, but the statistical properties of the program... and while in some cases it might be negligible (1E-10 or what have you), that's not necessarily the case, at which point a difference in degree really can become a difference in kind.
- chrisseaton 5y agoBut no mechanism was ever guaranteeing the 50% in the first place. So their program could already stop working correctly without any changes and with the same compiler. What I'm saying is I don't know how they'd even tell the difference between my compiler being the problem, or them just being unlucky and not getting the interleavings they want even though they're statistically likely.
- dataflow 5y agoI'm saying if you made a complier that made reduced that expected 50% to roughly 0%, it wouldn't matter to the user if it was 1E-10 or exactly 0%. Both could be undesirable for exactly the same reason. Again: you can complain that the 1E-10 compiler is still "correct" because there was never a 50% guarantee, but in doing that you're completely missing the point. Here's an exaggerated example to get the point across. Imagine your Tesla autopilot's accuracy suddenly dropped from >99.9999% to <0.00001% overnight because of some stupid optimization (maybe this one) that was technically correct. Assume there was never a guarantee provided to the user that it would stay this accurate. Now if your 99.9999% became 99.9998% overnight, OK, I think a sane user would completely anticipate that and live with it. But when it drops orders of magnitude lower, do you really think you could shift the blame to the user because you were "technically" not guaranteeing anything? Is it really the user's fault that your optimization reduced that accuracy to 0.00001% and killed them? Can you walk away with your conscience clear at that point that you did everything 'right'? At what point do you feel like some kinds of changes just blatantly unfair and uncalled for, even if they're technically "by the book"?
- deleted 5y ago[deleted]
- chrisseaton 5y agoI guess I don't know why the user would be betting on interleavings which I never said I could guarantee. If you build your car with a part that isn't rated for what you use it for that's your fault not the manufacturer of the part - even if it worked every time when they tested it and they never saw it fail before one time it kills someone. I'm open to ideas on how to create understanding both ways on what the user wants and the compiler is able to provide?
- dataflow 5y ago> I guess I don't know why the user would be betting on interleavings which I never said I could guarantee. Same reason people walk outside without bodyguards and "bet" on coming back home alive despite the fact that nobody ever gave them such a guarantee. It's not insane to expect the future to bear some kind of resemblance to the past without some contract to guarantee it, is it?
- deleted 5y ago[deleted]
- Dylan16807 5y ago> If they have some hard minimum they require, then what do they expect me to do? Completely abstract from the system scheduler to make it happen? What if they say the hard minimum is "occasionally"? They're not holding you responsible for the scheduler, they just want you to leave it as possible. (and not be deliberately malicious, just in case that needs to be said)
- chrisseaton 5y agoIsn't this already expressible with something like a yield statement between the two atomics? If you need it - write it down! I can't guess your intentions as a compiler author!
- Dylan16807 5y agoA yield might be way too slow. And sure, there should be a way to signal intentions. By my point is that there is a reasonable way to describe what certain people would expect by default.
- spacechild1 5y ago“volatile std::atomic“ also works and is more clear, IMO.
- lmm 5y agoWhat they wanted was a cross-platform assembler, often. They listened to people who told them things like "C is close to the metal".
- pjmlp 5y agoThe amount of damage made to IT industry by that cargo cult is immeasurable and will take generations to recover from, if ever.