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.

Linux's fsync() woes are getting some attention

135 pointsby r4umabout 11 years ago

12 comments

bodyfourabout 11 years ago
I think part of the problem is that fsync() is that it&#x27;s an insufficient interface. Most of the time, you want two things: * write ordering (&quot;write B must hit disk after write A&quot;) * notification (&quot;let me know when write A is on disk&quot;) In particular, you often <i>don&#x27;t</i> want to actually force I&#x2F;O to happen immediately, since for performance reasons it&#x27;s better for the kernel to buffer as much as it wants. In other words, what you want should be nearly free, but instead you have to do a very expensive operation.<p>For an example for notification: suppose I have a temporary file with data that is being journaled into a data store. The operation I want to do is: 1. Apply changes to the store 2. Wait until all of those writes hit disk 3. Delete the temporary file I don&#x27;t care if step 2 takes 5 minutes, nor do I want the kernel to schedule my writes in any particular way. If you implement step 2 as a fsync() (or fdatasync()) you&#x27;re having a potentially huge impact on I&#x2F;O throughput. I&#x27;ve seen these frequent fsync()s cause 50x performance drops!
评论 #7376500 未加载
评论 #7376247 未加载
评论 #7376149 未加载
评论 #7376258 未加载
评论 #7377464 未加载
habermanabout 11 years ago
It always amazes me that after all these years, Linux still hasn&#x27;t fixed this.<p>In my experience, any program that overloads I&#x2F;O will make the system grind to a halt on Linux. Any notion of graceful degradation is gone and your system just thrashes for a while.<p>My theory about this has always been that any I&#x2F;O related to page faults is starved, which means that every process spends its time slice just trying to swap in its program pages (and evicting other programs from the cache, ensuring that the thrashing will continue).<p>I&#x27;ve never gotten hard data to prove this, and part of me laments that SSDs are &quot;fast enough&quot; that this may never actually get fixed.<p>Can anyone who knows more about this comment? It seems like a good rule inside Linux would be never to evict pages that are mapped executable if you can help it.<p>Has anyone experimented with ionice or iotop? <a href="http://www.electricmonk.nl/log/2012/07/30/setting-io-priorities-on-linux/" rel="nofollow">http:&#x2F;&#x2F;www.electricmonk.nl&#x2F;log&#x2F;2012&#x2F;07&#x2F;30&#x2F;setting-io-priorit...</a>
评论 #7376676 未加载
rwmjabout 11 years ago
Interesting couple of related articles &#x2F; rants by Jeff Darcy:<p><a href="http://pl.atyp.us/2013-08-local-filesystems-suck.html" rel="nofollow">http:&#x2F;&#x2F;pl.atyp.us&#x2F;2013-08-local-filesystems-suck.html</a><p><a href="http://pl.atyp.us/2013-11-fixing-fsync.html" rel="nofollow">http:&#x2F;&#x2F;pl.atyp.us&#x2F;2013-11-fixing-fsync.html</a>
zurnabout 11 years ago
Good to see this summit involving the kernel developers, since their past situation sounds rather bleak interaction-wise: using kernel version from 2009 and haven&#x27;t tested the improvements in the (2012) 3.2 kernel.<p>BTW, Linux provides the direct I&#x2F;O O_DIRECT interface that allows apps to bypass the kernel caching business altogether. This is also discussed in Mel Gorman&#x27;s message that this blog borrows from.
estabout 11 years ago
Hmm. maybe that&#x27;s why they had so many issues with single instance Redis &amp; Mongodb? As soon as fsync() the whole db became unresponsive.
评论 #7377315 未加载
mrottenkolberabout 11 years ago
I think this is a very important area of improvements for linux. While we call it &quot;multitasking&quot; there are a lot of situations where one might doubt it deserves that title.<p>I have been experimenting with very low cost computing setups that optimize for robustness and that led me to pretty slow disk I&#x2F;O. While thats not a typical scenario for desktop computing, it can and should be possible with the limited but sane resources I ended up with. In practice however, certain loads freeze the whole system until a single usually non-urgent write finishes. Basically the whole throuput is used for a big write and then X (and others) freeze because they are waiting for the filesystem (probably just a stat and similar).<p>There are differences between applications. Some &quot;behave&quot; worse than others. Some even manage to choke themselves (ever seen GIMP take over an hour to write 4MB to an NFS RAID with 128kb&#x2F;s throughput?).<p>I guess this is a hard problem, but I would wish for an OS to never stall on load. It is even better to slow down exponentially than to halt other tasks. Ideally the sytem would be smart and deprioritize long-running tasks so that small, presumably urgent, tasks are impacted as little as possible.
zvrbaabout 11 years ago
Re Mel Gorman&#x27;s details in <a href="http://article.gmane.org/gmane.linux.kernel/1663694" rel="nofollow">http:&#x2F;&#x2F;article.gmane.org&#x2F;gmane.linux.kernel&#x2F;1663694</a><p>I don&#x27;t understand why PostgreSQL people don&#x27;t want to write their own IO scheduler and buffer management. It&#x27;s not that hard to implement (even a MT IO+BM is not really complicated), and there are major advantages:<p>- you become truly platform-independent instead of relying on particulars of some kernel [the only thing you need from the OS is some form of O_DIRECT; it exists also on Win32]<p>- you have total control over buffer memory allocation and IO scheduling<p>- whatever scheduling and buffer management policy you&#x27;re using, you can more easily adapt it to SSDs and other storage types, which are still in their infancy (e.g., memristors) [thus not depending on the kernel developers&#x27; goodwill]<p>I mean, really: these pepole have implemented a RDBMS with a bunch of extensions to standard SQL, and IO+buffer management layer is suddenly complicated, or [quote from the link]: &quot;While some database vendors have this option, the Postgres community do not have the resources to implement something of this magnitude.&quot;<p>This smells more like politics than a technical issue.
ibottyabout 11 years ago
here is a mail from mel gorman with many more details.<p><a href="http://mid.gmane.org/%3C20140310101537.GC10663%40suse.de%3E" rel="nofollow">http:&#x2F;&#x2F;mid.gmane.org&#x2F;%3C20140310101537.GC10663%40suse.de%3E</a>
peapickerabout 11 years ago
So, what does Oracle Enterprise Linux do on an Exadata box running Linux?
评论 #7378526 未加载
zvrbaabout 11 years ago
Ditch Linux and port PgSQL to run on top of raw Xen interfaces. You get to control your own buffering, worker thread scheduling, and talk directly to the (virtual) disk driver. I believe it&#x27;d be a win.
cratermoonabout 11 years ago
O_PONIES ride again?
dschiptsovabout 11 years ago
Oh yes, that annoying problem (especially fro MongoDB) that data should eventually be committed to a disk.)<p>Informix (and PostgreSQL) allows DBA to choice &quot;checkpoint&#x2F;vacuum intervals&quot;.<p>The rule of thumb, unless you are a Mongo fan, is that checkpoints should be performed often enough to not take too long, which depends only on the actual insert&#x2F;update data flow.<p>But any real DBA could tell the same - sync quickly, sync often, so server will run smoothly, but not &quot;at web scale&quot; and the pain of recovery will be less severe.)