WTF Bites
-
@HardwareGeek said in WTF Bites:
If your code is larger, you're going to cache-miss more
This is 2021. HelloWorld.exe is 10GB, anyway.
.exe? Did you mean .js?
-
@HardwareGeek said in WTF Bites:
checking the overflow bits screws with OoOE and branch prediction
Optimize for the normal path, and let exception-handling performance suck, because it will anyway. But I'll admit I don't know much about how the hardware does branch prediction (CPU architectures, at least non-trivial ones, are outside my hardware wheelhouse). Are there ways the compiler can tell the hardware which path to predict?
I was recently pointed to a blog about gcc's undefined behaviour sanitiser. Apart from (signed) overflow that also checks for out-of-bounds array accesses, unaligned pointer accesses, and some other things. The stated performance penalty is 2 to 3 times; I don't recall how much slower my actual test run was.
-
@PleegWat ooh now add gc
-
Just noticed in my calendar:
The 1st day of heritage month is on the 15th?
-
Just noticed in my calendar:
The 1st day of heritage month is on the 15th?
Damn straight. You'll find out what an April Fool is. You'll all find out.
-
Just noticed in my calendar:
The 1st day of heritage month is on the 15th?
And it lasts for two full days.
-
@PleegWat well it's a very dominating culture
-
But you have to test it after every single arithmetic instruction, or it gets cleared again. That’s a lot of branches everywhere.
Not as many as all that; a lot of cases are optimisable, such as when you know you're counting up in steps of 1 from a small non-negative number to an effectively-constant positive value. That case is extremely common. The other common use of arithmetic is doing stuff like struct or array accesses, where again you assume no overflows (or, in the case of Java, have explicit checks every time unless you can prove elsewhere that you don't need to). It's rare that you have code where things can actually overflow (and that's when you put the conditional jumps in for the unhappy path).
It's easy to forget to do this if you're doing hand code generation. It's extremely easy to get it right if you are compiling. (Heck, you might even use a virtual instruction that does the arithmetic op and threads to the next basic block depending on overflow status.) It's not really more difficult than dealing with any other status flag bit.
-
the CPU now has to remember the status after OoO instruction so it can be checked on a branch instruction
I'm not sure why the CPU would need special support for branching on an out-of-office status, but I'm sure it's very useful to Microsoft for optimising Outlook.
-
@dkf I thought it was self-explanatory why executing out-of-office resources is more expensive than in-office.
-
@Gąska Duh, you have to send the executioner to find the resource. In office, a little ricin will execute all the resources at once.
-
@HardwareGeek "ricin" in Polish is "rycyna", which is very close to "rycina", which means "a chart on a presentation slide". A very appropriate execution method.
-
.exe? Did you mean .js?
Nope. You forgot about the Electron wrapper around that piece of JS
-
But I think branch prediction isn't as much of an issue as OoOE. If you don't check status flags, you don't have to save status flags for reference later. When you start checking, the CPU now has to remember the status after OoO instruction so it can be checked on a branch instruction. I'm not well versed in modern CPU architecture, but one thing is for sure - there is limited memory available for saving those flags, so code without checks can execute more instructions out of order than code with checks,
Another thing is code size, and with that, cache utilization. If your code is larger, you're going to cache-miss more, and that can lead to significant performance penalties.Checking for overflow might not mix well with SIMD instructions, either.
-
@HardwareGeek "ricin" in Polish is "rycyna", which is very close to "rycina", which means "a chart on a presentation slide". A very appropriate execution method.
So you mean that in Polish, death-by-Powerpoint is a real thing?
-
@Zerosquare does dying inside count?
-
If it did, all of us would be ghosts.
-
When you start checking, the CPU now has to remember the status after OoO instruction so it can be checked on a branch instruction. I'm not well versed in modern CPU architecture, but one thing is for sure - there is limited memory available for saving those flags, so code without checks can execute more instructions out of order than code with checks,
Agner has some interesting numbers for modern Ryzens regarding this (see 22.8). Each core has
The integer register file has 192 physical registers of 64 bits each. The floating point register file has probably 160 vector registers of 256 bits each.
The schedulers include a reorder buffer of 256 μops, according to AMD documentation. Eight integer μops and six floating point/vector μops can be scheduled per clock cycle.So reordering takes place across ~256µops, which seems around average (Skylake apparently has 224 entries, with 180 integer registers and 168 vector registers).
I didn't find explicit mention of how CPU flags are handled, other than that flags registers can be renamed too. With all that's going on (scheduling to EUs, dependency tracking, branch prediction and speculative execution), I don't think that storing the extra flags is a huge deal. IIRC, as part of the speculative execution, the whole resulting state of the instruction is computed and checked against previous assumptions upon retirement, which in some cases needs execution to roll back to an earlier state and resume from there.
On the other hand, branching after each arithmetic instruction not only introduces the extra instructions in question, but those instructions are dependent on each other. And they will take space in the reorder buffer, meaning that fewer independent operations are available for scheduling.
On the third hand, Agner's huge-ass PDF also mentions the following (11.6 Macro-op fusion):
The CMP, ADDand SUB instructions can fuse with signed and unsigned branch instructions. INC and DEC can fuse with signed branch instructions, and TEST and AND instructions can fuse with all branch instructions (including useless combinations), as indicated in table 9.2page 126.
This eliminates the problem in a lot of common cases, where something like
ADD
followed by a branch is fused into a single µop. The whole problem of transporting flags goes away to some degree (as does the pollution of the reorder buffer). The downside seems to be that there are fewer EUs that can handle branches (which I guess the resulting µup counts as -- there's just 1 in Skylake per core) than those that can handle general integer arithmetic (2-4 EUs, depending on type of instruction). So there's some overhead to that.
-
@BernieTheBernie said in WTF Bites:
when you use LINQ, structures
Exactly: the performance penalty lies else where. The costs of overflow checking are nothing in comparison to that.
For most programs. Overflow is rare, and reasonably predictable.
Haha, no. Actually that's a never ending source of security holes in C{,++}. You get a buffer offset from your caller, do some math with it, and make sure your result isn't greater than
sizeof(buf)
because you're prudent and wouldn't want to return stuff past your end of buffer. Then someone hands youINT_MAX - a_little
and you leak your private keys from somewhere in the program.
-
@BernieTheBernie said in WTF Bites:
when you use LINQ, structures
Exactly: the performance penalty lies else where. The costs of overflow checking are nothing in comparison to that.
For most programs. Overflow is rare, and reasonably predictable.
Haha, no. Actually that's a never ending source of security holes in C{,++}. You get a buffer offset from your caller, do some math with it, and make sure your result isn't greater than
sizeof(buf)
because you're prudent and wouldn't want to return stuff past your end of buffer. Then someone hands youINT_MAX - a_little
and you leak your private keys from somewhere in the program.User input... that's different
-
@BernieTheBernie said in WTF Bites:
when you use LINQ, structures
Exactly: the performance penalty lies else where. The costs of overflow checking are nothing in comparison to that.
For most programs. Overflow is rare, and reasonably predictable.
Haha, no. Actually that's a never ending source of security holes in C{,++}. You get a buffer offset from your caller, do some math with it, and make sure your result isn't greater than
sizeof(buf)
because you're prudent and wouldn't want to return stuff past your end of buffer. Then someone hands youINT_MAX - a_little
and you leak your private keys from somewhere in the program.User input... that's different
At some point, all input is user...
-
@BernieTheBernie said in WTF Bites:
when you use LINQ, structures
Exactly: the performance penalty lies else where. The costs of overflow checking are nothing in comparison to that.
For most programs. Overflow is rare, and reasonably predictable.
Haha, no. Actually that's a never ending source of security holes in C{,++}. You get a buffer offset from your caller, do some math with it, and make sure your result isn't greater than
sizeof(buf)
because you're prudent and wouldn't want to return stuff past your end of buffer. Then someone hands youINT_MAX - a_little
and you leak your private keys from somewhere in the program.User input... that's different
Don't smell that argument¹, you don't know where it's been.
¹ Neither yours nor my function's
-
@BernieTheBernie said in WTF Bites:
when you use LINQ, structures
Exactly: the performance penalty lies else where. The costs of overflow checking are nothing in comparison to that.
For most programs. Overflow is rare, and reasonably predictable.
Haha, no. Actually that's a never ending source of security holes in C{,++}. You get a buffer offset from your caller, do some math with it, and make sure your result isn't greater than
sizeof(buf)
because you're prudent and wouldn't want to return stuff past your end of buffer. Then someone hands youINT_MAX - a_little
and you leak your private keys from somewhere in the program.User input... that's different
Don't smell that argument¹, you don't know where it's been.
¹ Neither yours nor my function's
Point is you either have bounded inputs, or the problem is the inputs, in most cases.
-
-
@TimeBandit Why are you using Bing in the first place?
-
@TimeBandit said in WTF Bites:
What about "man tank", or "Tank-Man", or with quotes?
Seems to work fine on mobile. Maybe that's different. Maybe this is glurge. Maybe some reporter hit a transient error and wrote a story. Who knows.
-
-
A Microsoft spokesperson told Motherboard in an email that "This is due to an accidental human error and we are actively working to resolve this."
-
@Zerosquare Yeah, right.
-
Well, censoring the results everywhere is probably a genuine human error.
-
@Zerosquare said in WTF Bites:
This is due to an accidental human error
They filter results by hand?
With the amount of search trafic they get, it's plausible
-
Mark saying find and terminate sent a shiver up my spine.
-
@HardwareGeek said in WTF Bites:
@TimeBandit Why are you using Bing in the first place?
At some point DDG wasn't showing image results for "tank man" either, even with safe search off. But I see it is showing results now.
-
Mark saying find and terminate sent a shiver up my spine.
To be fair, when confidential stuff leaks, pretty much any company is going to try to find who's responsible for that and fire them. The problem isn't really that part ; it's that Facebook wants to hide really nasty stuff, and that they're hypocrites.
-
@Zerosquare said in WTF Bites:
Mark saying find and terminate sent a shiver up my spine.
To be fair, when confidential stuff leaks, pretty much any company is going to try to find who's responsible for that and fire them. The problem isn't really that part ; it's that Facebook wants to hide really nasty stuff, and that they're hypocrites.
Yeah but whenever a robot says stuff like that it hackles biological human spines.
-
@HardwareGeek said in WTF Bites:
@TimeBandit Why are you using Bing in the first place?
At some point DDG wasn't showing image results for "tank man" either, even with safe search off. But I see it is showing results now.
Doesn't duck duck go use bing behind the scenes?
-
@HardwareGeek said in WTF Bites:
@TimeBandit Why are you using Bing in the first place?
At some point DDG wasn't showing image results for "tank man" either, even with safe search off. But I see it is showing results now.
Doesn't duck duck go use bing behind the scenes?
No, the statement you were responding to was a non sequitur and common knowledge has all been invalidated.
-
@HardwareGeek said in WTF Bites:
@TimeBandit Why are you using Bing in the first place?
At some point DDG wasn't showing image results for "tank man" either, even with safe search off. But I see it is showing results now.
Doesn't duck duck go use bing behind the scenes?
You know, they don't actually say...
-
@Tsaukpaetra said in WTF Bites:
@HardwareGeek said in WTF Bites:
@TimeBandit Why are you using Bing in the first place?
At some point DDG wasn't showing image results for "tank man" either, even with safe search off. But I see it is showing results now.
Doesn't duck duck go use bing behind the scenes?
You know, they don't actually say...
They don't? Maybe they threw a few more in the mix.
-
@HardwareGeek said in WTF Bites:
@TimeBandit Why are you using Bing in the first place?
Duck Duck Go uses Bing.
-
Another day of having to use MS Teams:
-
@topspin I don't see a problem.
-
-
Things that remind you of WDTWTF members:
I'm going to become rich and famous after i invent a device that allows you to stab people in the face over the internet
I would definitely buy one of those.
-
@boomzilla said in WTF Bites:
@HardwareGeek said in WTF Bites:
@TimeBandit Why are you using Bing in the first place?
Duck Duck Go uses Bing.
According to this article:
"Some of the search results are pulled in from Bing, while others are populated from Apple Maps, Wikipedia, Wolfram Alpha, etc. It’s estimated that they use over 400 sources in total to populate their data."
400 sources, and yet, my experience has been that DuckDuckGo returns worse search results than Google. In fact, the article I linked to even says that:
"If you want the best search results, then use Google. "
-
my experience
: it's because they don't know with anything about you and so provide an untailored experience. Here at Google, we provide you with what you actually want!
-
@Tsaukpaetra said in WTF Bites:
my experience
: it's because they don't know with anything about you and so provide an untailored experience. Here at Google, we provide you with what you actually want!
Exactly. There's a lot of information out there and a good search engine isn't gonna waste your time showing you something you won't like.
-
@El_Heffe if your target users were a bunch of privacy nerds instead of general population, would you care about quality of search results?
Same reason why virtually all programming tools have the worst UX imaginable.
-
@El_Heffe if your target users were a bunch of privacy nerds instead of general population, would you care about quality of search results?
Same reason why virtually all programming tools have the worst UX imaginable.
Hey watchit,
vim
has optimal UX.
-
Same reason why virtually all programming tools have the worst UX imaginable.
You should see just how bad tooling used to be!