Live data from Hacker News

Clang Format Tanks Performance

travisdowns.github.io

11–20 of 156 posts

Re: Clang Format Tanks Performance

#11
post #5

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.

clang format can tank performance” would, IMO, not decrease the number of people who click the link, yet remove the clickbait.

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

#12
post #7

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.

Why does every title have to be a mystery? Why not tell people what it contains?

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

#13

You also get the slow version if you include instead of . https://godbolt.org/z/cbeGc4

Yes, I saw that too and mention it:

> As a corollary, if you include rather than (the C++ version of the C header which puts functions in the std:: namespace) you also get the slow behavior because ultimately includes .

Re: Clang Format Tanks Performance

#14
post #7

Earlier quoted context omitted.

Why does every title have to be a mystery? Why not tell people what it contains?

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 w…

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

#16
post #6

Can the std::transform version be written without a lambda? std::transform(buf, buf + size, buf, toupper);

Yes, it can!

In fact I had that at some point and clobbered it with a git reset (the perils of developing on two machines and once and using git a sync mechanism).

Fixed [1] and credited.

---

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

Re: Clang Format Tanks Performance

#17

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.

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

#18

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.

> 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 ) 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

#19
post #14

Earlier quoted context omitted.

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 w…

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).

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

#20
post #14

Earlier quoted context omitted.

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).

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…

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.

Post reply on HN