News for hackers. Stuff that matters.
Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @06:15PM (#21579398)
Author here, happy for any feedback.

I'll own up to misleading-and-possibly-clickbait title, I just gave up trying to think of anything better without revealing the conclusion.

Re:Clang Format Tanks Performance by gpm on Tuesday November 19, 2019 @08:01PM (#21580151)
I'm going to take the contrarian view here, and say it's not clickbait.

I admit that I'm not a C++ expert, but naively I would never have expected clang-format to have any effect on my code. If you stopped and suggested header re-ordering to me my first thought would have been "I guess it must not do that. Maybe in practice header re-ordering doesn't actually matter with reasonable code?".

The title here doesn't describe the contents of the article, but it describes a very important consequence of it that C++ programmers should be aware of. It gives a specific example of the consequence. I'm ok with that.

Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @08:16PM (#21580232)
I agree with most of that, although as the author I think it's still clickbait in the sense that:

1) clang-format is not really at fault here at all - the same effect could have happened by adding a new header, reordering the headers manually, switching to a system with a different libc version or a different transitive header include tree, etc.

2) The title doesn't tell you wtf is up. You have to get at least half way through the post to figure that out. It's in the vein of "This one food could wreck your health" posts.

That said, other aspects of clickbait are advertising or monetization to profit from the clicks. Except for the crypto mining bot I load into your browser, and which subsequently writes itself to your MBR or UEFI partition, I have no ads, affiliate links, patreon-alikes or other monetization vectors.

Re:Clang Format Tanks Performance by dleslie on Tuesday November 19, 2019 @10:14PM (#21580814)
Of course clang format is at fault; reordering includes, even standard or system includes, will almost certainly effect how a complex C/C++ program compiles. That's just how it is, with the preprocessor and such.

This is a _bad_ clang-format bug.

Re:Clang Format Tanks Performance by sanxiyn on Wednesday November 20, 2019 @02:25AM (#21581788)
You can disable include reordering in clang-format. I don't think this is a bug, because I see the default here as a matter of policy decision.
Re:Clang Format Tanks Performance by HelloNurse on Wednesday November 20, 2019 @09:46AM (#21584310)
Given that reordering includes can have consequences, reordering includes blindly and casually like the OP is a form of Russian roulette: an order that works should be preserved until it stops working.

The article describes false complexity caused by looking atr the issue in the wrong way: a "mysterious" performance problem, to be diagnosed, rather than the obvious consequence of a broken workflow that includes an extremely hazardous operation.

In a voluntary header reordering experiment, all kinds of breakage could be detected with a trivial before and after comparison of compiled code.

Re:Clang Format Tanks Performance by BeeOnRope on Thursday November 21, 2019 @03:35PM (#21599284)
Yes, but reordering the headers is usually safe. Having order-dependent behavior is a serious bug and should generally be fixed by the header authors. When you add a header do you usually carefully consider the interaction between the new header and all the exist ones? No, you just add it to the end of the existing list or at its sorted position? Yeah, me too.

I agree that a formatting tool changing the behavior or performance is a serious issue, but I don't think it's a bug in clang-format in that I suspect it is deliberate design choice, and users can opt out if they want. Maybe the default could be changed or more visible warnings added to the documentation, but the real fix here needs to be in glibc.

Re:Clang Format Tanks Performance by umanwizard on Friday November 22, 2019 @01:39AM (#21603358)
No, I don’t normally think about header order, but if I’m unlucky enough to be getting some weird behavior based on header order, I think I’d be able to debug it before landing my change.

I’d be pissed if the issue were introduced by a formatting pass.

Re:Clang Format Tanks Performance by lilyball on Wednesday November 20, 2019 @03:44AM (#21582182)
Headers really shouldn’t be affecting each other. Header order shouldn’t matter. The fact that it does is arguably a bad design flaw in C/C++, although the C modules system pushed by Apple fixed this.
Re:Clang Format Tanks Performance by pdpi on Wednesday November 20, 2019 @05:18AM (#21582586)
Tooling developers don’t get to say “it shouldn’t matter”. It does matter, so the tools should account for this.
Re:Clang Format Tanks Performance by twic on Wednesday November 20, 2019 @09:41AM (#21584267)
clang-format does account for this: if you break your includes into groups with blank lines, clang-format will sort within but not across the groups. That is, clang-format offers a crude but simple API to the programmer to express which headers have order dependency, and which don't.

Given that headers can have order dependency, it is sadly part of a C++ programmer's responsibility to know which do, just as it is their responsibility to know which functions have side-effects, etc. If they are using clang-format, it is then their responsibility to communicate this knowledge to it.

Re:Clang Format Tanks Performance by dleslie on Wednesday November 20, 2019 @03:08PM (#21587931)
The simplest way to communicate that this anti-feature is unwanted is to add this to your clang-format:

   SortIncludes: false
Re:Clang Format Tanks Performance by pdpi on Wednesday November 20, 2019 @10:47AM (#21584892)
Ok, that is a fairly unobtrusive way to describe dependencies, fair.
Re:Clang Format Tanks Performance by TwoBit on Tuesday November 19, 2019 @11:54PM (#21581196)
That reordering is simply a feature of clang-format. Some coding standards require sorting includes alphabetically, possibly to avoid dupes and to make all include usage identical between source files.
Re:Clang Format Tanks Performance by dleslie on Wednesday November 20, 2019 @12:34AM (#21581342)
In terms of C/C++ headers, that's like requiring all scopes have their expressions alphanumerically sorted.

C/C++ headers are literal code-injection mechanisms; they aren't modifying a runtime environment by importing symbols, they inject code into the compilation unit.

Re:Clang Format Tanks Performance by OskarS on Wednesday November 20, 2019 @04:40AM (#21582430)
> Some coding standards require sorting includes alphabetically

Those are some pretty dumb coding standards if that's true.

(I mean, yeah, the original fault is with the C preprocessor and the fact that header order matters, but since we're stuck with that, having those kinds of coding standards is pretty darn silly!)

Re:Clang Format Tanks Performance by antoinealb on Wednesday November 20, 2019 @08:24AM (#21583658)
Well given that the order of the headers matter, wouldn't it make sense to have the coding standard specify one true include order ? That's the only way to have a deterministic result.
Re:Clang Format Tanks Performance by yifanl on Wednesday November 20, 2019 @08:49AM (#21583828)
That ties namespacing to performance, which just sounds horrible to deal with.
Re:Clang Format Tanks Performance by antoinealb on Wednesday November 20, 2019 @10:58AM (#21584972)
Of course, the bug is horrible. But given that those type of bugs exist, having a fixed ordering of include statements seem like the least painful way to go.
Re:Clang Format Tanks Performance by jlarcombe on Wednesday November 20, 2019 @04:57AM (#21582495)
Indeed, and one reason I dislike sorting header includes alphanumerically is that it makes it easy for include-order-dependencies between them to creep in, as they're always used in the same relative order.
Re:Clang Format Tanks Performance by TehCorwiz on Tuesday November 19, 2019 @09:02PM (#21580482)
At least you’re forthcoming.
Re:Clang Format Tanks Performance by fizwhiz on Wednesday November 20, 2019 @12:37AM (#21581352)
> Except for the crypto mining bot I load into your browser, and which subsequently writes itself to your MBR or UEFI partition

Guess I won't be clicking on the link now.

Re:Clang Format Tanks Performance by skrebbel on Wednesday November 20, 2019 @01:33AM (#21581574)
You're missing out. It's a great article, definitely worth all that monero.
Re:Clang Format Tanks Performance by acemarke on Tuesday November 19, 2019 @06:16PM (#21579413)
Clickbait, but _good_ clickbait :) I do so love good deep technical blog posts that dig into why something works a certain way, and the title is a legit statement based on the initial cause. Thanks for writing this!
Re:Clang Format Tanks Performance by JonathonW on Tuesday November 19, 2019 @07:06PM (#21579807)
Just to make sure I'm understanding this correctly: the performance issue you found actually amounts to include-order dependent behavior in GCC and glibc; clang doesn't really have anything to do with anything here except that you used its code formatter to sort your include statements.

If that's the case, the clickbait-y headline's bordering on useless, since the performance differences here have nothing to do with clang itself-- you'd see the same results if you had ordered your includes the same way by hand.

Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @07:40PM (#21580024)
I'm talking about clang-format, a formatting tool for C and C++ code, which has nothing to do with compiling your code with clang. You can use it with any compiler.

That said, the title is still a lie in that clang-format is not really at a fault here at all: clang-format triggered the issue on my codebase, by sorting header files, and this in turn triggered a libc performance issue.

So as I initially say it, a commit which purely clang-format 'd my codebase caused a massive regression - but the full story is doesn't implicate clang-format at all, really.

Re:Clang Format Tanks Performance by glandium on Tuesday November 19, 2019 @08:01PM (#21580154)
The title would be a /little/ clearer with a dash between Clang and format.
Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @09:02PM (#21580478)
Good point, I put a hyphen a few places but not everywhere nor in the title. It seems hyphen is definitely the standard though.

Fixed now [1], although the HN title will remain hyphen-free free I guess.

---

[1] https://github.com/travisdowns/travisdowns.github.io/commit/...

Re:Clang Format Tanks Performance by ndesaulniers on Tuesday November 19, 2019 @08:06PM (#21580179)
Or "header inclusion order may affect performance." If someone points to this as a reason not to use clang-format...
Re:Clang Format Tanks Performance by dleslie on Tuesday November 19, 2019 @10:17PM (#21580829)
clang-format reordering includes is a terrible behaviour. It would break many C/C++ projects.
Re:Clang Format Tanks Performance by glandium on Tuesday November 19, 2019 @10:48PM (#21580931)
It's optional, although it's enabled by default in the LLVM and Chromium styles.
Re:Clang Format Tanks Performance by dleslie on Tuesday November 19, 2019 @11:12PM (#21581022)
That's a bizarre optional feature to have; it's tantamount to having a "blindly reorder logic" function that sorts your source alphanumerically.
Re:Clang Format Tanks Performance by defap on Wednesday November 20, 2019 @12:00AM (#21581225)
Not really too bizarre. Header files should include or declare everything they need; they should not introduce include-order dependencies. Listing your includes in lexicographic order is a good way to enforce header completeness.
Re:Clang Format Tanks Performance by dleslie on Wednesday November 20, 2019 @12:32AM (#21581330)
It is by convention that C/C++ headers rely on preprocessor state to determine what blocks to reveal, macros to use, et al.

It is quite common to have an auto-generated configuration header, for instance; or a precompiled header; or optional headers that, when present, mutate the behaviour of other headers.

Every time you run a configure script for a C project there's a good chance you're interacting with code in this way.

Re:Clang Format Tanks Performance by lorenzhs on Wednesday November 20, 2019 @05:15AM (#21582574)
Yeah, and if you want to use clang-format include reordering in such a project, you should read the docs for clang-format's "IncludeCategories". It allows you to separate your includes into blocks by providing regexes and associated priorities. Alphabetic sorting is done only within a block.

It's not like clang-format was written by idiots who never used the language before. Maybe read up on what the tool actually does before you get all mad at them?

Re:Clang Format Tanks Performance by dleslie on Wednesday November 20, 2019 @09:38AM (#21584250)
I'm not mad?

I think it's a harmful anti-feature that's worthy of criticism.

Re:Clang Format Tanks Performance by glandium on Wednesday November 20, 2019 @12:35AM (#21581344)
clang-format still allows some ordering when the SortIncludes feature is enabled. Search for IncludeBlocks in https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Re:Clang Format Tanks Performance by daemin on Wednesday November 20, 2019 @08:34AM (#21583727)
One other ordering I've encountered which helps remove errors is to list the headers in reverse generic order. Meaning that you go from the most specific header files to the least specific. So <algorithm> and <windows.h> would be getting included last.

This helps ensure that your specific project level header files have all the necessary forward declares and includes to be a fully functioning and complete header.

Re:Clang Format Tanks Performance by craftinator on Wednesday November 20, 2019 @08:15PM (#21590527)
I also sort my includes this way. The trouble is, determining how generic an include (inclusion?) is is a fuzzy problem. Sometimes I get stuck trying to figure out which header is more abstract, and at times I've run into side effects like this even with reverse generic sorting.
Re:Clang Format Tanks Performance by daemin on Thursday November 21, 2019 @06:03AM (#21593014)
Yeah, this header sorting is only meant to be a tool to help craft header files which are independent. If that's not your project structure then you can use whatever sorting you want.

In the end though you'll have to make a decision on how to sort the projects and which one is more or less specific than another. Kind of like deciding to just sort by pointer address if all else is equal.

Re:Clang Format Tanks Performance by big_chungus on Tuesday November 19, 2019 @07:36PM (#21580000)
No, the headline pretty clearly states "Clang Format". I've used clang-format on MSVC codebases, and imagine there are some who use it with GCC (say, for instance, the author). It's still the best C++ formatter, as far as I know, and is compiler-independent.
Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @07:42PM (#21580038)
It's basically the gorilla in the space, and it's good.

There is no gcc equivalent. In any case there no 1:1 relationship between formatters anyways: you might compiler you codebase with N compilers, but you'll only have one formatter unless you are insane. So my codebases are not "gcc" or "clang" codebases, but basically "linux" codebases - but the formatter is always clang-format.

Re:Clang Format Tanks Performance by twic on Wednesday November 20, 2019 @09:47AM (#21584323)
It would actually be interesting to see if this phenomenon happens with clang, which has its own implementation of the standard library. And perhaps with musl libc or some such.
Re:Clang Format Tanks Performance by BeeOnRope on Thursday November 21, 2019 @05:21PM (#21600366)
Clang has its own libc++ implementation, but I think clang still uses the system libc and associated headers?
Re:Clang Format Tanks Performance by twic on Friday November 22, 2019 @06:07AM (#21604546)
Yes, i think so too. So a different <algorithm>, but the same <ctype.h>.

The crucial __NO_CTYPE define is in <bits/os_defines.h>, which is part of the GCC paraphernalia. I don't know if clang's stdlib would also have to end up defining it.

Re:Clang Format Tanks Performance by iameli on Tuesday November 19, 2019 @08:34PM (#21580335)
I clicked because of the title and laughed when I read the reason, don't sweat about anyone accusing you of clickbait
Re:Clang Format Tanks Performance by Someone on Tuesday November 19, 2019 @06:25PM (#21579477)
clang format can tank performance” would, IMO, not decrease the number of people who click the link, yet remove the clickbait.
Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @06:43PM (#21579632)
Could be, but I feel it would equally dishonest?

This really has nothing to do with clang-format: I only mention that once (twice with an update: where clang format actually helps because it reorders stdlib.h after ctype.h) - it's all about header include order.

Re:Clang Format Tanks Performance by mipmap04 on Tuesday November 19, 2019 @08:06PM (#21580173)
Maybe someone should make a tool that randomly reorders your header includes until optimal performance is found.
Re:Clang Format Tanks Performance by emmelaich on Tuesday November 19, 2019 @09:41PM (#21580658)
I think clang-format is definitely relevant; the take-away here is that no formatter should change the order of includes.

I was wondering about this only yesterday - tidying up some C++ and C code. I don't remember any standard that says it's OK to re-order headers, and clearly it can matter a lot.

Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @09:43PM (#21580671)
That wouldn't be my take away.

My takeway would be anything that changes in semantics or performance due to header includes should be considered a bug by the (possibly joint) writers of the involved headers.

clang-format is an innocent victim here. Maybe I should make that clearer.

Re:Clang Format Tanks Performance by flukus on Tuesday November 19, 2019 @10:05PM (#21580772)
Clang isn't the root cause, but as a (relatively) new tool in an existing ecosystem it needs to work with the existing ecosystem and not some imaginary idealistic world.
Re:Clang Format Tanks Performance by mypalmike on Wednesday November 20, 2019 @01:21PM (#21586704)
Changing semantics due to header order is considered a feature in C/C++. If you aren't willing to waste hours working through esoteric header issues, you just aren't tough enough.
Re:Clang Format Tanks Performance by BubRoss on Tuesday November 19, 2019 @06:30PM (#21579519)
Why does every title have to be a mystery? Why not tell people what it contains?
Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @06:46PM (#21579663)
In this case it's an excerpt of a larger post that I was writing while I ran into this.

I don't think there is a good single-sentence title that would encapsulate the whole thing without being an already well-known fact, like say "Header include order matters".

Also, I wrote this one as a narrative, not revealing the conclusion at the start - basically a reconstructed version of how I encountered it myself. I don't write all my posts like that and it's not for everyone: but once I've decided on that, it makes no sense to reveal the conclusion in the title, I think?

The HN headline could be changed though if it places a priority on information-full titles.

Re:Clang Format Tanks Performance by pvg on Tuesday November 19, 2019 @06:59PM (#21579765)
It places priority on not-clickbait, above most things. You could have a title that isn't super descriptive, asks a question, maintains an air of mystery, whatever. But a title that deliberately elevates some near-irrelevant detail for attention is purposefully deceptive and, well, less than good (by HN's rules, that is).
Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @07:08PM (#21579825)
Eh, sure - but you are arguing for non-clickbait titles, while I was replying to the OP who complained about not revealing more about the conclusion in the title. It seems we agree there that some mystery is allowed: the point of contention is on "click-baitiness".

I don't have a similar principled defense of clickbait titles, either in general or mine specifically! I just thought it was a funny one and didn't expend more effort on coming up with a non-clickait one.

That's an independent issue from revealing more info in the title.

Re:Clang Format Tanks Performance by pvg on Tuesday November 19, 2019 @07:12PM (#21579857)
Oh, I don't really have any argument about what titles you should put on your own writing. It's your writing, if you feel its narrative purpose is served by an intricate web of title feints, line noise, whatnot, more power to you.

I'm just explaining the HN title rules, you can see them here (do a find title):

https://news.ycombinator.com/newsguidelines.html

There's nothing in there about titles having to be 'information-full'. Lots of perfectly HN-good titles aren't.

Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @07:54PM (#21580115)
Got it, I didn't understand you were talking about HN titles, rather than the blog post title.

I didn't submit it to HN so I can't comment on the title choice, other than say it at least reflects the literal title of the page which I guess would be the default when submitting.

I tend to outsource my comments to HN, since my blog is a github pages static site and introducing comments without tracking and ads is a pain, but I definitely don't choose my post titles to satisfy HN rules.

Re:Clang Format Tanks Performance by pvg on Tuesday November 19, 2019 @08:08PM (#21580189)
Right, technically, fixing the title in this case would have been on the poster. Then there'd probably be a long subthread about why the title was changed so drastically. Title-lawyering is a professional metasport around here, as has been amply demonstrated.
Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @10:47PM (#21580927)
Grabs popcorn :).
Re:Clang Format Tanks Performance by rdc12 on Wednesday November 20, 2019 @02:10AM (#21581725)
Pretty much the HN version of nerd sniping.

https://xkcd.com/356/

Re:Clang Format Tanks Performance by hombre_fatal on Tuesday November 19, 2019 @10:44PM (#21580916)
So that you can't just respond to the title.
Re:Clang Format Tanks Performance by pydave on Tuesday November 19, 2019 @07:08PM (#21579824)
> Are my standard algorithms letting me down? Does std::transform have some fatal flaw? Not really. Well, not at all.

This part lost me because I can't see how you can use std::transform (which is in <algorithm>) without hitting this flaw. Unless you edit the headers? I guess you mean the algorithm isn't flawed.

I also didn't understand the title because I don't use clang-format and I skimmed past the single mention of it (my fault).

Regardless, interesting post.

Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @07:50PM (#21580091)
The title was basically clickbait.

It reflects how I encountered the issue, but the investigation doesn't have much of that, because I was starting from a point where I suddenly had a slow and fast algorithm (the actual scenario was more complicated than shown).

The investigation doesn't have much to do with clang-format because I'm just trying to see why a raw loop is faster, and ultimately has nothing to do with "raw" vs "std" at all, really. Only when I understood that includes and include order matter was I able to map it back to a header order swap made by clang-format.

> This part lost me because I can't see how you can use std::transform (which is in <algorithm>) without hitting this flaw.

No, two ways.

You can get the fast performance with std::transform if you happen to include <ctype.h> before <algorithm>. The order matters.

Similarly, you can get the slow performance with a raw loop if you happen to include <algorithm> before <ctype.h> in the file for the raw loop.

In fact, I'd say that the raw loop and std::transform will have the same performance almost all the time. If they are in the same file, they will have the same performance. If they are in a C++ file, you are almost certainly including some C++ header that triggers the issue. Only in special cases, like a coding convention that separates C and C++ headers with whitespace with C first (clang-format doesn't sort headers separated by whitespace) are you likely to come into it "natively".

Even if you do, it's absolutely no fault of std::transform or <algorithm> - it's a weird effect of interaction between C, C++ and OS headers, nothing inherent to the C++ algorithms.

Re:Clang Format Tanks Performance by slavik81 on Wednesday November 20, 2019 @02:31AM (#21581824)
I bet the performance would look different in a real program anyways. The random input data probably results in more branch predict misses than would occur in normal text, and the tight loop of the benchmark basically ensures the lookup table is always in cache.
Re:Clang Format Tanks Performance by BeeOnRope on Thursday November 21, 2019 @05:29PM (#21600434)
Definitely, but I think it's unlikely that it will close the gap much between the fast and slow std::toupper() compilations (my own toupper is mostly just in there as an interesting reference point).

In addition to more instructions and a function call, the slow version has many more memory dereferences, so if everything is very cold it is likely to suffer more misses.

Re:Clang Format Tanks Performance by TwoBit on Tuesday November 19, 2019 @11:57PM (#21581206)
A disagree with your conclusion that the slowness doesn't matter. If it doesn't matter to anybody then why does the optimized version even exist?

IMO this is a library bug. <algorithm> shouldn't be limping toupper or anything else.

Re:Clang Format Tanks Performance by BeeOnRope on Thursday November 21, 2019 @05:32PM (#21600461)
The conclusion near the end of the blog post?

That's not really because performance doesn't matter, but because toupper() shouldn't really matter in most modern C and C++ programs: it just can't support Unicode. So either you are using a different way of supporting strings entirely (if you need any kind of Unicode or multibyte support), or this is some internal ASCII-only text processing in which case you are better off using your own methods (e.g., the lookup table I mention at the end) since they'll provide an easy speedup and you aren't accidentally introducing locale-dependent code where you don't want it.

Re:Clang Format Tanks Performance by jimbo1qaz on Tuesday November 19, 2019 @11:50PM (#21581181)
I read the title and thought the article was about (clang-format's performance) on a (program simulating military tanks)... Apparently you meant "tanks" as a verb...
Re:Clang Format Tanks Performance by BeeOnRope on Thursday November 21, 2019 @05:33PM (#21600473)
Yes, although a quick search reveals that Oxford considers this a US usage so it was probably not the ideal choice for a title.
Re:Clang Format Tanks Performance by fyp on Tuesday November 19, 2019 @07:20PM (#21579901)
The "three observations that aren’t really part of the story" were really interesting and doesn't seem to be fully resolved. Will you be discussing them more in the future post?
Re:Clang Format Tanks Performance by BeeOnRope on Tuesday November 19, 2019 @07:36PM (#21579999)
Maybe.

This is really a three part answer, since there were three quite-different effects I glossed over.

The first one is interesting, but it is also well-covered elsewhere, e.g., [1], [2] and [3]. That said, I have a ton of stuff to say on branch prediction, so I probably will at some point. Those posts are slow going, however. It may never emerge.

For the second and third points, I am partly blocked by the fact the effect disappeared or is only intermittently reproducible.

I am more interested in the third uninteresting effect than the second. The second thing could be a lot of things, since it shows up when running a python script with results piped to disk. What I've seen in the past is that the "driver" program (driver.py) undergoes some kind of phase change, e.g., suddenly causing a bunch of context switches or allocating/freeing a munch of memory which affects the program under test (despite CPU pinning, since there are shared resources). They are phantoms (but still interesting!).

The third one is very interesting to me, because it involves a CPU-bound loop with only L1 hits. It goes to the core of the Skylake uarch and the kind of fine-grained uarch details I'm interested in. However, it disappeared as I was tracking it down. I was getting a mix of 2.07 cycles and 1.57 cycles (slow and fast) running the benchmark repeatedly, trying differnet perf counters and doing the needful to track it down and then suddenly I only got 2.07. A new plot showed "blue" only at ~2.07. So I don't know. I have seen similar things though, and I've tracked down an similar "mode shift" and will post on it soon. Stay tuned.

---

[1] https://lemire.me/blog/2019/11/12/unrolling-your-loops-can-i...

[2] https://lemire.me/blog/2019/10/16/benchmarking-is-hard-proce...

[3] https://lemire.me/blog/2019/10/15/mispredicted-branches-can-...