Excessive swapping during hash

Bug #376896 reported by dairinin
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
LinuxDC++
Incomplete
Undecided
Unassigned

Bug Description

There is a reproducable problem in linuxdcpp (or maybe it is the kernel/libc?), where hashing a large file causes excessive swapping to occur, while memory usage is far from 100%. I've seen this on at least two different machines, both working under gentoo amd64 and both using 2.6.29.2 kernel.
Steps to reproduce:
1. Start X/GNOME/KDE, some programs in the background to give system something to swap
2. Start hashing some _big_ files (say, 2GIG and more on a system with 4GiGs of RAM)
3. See swapping to occur

I don't know whether thisi is a kernel or stdlib or linuxdcpp issue, but I only see such swapping with linuxdcpp

Here is a "vmstat 2" output during hashing of two big files in the attachment

Tags: core hashing
Revision history for this message
dairinin (nowhere-hakkenden) wrote :
Revision history for this message
Razzloss (razzloss) wrote :

Unable to reproduce. Gentoo x86, 2.6.27-gentoo-r10, 4G RAM.

Hashed 4G file without swapping.

--RZ

Revision history for this message
dairinin (nowhere-hakkenden) wrote :

Could you try any from 2.6.28 or 2.6.29?
2.6.28-gentoo-r5 is stabilized

2.6.27 is not affected, only 2.6.28+. I've added a picture of memory usage with some milestones.
Before 2.6.28 linuxdcpp did not affect swapping at all. Well, after 2.6.28 swapping began, so I had to get a "workaeound" - a small 10M swap-file, which filled instantly, but did not fit enough pages to affect performance.

Revision history for this message
Razzloss (razzloss) wrote :

Ok, tested with 2.6.28-gentoo-r5 and I do see some swapping while hashing.

So is this a problem/feature of the kernel or should we doing something different?

--RZ

Revision history for this message
dairinin (nowhere-hakkenden) wrote :

I don't know (if that question was for me). I hoped some of the devs could tell whether this is a linuxdcpp problem or not.

Revision history for this message
Razzloss (razzloss) wrote :

Question was mainly to Steven/individ... or anyone else who might have a clue.

Though I suspect that this isn't a Linuxdcpp problem as it seems that 2.6.28 kernel is being more unresponsive and swapping more than the previous ones. (no I don't really have any hard data of this, just a gut feeling)

--RZ

Revision history for this message
dairinin (nowhere-hakkenden) wrote :

Looking through the code, I've found out there are two implementations of hashing function. Swapping happens only when the fast one is in use.

Revision history for this message
Steven Sheehy (steven-sheehy) wrote :

I've added some additional error checking to fast hash a while ago in upstream dc++, but it has not made its way to linuxdcpp yet. It may show that madvise is indicating an error and fallback to regular hash in your case. Can you try grabbing the latest copy of HashManager.cpp and .h from DC++ and retrying? Also, what is your max hash speed size preference set to?

http://bazaar.launchpad.net/~dcplusplus-team/dcplusplus/trunk/files/head%3A/dcpp/

Revision history for this message
dairinin (nowhere-hakkenden) wrote :

Rebuilt with hashmanager from dcpp fith debug=true (not sure whether this matters here). Started from terminal and turned on system log (also not sure). There are no error messages from mmap/madvise either in the terminal nor in system.log

Did I do everything right?

Revision history for this message
Steven Sheehy (steven-sheehy) wrote :

Sounds like it. They probably just didn't have any errors to report. Did you see any difference in the swapping?

Revision history for this message
dairinin (nowhere-hakkenden) wrote :

Nope. Swaps like hell
BTW, I've found some discussion on linux-mm, which could be related to this case: http://marc.info/?l=linux-kernel&m=121616312201185&w=2
Also mysql guys had similar problems with mmaps: http://bugs.mysql.com/bug.php?id=37408

Revision history for this message
Vangelis Tasoulas (cyberang3l) wrote :

Having exactly the same problem. 3gigs of RAM on a karmic 64bit installation...
2GB free and when linuxdcpp hashes large files, it is using more than 1GB of swap that makes my computer very slow at the time of this operation...

Revision history for this message
Steven Sheehy (steven-sheehy) wrote :

Might be related to bug #517948.

Revision history for this message
dairinin (nowhere-hakkenden) wrote :

There's a patchset in kernel dev. list, which looks to be related to this trouble:
http://lkml.org/lkml/2010/2/22/274

This is the same in more details:
http://marc.info/?l=linux-mm&m=125297194724716&w=2

Revision history for this message
Steven Sheehy (steven-sheehy) wrote :

Indeed, that patch looks very promising. If I understand it correctly, it could help with reducing swapping, reducing memory usage, and decreasing CPU utilization. Let's hope someone has the ability to test this patch to verify it solves this bug.

Changed in linuxdcpp:
status: New → Incomplete
tags: added: core hashing
Revision history for this message
Steven Sheehy (steven-sheehy) wrote :

Oh, I also added an option to disable fast hashing until this issue is resolved. You can find it in the advanced tab of the preferences.

Revision history for this message
dairinin (nowhere-hakkenden) wrote :

Well, 2.6.34-r1 is out and it contains patch under question. I've managed to try in on a testbox and compare with 2.6.32-gentoo-r3 on a x86_64 machine with 4G of ram

The file list is clean. After restart, adding a single 8G file causes ZERO swapping, and the system stays responsive. With 2.6.32 swapping occurs instantly when free memory reaches it's minimum and kswapd begins reclaiming pages. The system becomes sluggish, mouse cursor jumps.
Overall hashing speed with the new kernel is very stable - 57Mb/s on my old SATA drive. With 2.6.32, hashing speed is also very stable until kswapd steps in - after that, hashing speed drops to ~50Mb/sec and oscillates around it.
When hashing thread is finished, new kernel still shows ZERO swap usage, whereas 2.6.32 shows this:
$ free
             total used free shared buffers cached
Mem: 4055264 4022896 32368 0 2952 3824016
-/+ buffers/cache: 195928 3859336
Swap: 2008084 122796 1885288

So, this post is not a confirmation of a problem resolution, more testing is needed, and probably not until the patchset is backported on 2.6.33 series. Or, maybe, not until 2.6.34 is stable.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.