4 ms·
Oh come on, that language lawyering is sophistry. If I write 4 instructions that are "atomic" I expect 4 instructions. If I end up with one, they werent really
by overgard 5y ago
Oh come on, that language lawyering is sophistry. If I write 4 instructions that are "atomic" I expect 4 instructions. If I end up with one, they werent really "atoms" were they? I do not expect what you just said. I may think, gee, perhaps I don't need 4 instructions, but what you are doing is undeniably changing the meaning of the program, even if you think it's close enough. The fact that there's an article about this tends to agree with me that most people think: wtf happened?
- kllrnohj 5y agoIf you're going to use atomics, you should be reading what guarantees those atomics actually provide. In this case of memory_order_relaxed they pretty clearly specify they don't provide any cross-thread synchronization. So if you wrote those 4 atomics expecting something the docs explicitly & clearly say it doesn't provide, that's pretty much entirely your fault and not "language lawyering"
- chrisseaton 5y ago> If I write 4 instructions that are "atomic" I expect 4 instructions. Why do you expect that? Nobody ever promised you that. If you expect something you weren’t promised then that’s on you. > If I end up with one, they werent really "atoms" were they? Atomic has a technical definition - it means either applied fully or not at all. That doesn’t preclude combining. > what you are doing is undeniably changing the meaning of the program It doesn’t! According to the spec we’re both working off. If you think the spec is wrong then change it. But I can’t guess what you want unless you tell me using the spec.
- overgard 5y ago> Why do you expect that? Because I wrote it? > Nobody ever promised you that. I just assumed that compiler writers had empathy for humans, my bad. > It doesn’t! According to the spec we’re both working off. If you think the spec is wrong then change it. But I can’t guess what you want unless you tell me using the spec. How big is the spec and how many working programmers do you think are super intimately familiar? Do you think this article would be on the front page if this information wasn't surprising? Are you building a compiler for humans, or are you just chasing metrics and getting the smug satisfaction of telling users "I told you so" when shit doesn't work in an intuitive way? If you want to beat me over the head with "the spec says", you win, master language lawyer. I build things for a living and I like it when the code I specify is the code that's generated. You can blame users all you want, but maybe after the trillionth zero day exploit because nobody gets these things right you might consider empathy and developer ergonomics.
- jmgao 5y ago> I build things for a living and I like it when the code I specify is the code that's generated. Okay, then specify -O0 and enjoy your dumpster fire performance.
- overgard 5y agoTo be fair, it's usually like 5% slower. But I also don't usually have control over the flags if I'm writing a library.
- umanwizard 5y agoI’d be curious to know what benchmarks you’re using on which O0 is only 5% slower. I suspect your program must be almost entirely IO-bound, if this is the case. In that case, Python, Ruby, or shell probably wouldn’t be much slower either.
- overgard 5y agoWriting games, I've rarely seen the optimizer do anything of substantial use.
- SAI_Peregrinus 5y ago-O0 doesn't necessarily change this. After all, optimizations aren't allowed to violate the spec (if they do, they're buggy). So any code that can be output by an optimizing compiler could (in principle) be output by a non-optimizing compiler.
- chrisseaton 5y ago> I like it when the code I specify is the code that's generated But you aren't specifying it! You're asking me to follow extra constraints that you haven't written down and we haven't agreed. Don't you think it's unreasonable when you say it out loud like that? If you want extra constraints on top of what is already agreed in the spec then we can do that, but you have to ask for it and you have to bring me a workable spec. You want me to 'intuit' but really you want me to read your mind and follow a lot of unwritten rules!
- burnished 5y ago'atomic' isn't uncuttable in the sense that it is irreducible, but in the sense that it cannot be stopped/does not produce intermediaries. If you write four atomic instructions you should expect that they will not be interrupted, nothing more. of course I'm not an expert, but I think that is where your misunderstanding has originated.
- overgard 5y ago> 'atomic' isn't uncuttable Well then it's a pretty bad name no? Considering what the word atomic means.
- jcelerier 5y agoDid you even read the post you're replying to. "Uncuttable" can apply to multiple properties of an instruction's execution - "atomic" colloquially refers to one of these properties. You seem to want "atomic" to mean "the data that corresponds to the instruction cannot be divided" but it means "the execution of the instruction cannot be divided", those aren't the same thing.
- burnished 5y agoThe four hardest problems in computer science are cache invalidation, naming stuff, and off by one errors. Please accept that your understanding was flawed and have empathy for the people who named stuff.