From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <201102181445.41877.dexen.devries@gmail.com> <201102181753.30125.dexen.devries@gmail.com> <7769a67a9fbc1fae2186ff9315457e0d@ladd.quanstro.net> Date: Fri, 18 Feb 2011 14:15:51 -0500 Message-ID: From: "Devon H. O'Dell" To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] Modern development language for Plan 9, WAS: Re: RESOLVED: recoving important header file rudely Topicbox-Message-UUID: b11ff80c-ead6-11e9-9d60-3106f5b1d025 2011/2/18 Rob Pike : > The more you optimize, the better the odds you slow your program down. > =A0Optimization adds instructions and often data, in one of the > paradoxes of engineering. =A0In time, then, what you gain by > "optimizing" increases cache pressure and slows the whole thing down. > > C++ inlines a lot because microbenchmarks improve, but inline every > modest function in a big program and you make the binary much bigger > and blow the i-cache. I think what I've been trying to say in this thread doesn't clash with anything that you, Erik, or others have said. Understanding the system, the complexity you are introducing, and carefully measuring the net effect are all important parts of the optimization process. You can't just switch from one data structure to another. Skip lists are a really great example: they have really amazing properties, but you trash your cache when you use them, and gathering entropy to determine where a node is placed is *not* cheap. In the end, an optimization that slows things down is not an optimization at all. You can't do it if you don't understand what you're doing, and you don't understand the overall effect. I don't think that Linux's gettimeofday(2) optimization falls into this category, though I do think that some of the similar optimizations they've done using the same approach do. In this specific case, it is an easy optimization that is cheap and works quite well. It provides measurable performance improvements in the general case, as well as in special cases. As mentioned before, people who need more accurate times can still use rdtsc. > -rob --dho