
Hotspot Performance Engineering Fails
Developers often believe that software performance follows a Pareto distribution: 80% of the running time is spent in 20% of the code. Using this model, you can write most of your code without any care for performance a…
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
Developers often believe that software performance follows a Pareto distribution: 80% of the running time is spent in 20% of the code. Using this model, you can write most of your code without any care for performance and focus on the narrow pieces of code that are performance sensitive. Engineers like Casey Muratori have rightly criticized this model. You can read Muratori’s excellent piece on his blog.
It is definitively true that not all of your code requires attention. For example, it is possible that 99% of the time, your code processes correct data. The code that handles errors could be quite slow and it would not impact most of your users.
But the hotspot predicts something more precise: you should be able to just keep all of your code, identify the specific bottlenecks, optimize these bottlenecks, and then get great performance all around. Muratori relies on empirical evidence to falsify the model: many companies embarked on large rewrites of their codebase to optimize it. Why bother with such expenses if they could simply identify the bottlenecks and fix those?
We have tools today called profilers that can tell you roughly where your software spends its time. And if you apply such a tool to your software, you may indeed find massive bottlenecks. It may sometimes work wonders. For example, there was a video game (GTA Online) that was loading a JSON file. Simply optimizing this one bottleneck solved a massive performance issue. It did not make the game more performant, but it made it start much faster. So bottlenecks do exist. We should hunt them down and optimize them. But that’s not what the hotspot model predicts: it predicts that it is all you need to do to get performance. Hit a few bottlenecks and you are done.
Sadly, it does not work. To illustrate, let us look at how the very popular SQLite project got to be 50% faster:
The latest SQLite 3.8.7 alpha version is 50% faster than the 3.7.17 release from 16 months ago. That is to say, it does 50% more work using the same number of CPU cycles. This is 50% faster at the low-level grunt work of moving bits on and off disk and search b-trees. We have achieved this by incorporating hundreds of micro-optimizations. Each micro-optimization might improve the performance by as little as 0.05%. If we get one that improves performance by 0.25%, that is considered a huge win. Each of these optimizations is unmeasurable on a real-world system but if you do enough of them, they add up.
Why did they have to add up hundreds of micro-optimizations instead of simply finding the one function that uses 80% of the running time?
The effort needed to optimize code grows exponentially. In other words, to multiply the performance by N, you need 2N optimizations. The more you optimize, the more code you must consider. It is relatively easy to double the performance of an unoptimized piece of code, but much harder to multiply it by 10. In effect, we have a long tail effect: though there are clearly easy wins, much of the work lies in the ‘tail’. In effect, you end up winning by continually adding small optimizations.
Further content: Federico Lois — Patterns for high-performance C#.
Daniel Lemire, "Hotspot performance engineering fails," in Daniel Lemire's blog, April 27, 2023, https://lemire.me/blog/2023/04/27/hotspot-performance-engineering-fails/.
https://lemire.me/blog/2023/04/27/hotspot-performance-engineering-fails/'> [BibTeX]
Copy
`;
modal.addEventListener('click', function(e) { if (e.target === modal) modal.close(); });
modal.querySelector('#bibtex-copy-btn').addEventListener('click', function() { const text = modal.querySelector('#bibtex-target').textContent; navigator.clipboard.writeText(text).then(() => { const origText = this.innerText; this.innerText = "Copied!"; setTimeout(() => this.innerText = origText, 1500); }); });
document.body.appendChild(modal);
const style = document.createElement('style');
style.innerHTML = dialog::backdrop { background: rgba(0, 0, 0, 0.5); };
document.head.appendChild(style);
}
// 1. Extract the URL
const fullLinkHtml = el.dataset.fullLink;
const tempDiv = document.createElement('div');
tempDiv.innerHTML = fullLinkHtml;
const linkElement = tempDiv.querySelector('a');
const rawUrl = linkElement ? linkElement.href : '';
// 2. Compute the current access date
const accessedDate = this.getCurrentAccessedDate();
// 3. --- NEW LOGIC: Extract ONLY the year (YYYY) --- // Gets the full date string, e.g., "November 23, 2025" const fullDateString = el.dataset.year; // Use regex to find the four-digit year at the end of the string const match = fullDateString.match(/(\d{4})$/); const publicationYear = match ? match[0] : '????'; // e.g., '2025' // 4. Generate BibTeX Data with the corrected year const safeTitle = el.dataset.title.replace(/[^a-zA-Z0-9]/g, '').substring(0, 15); // Use the clean year for the BibKey const bibKey = (publicationYear + safeTitle);
const content = @misc{${bibKey}, author = {${el.dataset.author}}, title = {{${el.dataset.title}}}, year = {${publicationYear}}, howpublished = {\\url{${rawUrl}}}, note = {Accessed: ${accessedDate}} };
// 5. Show Modal
document.getElementById('bibtex-target').textContent = content;
modal.showModal();
}
};
})();
Published by
Daniel Lemire
A computer science professor at the University of Quebec (TELUQ). View all posts by Daniel Lemire
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。
