News for hackers. Stuff that matters.
Re:Windows file access performance compared to Linux by black-tea on Saturday December 29, 2018 @10:59AM (#18784145)
You're probably getting downvoted by people who have used Linux in the past 10 years.
Re:Windows file access performance compared to Linux by Thaxll on Saturday December 29, 2018 @11:09AM (#18784190)
It was / still is that the default scheduler is / was bad under heavy IO, copying a file on a USB disk would freeze the whole system ( on desktop ).

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/131094

Re:Windows file access performance compared to Linux by AnthonBerg on Saturday December 29, 2018 @11:37AM (#18784336)
I encountered this. I remember it. It was/is real. But I only happened to encounter it on Ubuntu, fwiw.
Re:Windows file access performance compared to Linux by segfaultbuserr on Saturday December 29, 2018 @12:08PM (#18784518)
And it's a particularly interesting issue, because this problem mirrors the congestion control failure observed on most networks in recent years. We all have seen this problem, on a busy network, the latency will increase by two order of magnitudes, ruining other network activities like web browsing, even themselves require only a little bit of bandwidth. The simplest demo is uploading a large file, while observing the ping latency, it would just jump from 100ms to 2000ms. But it should not happen, because the TCP congestion control was just designed to solve it.

In turns out that the cause of this problem, known as bufferbloat, is the accumulated effect of excessive buffering in the network stack, mostly the system packet queue, but also includes the routers, switches, drivers and hardware, since RAM is cheap nowadays. The TCP congestion control works like this: if packet loss is detected, then sends at a lower rate. But when there are large buffers on the path for "improving performance", the packets are never lost when if the path is congested, instead, they would be put into a huge buffer, so TCP will never slow down properly as designed, and during the slow-start, it believes it's on the way going to the moon. On the other hand, all the buffers are FIFO, it means when your new packets have a chance to get out, it's probably no longer relevant, since it takes seconds for moving it from the tail of the queue to the head, the connection would be timed out already.

Solutions include killing buffers and limiting their length (byte queue limit, TCP small queue), another innovation is new queue management algorithms: we don't have to use a mindless FIFO queue, we can make them smarter. As a result, CoDel and fq_codel are invented to implement "DELay-COntrolled queues", they are designed to prioritize new packets that are just arrived, and dropping old packets to keep your traffic flowing.

And people realized the Linux I/O freeze is a variant of bufferbloat, and the very same ideas of the CoDel algorithm can be applied to the Linux I/O freeze problem.

Another interesting aspect was, that the problem is NOT OBSERVABLE if the network is fast enough, or the traffic is low, because the buffering does not occur, so it will never be caught in many benchmarks. On the other hand, when you start uploading a large file over a slow network, or start copying a large file to a USB thumb drive on Linux...

https://lwn.net/Articles/682582/

and

https://lwn.net/Articles/685894/

Re:Windows file access performance compared to Linux by newnewpdro on Saturday December 29, 2018 @01:59PM (#18785121)
> And people realized the Linux I/O freeze is a variant of bufferbloat, and the very same ideas of the CoDel algorithm can be applied to the Linux I/O freeze problem.

There are myriad causes for poor interactivity on Linux systems under heavy disk IO. I've already described the two I personally observe the most often in another post here [1], and they have nothing at all in common with bufferbloat.

Linux doesn't need to do less buffering. It needs to be less willing to evict recently used buffers even under pressure, more willing to let processes OOM, and a bridging of the CPU and IO scheduling domains so arbitrary processes can't hog CPU resources via plain IO on what are effectively CPU-backed IO layers like dmcrypt.

But it gets complicated very quickly, there are reasons why this isn't fixed already.

One obvious problem is the asynchronous, transparent nature of the page cache. Behind the scenes pages are faulted in and out on demand as needed, this generates potentially large amounts of IO. If you need to charge the cost of this IO to processes for informing scheduling decisions, which process pays the bill? The process you're trying to fault in or the process that was responsible for the pressure behind the eviction you're undoing? How does this kind of complexity relate to bufferbloat?

[1] https://news.ycombinator.com/item?id=18784209

Re:Windows file access performance compared to Linux by magicalhippo on Saturday December 29, 2018 @07:01PM (#18786455)
> It needs to be less willing to evict recently used buffers even under pressure, more willing to let processes OOM

I've had similar experiences. On Windows, where either through bugs or poor coding, an application requests way too much memory, leading to an unresponsive system while the kernel is busy paging away.

On Linux I've experienced the system killing system processes when under memory pressure, leading to crashes or an unusable system.

I don't understand why the OS would allow a program to allocate more than available physical memory, at least without asking the user, given the severe consequences.

Re:Windows file access performance compared to Linux by newnewpdro on Saturday December 29, 2018 @09:05PM (#18786922)
Overcommit is a very deliberate feature, but its time may have passed. Keep in mind this is all from a time when RAM was so expensive swapping to spinning disks was a requirement just to run programs taking advantage of a 32-bit address space.

You can tune the overcommit ratio on Linux, but if memory serves (no pun intended) the last time I played with eliminating overcommit, a bunch of programs that liked to allocate big virtual address spaces ceased functioning.

Re:Windows file access performance compared to Linux by magicalhippo on Saturday December 29, 2018 @10:00PM (#18787089)
Yeah, I know it was a feature at one point... but at least the OS should punish the program overcommitting, rather than bringing the rest of the system down (either by effectively grinding to a halt or killing important processes).
Re:Windows file access performance compared to Linux by Dayshine on Saturday December 29, 2018 @11:53AM (#18784415)
I'm on Linux right now and can cause this to happen by using more than 60% of my RAM. Afaik no distros correctly handle swapping onto a HDD.

If I hit 80%, I get 10-20 second lock ups.

If I hit >95%, I get 1-2 minute lock ups.

Using Ubuntu 18.04.

Re:Windows file access performance compared to Linux by opencl on Saturday December 29, 2018 @12:25PM (#18784611)
What is the "correct" handling of swap on an HDD supposed to be like? It is going to be slow no matter what you do. Windows also locks up for long periods of time if you use up almost all the RAM and it has to swap to HDD.
Re:Windows file access performance compared to Linux by Dayshine on Saturday December 29, 2018 @12:32PM (#18784662)
When I say lock up I mean the UI completely stops. As in, my i3 bar stops updating for several minutes. Not even the linux magic commands let me recover.

On windows things may be unresponsive, but at least ctrl-alt-del responds, and at least the mouse moves!

The main difficulty is I can't tell if my machine has crashed vs is overloaded if the UI doesn't do anything for several minutes.

Re:Windows file access performance compared to Linux by pritambaral on Saturday December 29, 2018 @02:27PM (#18785253)
> Not even the linux magic commands let me recover.

Are you sure you've set up the magic sysctls correctly? Ubuntu ships with magic oomkill disabled, by default.

On all machines I've tried, whenever I've needed it, magic oomkill has always worked, and I've been thankful of the fact that it's implemented down in the kernel.

Re:Windows file access performance compared to Linux by zozbot123 on Saturday December 29, 2018 @12:58PM (#18784793)
If you renice the UI processes to a higher-than-normal priority, it should work more like it does in Windows. (This used to be somewhat risky, but today Linux UI is not going to hog your system resources.) The underlying problem is that when memory is tight, Linux starts evicting "clean" pages from the page cache that actually will need to be accessed shortly afterwards (i.e. they're part of the working set of some running process), and thrashing occurs. There's no easy solution to this issue, other than making user programs more responsive to memory pressure in the first place. (This could extend as far as some sort of seamless checkpoint+resume support, like what you see in mobile OS's today.)
Re:Windows file access performance compared to Linux by Dayshine on Saturday December 29, 2018 @01:07PM (#18784838)
>There's no easy solution to this issue, other than making user programs more responsive to memory pressure in the first place.

Well, why can't distributions that come with recommended GUIs just set that high-than-normal priority by default?

I don't quite understand why the system can't keep what it needs to perform REISUB in memory at all times. Surely that's a tiny program!?

Re:Windows file access performance compared to Linux by zozbot123 on Saturday December 29, 2018 @01:13PM (#18784860)
> Well, why can't distributions that come with recommended GUIs just set that high-than-normal priority by default?

Feel free to file bugs for your preferred distro. It would be especially appropriate to do this for critical UI processes like xorg/wayland or lightdm, and for "lightweight" desktops like xfce/lxde that aren't going to cause resource pressure under foreseeable conditions, even when run at higher-than-normal priority.

Re:Windows file access performance compared to Linux by Dylan16807 on Saturday December 29, 2018 @12:43PM (#18784713)
"Correct" handling of swap would mean mostly leaving the window manager and its dependencies in memory. Individual application windows may stop responding, but everything else should be pretty quick. And small things like terminal emulators should get priority to stay in ram too.
Re:Windows file access performance compared to Linux by ninkendo on Saturday December 29, 2018 @01:21PM (#18784912)
Not that I'd recommend this, but my work MBP has 16GB of ram, and my typical software development setup (JVM, IntelliJ, Xcode, gradle) easily uses up 30GB. It swaps a lot but generally OSX does a good job of keeping the window manager and foreground applications at priority so I can still use my machine while this is happening.

I attribute this to the fact that the darwin kernel has a keen awareness of what threads directly affect the user interface and which do not (even including the handling of XPC calls across process boundaries... if your work drives the UI, you get scheduling/RAM priority). I don't think the linux kernel has nearly this level of awareness.

Re:Windows file access performance compared to Linux by zozbot123 on Saturday December 29, 2018 @04:33PM (#18785837)
> ... the darwin kernel has a keen awareness of what threads directly affect the user interface and which do not (even including the handling of XPC calls across process boundaries... if your work drives the UI, you get scheduling/RAM priority). I don't think the linux kernel has nearly this level of awareness.

You're talking about priority inheritance in the kernel. In Linux, this is in development as part of the PREEMPT_RT ("real-time") patches, already available experimentally in a number of distributions.

Re:Windows file access performance compared to Linux by el_isma on Saturday December 29, 2018 @12:32PM (#18784664)
Install earlyoom, it will kill processes before a lock up occurs. Greatly helped me (at the expense of random chrome tabs killed)
Re:Windows file access performance compared to Linux by mirimir on Saturday December 29, 2018 @02:10PM (#18785178)
I usually set vm.swappiness to about 20.
Re:Windows file access performance compared to Linux by dralley on Saturday December 29, 2018 @11:11AM (#18784201)
I've experienced a total freeze before once one of my programs started swapping/thrashing. The entire desktop froze, not just the one program. This was in the past two years or so, so it's not a solved problem.