News for hackers. Stuff that matters.
Re:Strobelight: A profiling service built on open source tec... by varunneal on Friday March 07, 2025 @10:32AM (#43290960)
Cool anecdote from inside article

> A seasoned performance engineer was looking through Strobelight data and discovered that by filtering on a particular std::vector function call (using the symbolized file and line number) he could identify computationally expensive array copies that happen unintentionally with the ‘auto’ keyword in C++.

> The engineer turned a few knobs, adjusted his Scuba query, and happened to notice one of these copies in a particularly hot call path in one of Meta’s largest ads services. He then cracked open his code editor to investigate whether this particular vector copy was intentional… it wasn’t.

> It was a simple mistake that any engineer working in C++ has made a hundred times.

> So, the engineer typed an “&” after the auto keyword to indicate we want a reference instead of a copy. It was a one-character commit, which, after it was shipped to production, equated to an estimated 15,000 servers in capacity savings per year!

Re:Strobelight: A profiling service built on open source tec... by JoshTriplett on Friday March 07, 2025 @10:33AM (#43290970)
It's a cool anecdote. It's also a case study in heavyweight copies being something that shouldn't happen by default, and should require explicit annotation indicating that the engineer expects a heavyweight copy of the entire structure.
Re:Strobelight: A profiling service built on open source tec... by mhlakhani on Friday March 07, 2025 @10:47AM (#43291109)
I don’t know if that would have helped here, if memory serves me right:

1. The copy was needed initially 2. This structure wasn’t as heavy back then

… over time the code evolved so it became heavy and the copy became unnecessary. That’s harder to find without profiling to guide things

Re:Strobelight: A profiling service built on open source tec... by ehsankia on Friday March 07, 2025 @11:32AM (#43291569)
If it's safety/correctness versus performance, I think the default should be the former. Copying, while inefficient is generally more correct and avoids hard-to-debug errors. It's the whole discussion about premature optimization. I'd rather make a copy than make sure the array is not mutated anywhere ever.
Re:Strobelight: A profiling service built on open source tec... by ltbarcly3 on Friday March 07, 2025 @11:36AM (#43291602)
Yes, everyone agrees with you. The claim you responded to was that you should have to be explicit, because it is very easy to unintentionally copy. For example, it is easy to copy when there is never more than one live pointer to a datastructure. It's easy to copy when you allocate a resource in a function and return it, which makes the original an orphan which is then immediately freed. It's extremely easy to make a mistake which prevents move from working and you have to go back and carefully check if you want to be sure. It should be trivial to just say "move this" and if something isn't right it's an error at compile time, rather than just falling back to silently being wasteful.
Re:Strobelight: A profiling service built on open source tec... by umanwizard on Friday March 07, 2025 @12:22PM (#43292038)
This exact problem is basically why Rust exists.
Re:Strobelight: A profiling service built on open source tec... by JoshTriplett on Friday March 07, 2025 @01:25PM (#43292698)
I'm not saying it should silently alias any more than it should silently copy. It should give an error, and require the developer to explicitly copy or explicitly alias.
Re:Strobelight: A profiling service built on open source tec... by mhlakhani on Friday March 07, 2025 @10:40AM (#43291032)
That one diff blew my mind when I saw it. It’s a prime example of that story about “you paid me a lot of money to know where to fix that pipe”
[dead]
Re:Strobelight: A profiling service built on open source tec... by vosper on Friday March 07, 2025 @11:28AM (#43291538)
Tired vote-bait quote.
Re:Strobelight: A profiling service built on open source tec... by Bjartr on Friday March 07, 2025 @11:34AM (#43291584)
Only because the Overton window has shifted enough to normalize it.
Re:Strobelight: A profiling service built on open source tec... by howlallday on Friday March 07, 2025 @01:39PM (#43292875)
Imagine how much server capacity we could save if we didn't waste the equivalent electrical consumption of Belgium convincing your mother she needs more garbage from Temu.
Re:Strobelight: A profiling service built on open source tec... by phyrex on Friday March 07, 2025 @06:59PM (#43296146)
And then how would we pay for that server capacity?
Re:Strobelight: A profiling service built on open source tec... by howlallday on Friday March 07, 2025 @01:39PM (#43292880)
>The best minds of my generation are thinking about how to make people click ads. — Jeff Hammerbacher