TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

What's wrong with 2006 programming? (2010)

123 pointsby baotiaoover 8 years ago

8 comments

antirezover 8 years ago
Hello, a few things that changed in the latest 6-7 years:<p>1. The Redis project abandoned attempts to have a mixed memory-disk approach, at least for the near future. I want to focus on trying to do at least one thing well and it is already hard ;-) You know, the no-need-to-konquer-the-world approach. Otherwise the project per se is interesting. Redis Labs has a commercial fork that works that way for instance (which <i>I believe</i> was initially based on the Redis &quot;diskstore&quot; branch I was working on in order to replace the former &quot;virtual memory&quot; Redis feature), but not the OSS side. Maybe I&#x27;ll change my mind in the future but so far I can&#x27;t see signs of my mindchange ;-)<p>2. About threads, we are now a bit more threaded: Redis 4.0 is able to perform deletion of keys in background, Redis Modules have explicit support for blocking operations that use threads, and so forth. However my goal in the next 1&#x2F;2 years is to finally have threading in the I&#x2F;O, in order to scale syscals, protocol parsing, to multiple threads but <i>not data access</i>. So regarding the 2006 programming, things will be the same.<p>Basically I still believe that to do application-side paging now that disks are also faster (ratio compared to RAM) is an interesting approach. I still think that using the kernel VM to do so is a bad idea in general, but could work for certain apps.
评论 #13229241 未加载
camtarnover 8 years ago
Since the article doesn&#x27;t mention it til quite far in: Redis is apparently single threaded, which is why the blocking nature of OS page swapping is so disastrous. Presumably for a more traditional server with lots of worker threads this would be less true.
评论 #13226965 未加载
评论 #13228151 未加载
评论 #13227486 未加载
dvirskyover 8 years ago
It is important to note that in the many years since this post, while redis has remained single-threaded - it also removed the entire concept of VM, and now works only fully in memory.
评论 #13227688 未加载
geerlingguyover 8 years ago
The comments on this post are enlightening. I use both Varnish and Redis, and the architecture discussion is great!
koverstreetover 8 years ago
One thing that would really help is if we had buffered asynchronous IO.
trevynover 8 years ago
(2010)
ploxilnover 8 years ago
PHK&#x27;s post, which inspired this, assumes that the process is swapping. It describes writing an page to disk to free up that page, then reading in the anonymous page of data that needs to be used for the write() system call the process uses to manually cache the data to disk. For the stuff that I use and work on, if the system is swapping anonymous pages, the situation is dire and it&#x27;s time to kill (processes).<p>Let me back up and try to explain a bit:<p>While OS kernel developers have put a huge amount of effort into virtual memory management and paging, which was and is a good and necessary thing, the definition of &quot;interactive&quot; and &quot;low latency&quot; has changed. Long ago, half-second latency at a virtual terminal connected to a mainframe with hundreds or thousands of users was fantastic, compared with dropping off your stack of punch-cards and coming back 12 hours later.<p>For most of the software I use and work on today, I want low sub-second latency. It&#x27;s often only achievable with reasonable direct control of what is in memory and what is on disk. If I click a menu in a GUI program that I haven&#x27;t clicked in weeks, I don&#x27;t want to wait half a second for a few scattered pages to be paged in&#x2F;out of swap. Same goes for requests to web or api servers - I don&#x27;t want less-common requests to take a half second longer than the typical 50ms or so. For desktop environments, GUIs, databases, caches, services: no swap.<p>Certainly, <i>data</i>, multimedia files, dictionaries, etc will need to be read from disk. The processes can arrange for separate threads to do that. We can have responsive progress bars, cancel buttons, priorities, timeouts before hitting an alternative data source - but only if the process itself is in RAM, not in swap.<p>Now that desktop and server systems measure DRAM in 10s of gigabytes, this really should not be hard to achieve!<p>I&#x27;ve struggled with swap and out-of-memory situations on Linux many times. The linux kernel never seems to OOM-kill processes fast enough for me. If I have no swap, then if memory pressure sets in, the kernel struggles to shrink buffers, practically freezing most processes, for <i>a few minutes</i> before finally killing the obvious culprit. (I&#x27;ve also tried memory-limiting containers, and they suffer the same problem - freeze up for a few minutes instead of immediately killing when OOM.) I used to enable plenty of swap, more than RAM, because that was the common wisdom, but it causes the same problem when the system comes under memory pressure, everything freezes for a few minutes. But it also has the additional problem that despite setting swappiness to 1 or 0, some strange services&#x2F;applications will cause the kernel to put some anonymous pages in swap, even when there&#x27;s <i>plenty</i> of free physical memory. I never want that! I need to periodically swapoff and swapon to correct it.<p>So, at each company I work for, I end up writing a bash script, run by cron each minute, which checks for low system memory, looks among the application services for an obvious culprit, and sends it SIGTERM. In practice, this solves the problem pretty much every time, in the most graceful way. It&#x27;s extremely rare that a critical system process is the problem or looks like the problem. (Except dockerd a couple times ;)<p>(This is not to bash Linux in particular, Windows and MacOS use way more RAM and swap in general. I&#x27;ve heard the BSDs have been good at particular things at particular times, but driver support has always been more of a struggle. Besides the swap &#x2F; OOM behavior, I&#x27;m pretty happy with Linux.)<p>Letting the OS manage disk and RAM makes perfect sense for bulk data processing - hadoop, spark, or other map-reduce or stream-processing where a few seconds pause here and there is no problem if throughput is maximized. But I personally don&#x27;t work much on those things - and I&#x27;m not a rare case.
smegelover 8 years ago
&gt; OS paging is blocking as hell<p>No, Linux is rubbish. Seriously. FreeBSD does this properly.<p><i>Edit: FreeBSD, Windows, OSX, Solaris, AIX, HP-UX(?)...</i>
评论 #13226961 未加载
评论 #13226852 未加载
评论 #13227090 未加载
评论 #13227093 未加载
评论 #13226851 未加载