TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Surprisingly Slow

559 点作者 dochtman大约 4 年前

26 条评论

chungy大约 4 年前
&gt; Historically, the Windows Command Prompt and the built-in Terminal.app on macOS were very slow at handling tons of output.<p>A very old trick I remember on Windows, is to minimize command prompts if a lot of output was expected and would otherwise slow down the process. I don&#x27;t know if it turned write operations into a no-op, or bypassed some slow GDI functions, but it had an extremely noticeable difference in performance.
评论 #26735383 未加载
评论 #26736830 未加载
评论 #26736921 未加载
评论 #26740330 未加载
dspillett大约 4 年前
<i>&gt; CPUs have somewhat plateaued in their single core performance in the past decade</i><p>In fact for many cases single core performance has dropped at a given relative price-point. Look at renting inexpensive (not bleeding edge) bare-metal servers: the brand new boxes often have a little less single-core performance than units a few years old, but have two, three, or four times the number of cores at a similar inflation&#x2F;other adjusted cost.<p>For most server workloads, at least where there is more than near-zero concurrency, adding more cores is far more effective than trying to make a single core go faster (up to a point - there are diminishing returns when shoving more and more cores into one machine, even for embarrassingly parallel workloads, due to other bottlenecks, unless using specialist kit for your task).<p>It can be more power efficient too despite all the extra silicon - one of the reasons for the slight drop (rather than a plateau) in single core oomph is that a small drop in core speed (or a reduction in the complexity via pipeline depth and other features) can create a significant reduction in power consumption. Once you take into account modern CPUs being able to properly idle unused cores (so they aren&#x27;t consuming more than a trickle of energy unless actively doing something) it becomes a bit of a no-brainer in many data-centre environments. There are exceptions to every rule of course - the power dynamic flips if you are running every core at full capacity most or all of the time (i.e. crypto mining).
评论 #26738994 未加载
peter_d_sherman大约 4 年前
&gt;&quot;Closing File Handles on Windows<p>Many years ago I was profiling Mercurial to help improve the working directory checkout speed on Windows, as users were observing that checkout times on Windows were much slower than on Linux, even on the same machine.<p>I thought I could chalk this up to NTFS versus Linux filesystems or general kernel&#x2F;OS level efficiency differences. What I actually learned was much more surprising.<p>When I started profiling Mercurial on Windows, I observed that most I&#x2F;O APIs were completing in a few dozen microseconds, maybe a single millisecond or two ever now and then. Windows&#x2F;NTFS performance seemed great!<p>Except for CloseHandle(). These calls were often taking 1-10+ milliseconds to complete. It seemed odd to me that file writes - even sustained file writes that were sufficient to blow past any write buffering capacity - were fast but closes slow. It was even more perplexing that CloseHandle() was slow even if you were using completion ports (i.e. async I&#x2F;O). This behavior for completion ports was counter to what the MSDN documentation said should happen (the function should return immediately and its status can be retrieved later).<p>While I didn&#x27;t realize it at the time, the cause for this was&#x2F;is Windows Defender. Windows Defender (and other anti-virus &#x2F; scanning software) typically work on Windows by installing what&#x27;s called a filesystem filter driver. This is a kernel driver that essentially hooks itself into the kernel and receives callbacks on I&#x2F;O and filesystem events. It turns out the close file callback triggers scanning of written data. And this scanning appears to occur synchronously, blocking CloseHandle() from returning. This adds milliseconds of overhead.&quot;<p>PDS: Observation: In an OS, if I&#x2F;O (or more generally, API calls) are initially written to run and return quickly -- this doesn&#x27;t mean that they won&#x27;t degrade (for whatever reason), as the OS expands and&#x2F;or underlying hardware changes, over time...<p>For any OS writer, present or future, a key aspect of OS development is writing I&#x2F;O (and API) performance tests, running them regularly, and <i>immediately halting development to understand&#x2F;fix the root cause</i> -- if and when performance anomalies are detected... in large software systems, in large codebases, it&#x27;s usually much harder to gain back performance several versions after performance has been lost (i.e., Browsers), than to be disciplined, constantly test performance, and halt development (and understand&#x2F;fix the root cause) the instant any performance anomaly is detected...
评论 #26738547 未加载
评论 #26737796 未加载
评论 #26737769 未加载
评论 #26737982 未加载
评论 #26738701 未加载
h2odragon大约 4 年前
I&#x27;ll throw in &quot;hidden network dependencies &#x2F; name resolution&quot;; it&#x27;s amazing how things break nowadays when there&#x27;s no net.
评论 #26740458 未加载
评论 #26735235 未加载
评论 #26734943 未加载
fabian2k大约 4 年前
The python overhead is something I&#x27;ve noticed as well in a system that runs a lot of python scripts. Especially with a few more modules imported, the interpreter and module loading overhead can be quite significant for short running scripts.<p>Numpy was particularly slow during imports, but I didn&#x27;t see an easy way to fix this apart from removing it entirely. My impression was that it does a significant amount of work on module loading, without a way around it.<p>I think the other side of &quot;surprisingly slow&quot; is that computers are generally very fast, and the things we tend to think of as the &quot;real&quot; work can often be faster than this kind of stuff that we don&#x27;t think about that much.
评论 #26737101 未加载
balloneij大约 4 年前
Window&#x27;s slow thread spawn time is incredibly noticeable when you use Magit in Emacs.<p>It runs a bunch of separate git commands to populate a detailed buffer. It&#x27;s instantaneous on MacOS, but I have to sit and stare on Windows
评论 #26735918 未加载
评论 #26736006 未加载
评论 #26736807 未加载
评论 #26738562 未加载
评论 #26744003 未加载
ajuc大约 4 年前
&gt; Currently, many Linux distributions (including RHEL and Debian) have binary compatibility with the first x86_64 processor, the AMD K8, launched in 2003. [..] What this means is that by default, binaries provided by many Linux distributions won&#x27;t contain instructions from modern Instruction Set Architectures (ISAs). No SSE4. No AVX. No AVX2. And more. (Well, technically binaries can contain newer instructions. But they likely won&#x27;t be in default code paths and there will likely be run-time dispatching code to opt into using them.)<p>I&#x27;ve used Gentoo (everything compiled for my exact processor) and Kubuntu (default binaries) on the same laptop a few years ago and the differences in perceived software speed was negligible.
评论 #26740634 未加载
评论 #26739454 未加载
ulrikrasmussen大约 4 年前
I&#x27;d like to see some numbers comparing &quot;backwards compatible&quot; x86_64 performance with &quot;bleeding edge&quot; x86_64. That was something I had never considered, but it seems obvious in hindsight that you cannot use any modern instruction sets if you want to retain binary compatibility with all x86_64 systems.
评论 #26738047 未加载
评论 #26736208 未加载
评论 #26737878 未加载
OskarS大约 4 年前
The last section is really interesting. The author presents the following algorithm as the &quot;obvious&quot; fast way of doing diffing:<p>1. Split the input into lines.<p>2. Hash each line to facilitate fast line equivalence testing (comparing a u32 or u64 checksum is a ton faster than memcmp() or strcmp()).<p>3. Identity and exclude common prefix and suffix lines.<p>4. Feed remaining lines into diffing algorithm.<p>This seems like a terrible way of finding the common prefix&#x2F;suffix! Hashing each line isn&#x27;t magically fast, you have to scan through each line to compute the hash. And unless you have a cryptographic hash (which would be slow as anything), you can get false positives, so you still have to compare the lines anyway. Like, a hash will tell you for sure that two lines are different, but not necessarily that they are the same: different strings can have the same hash. In a diff situation, the assumption here is that 99% of the times, the lines will be the same, only small parts of the file will change.<p>So, in reality, the hashing solution does this:<p>1. Split the files into lines<p>2. Scan through each line of both files, generating the hashes<p>3. For each pair of lines, compare the hashes. For 99% of pairs of lines (where the hash matches), scan through them <i>again</i> to make sure that the lines actually match<p>You&#x27;re essentially replacing a strcmp() with a hash() + strcmp(). Compared to the naive way of just doing this:<p>1. Split the files into lines<p>2. For each pair line, strcmp() the lines once. Start from the beginning for the prefix, start from the end for the suffix, in each case, stop when you get to a mismatch<p>That&#x27;s so much faster! Generating hashes is not free!<p>The hashes might be useful for the actual diffing algorithm (between the prefix&#x2F;suffix) because it presumably has to do a lot more line comparing. But for finding common prefix&#x2F;suffix, it seems like an awful way of doing it.
评论 #26739361 未加载
评论 #26738910 未加载
评论 #26740261 未加载
评论 #26746449 未加载
secondcoming大约 4 年前
&gt; Laptops are highly susceptible to thermal throttling and aggressive power throttling to conserve battery. I hold the general opinion that laptops are just too variable to have reliable performance. Given the choice, I want CPU heavy workloads running in controlled and observed desktops or server environments.<p>Hallelujah. Running microbenchmarks on laptops is generally pointless
评论 #26737074 未加载
评论 #26736988 未加载
Jakobeha大约 4 年前
Would slow build configuration be a problem though? It isn&#x27;t even slow compiling, on one machine you configure once and then you can compile n times (e.g. if you&#x27;re developing)<p>He&#x27;s definitely right about writing to Terminals though, or in my experience logging.
评论 #26737642 未加载
评论 #26735502 未加载
评论 #26745755 未加载
评论 #26735840 未加载
brundolf大约 4 年前
This is a fascinating set of shop-knowledge from someone who&#x27;s clearly spent many years in a set of trenches that I hope I never have to. Great stuff.
评论 #26743166 未加载
raverbashing大约 4 年前
Yeah, autoconf&#x2F;autotools are a mishmash of old tools and scripts put together.<p>I still can&#x27;t get my head around what it actually does when you do .&#x2F;configure (probably conjure some 70&#x27;s Unix daemon to make sure your machine is not some crazy variant with 25-bit addresses) and I tend to avoid it whenever possible
评论 #26739499 未加载
评论 #26737153 未加载
latch大约 4 年前
So if I&#x27;m compiling PostgreSQL from source, should I be doing:<p><pre><code> export CFLAGS=&#x27;-O3 -march=native&#x27; </code></pre> Before .&#x2F;configure? Because if I don&#x27;t, it&#x27;s using -O2 without specifying an architecture.
评论 #26738514 未加载
Flex247A大约 4 年前
Here&#x27;s a dumb question: doesn&#x27;t slow software affect the environment significantly?
评论 #26736402 未加载
评论 #26734935 未加载
评论 #26735299 未加载
drewg123大约 4 年前
He singles out Windows for configure slowness, but MacOS is shamefully slow as well. I&#x27;ve seen configure run at least 2x as fast on the same machine booted into Linux or FreeBSD as compared to the MacOS that came on it.
uyoakaoma大约 4 年前
For those with issues reading the site<p><a href="https:&#x2F;&#x2F;outline.com&#x2F;CyzVvN" rel="nofollow">https:&#x2F;&#x2F;outline.com&#x2F;CyzVvN</a>
andreyv大约 4 年前
Autoconf can use a cache file to speed up tests: <a href="https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;autoconf&#x2F;manual&#x2F;autoconf-2.60&#x2F;html_node&#x2F;Cache-Files.html" rel="nofollow">https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;autoconf&#x2F;manual&#x2F;autoconf-2.60&#x2F;h...</a>
评论 #26738416 未加载
voiper1大约 4 年前
Wow, a ton of nitty gritty details I was not aware of!
fudged71大约 4 年前
Speaking of thermal throttling on Macbooks, it&#x27;s also worth pointing out that after 2 years the thermal paste on the CPU should be replaced, which is only a few dollars. I wish Apple made this a free maintenance along with removing internal dust.
totololo大约 4 年前
Great content but please improve the contrast of your website &lt;3
评论 #26735813 未加载
评论 #26740084 未加载
ziml77大约 4 年前
In my experience, third party antivirus software does a better job than Windows Defender when it comes to file open&#x2F;close performance. I always disable Defender or replace it with something else specifically because of the performance impact when working with many tiny files.
评论 #26737970 未加载
brundolf大约 4 年前
&gt; If you are running thousands of servers and your CPU load isn&#x27;t coming from a JIT&#x27;ed language like Java (JITs can emit instructions for the machine they are running on... because they compile just in time), it might very well be worth compiling CPU heavy packages (and their dependencies of course) from source targeting a modern microarchitecture level so you don&#x27;t leave the benefits of modern ISAs on the table.<p>Interesting, I wonder how this has affected language benchmarks and&#x2F;or overall perception between JITed languages and native languages
mlthoughts2018大约 4 年前
&gt; “ Programmers need to think long and hard about your process invocation model. Consider the use of fewer processes and&#x2F;or consider alternative programming languages that don&#x27;t have significant startup overhead if this could become a problem (anything that compiles down to assembly is usually fine).”<p>This is backwards. It costs extra developer overhead and code overhead to write those invocations in an AOT compiled language. The trade off is usually that occasional minor slowness from the interpreted language pales in comparison to the develop-time slowness, fights with the compiler, and long term maintenance of more total code, so even though every run is a few milliseconds slower, adding up to hours of slowness over hundreds of thousands of runs, that speed savings would never realistically amortize the 20-40 hours of extra lost developer labor time up front, plus additional larger lost time to maintenance.<p>People who say otherwise usually have a personal, parochial attachment to some specific “systems” language and always feel they personally could code it up just as fast (or, more laughably, even faster thanks to the compiler’s help) and they naively see it as frustration that other programmers don’t have the same level of command to render the develop-time trade off moot. Except that’s just hubris and ignores tons of factors that take “skill with particular systems language” out of the equation, ranging from “well good luck hiring only people who want to work like that” to “yeah, zero of the required domain specific libraries for this use case exist in anything besides Python.”<p>This is a case where this speed optimization actually <i>wastes</i> time overall.
评论 #26741052 未加载
artursapek大约 4 年前
Great, insightful post
taeric大约 4 年前
I can&#x27;t but think some of these fall into premature territory. Configuring a build for the machine is relatively rarely on the critical path. And it is mostly tests before the build. As such, it needs to compare to the build with tests, which typically takes longer than just the build.<p>Similarly, the concern on interpreter startup feels like being about one of the least noticed times on the system. :(
评论 #26751118 未加载
评论 #26739464 未加载
评论 #26740660 未加载