Bug 110318 - Massive Lock-Ups While Web Browsing during periods of intense File-IO
Summary: Massive Lock-Ups While Web Browsing during periods of intense File-IO
Status: RESOLVED WORKSFORME
Alias: None
Product: konqueror
Classification: Applications
Component: general (show other bugs)
Version: 3.5.9
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 118698 120303 125406 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-08-07 06:50 UTC by Dylan Taft
Modified: 2012-06-18 17:46 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch to make konqueror history saves asynchronous (2.21 KB, patch)
2007-10-18 03:23 UTC, Johannes Schriewer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dylan Taft 2005-08-07 06:50:23 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources
Compiler:          GCC 3.4.3-20050110 
OS:                Linux

Konqueror seems to do a lot of file IO while only browsing the web, despite web caching off, as well as swapping.

If I put my IO scheduler under a load, for example, by copying a large file to another location on my hard drive, konqueror will freeze loading web pages.  The copy will fall from 40MB/Sec to under 1MB/Sec, sometimes as low as 10k/sec, until konqueror unlocks.  It may remain locked for as long as 5 seconds.  During periods of low IO, konqueror sometimes jitters, but rarely locks.

My hard drive has a seek time of something like 8ms, it's a Maxtor 7200RPM ATA100 drive.  I don't BELIEVE the problem is hardware.

It happens with both the CFQ and Deadline IO schedulers, which I find odd, since I almost suspect the IO scheduler.

During periods of no IO, I can load web pages up in konqueror.  I see my hard drive light flickering, despite Web Caching and Swapping off.  What is konqueror doing with my hard drive?  Firefox uses no file IO loading web pages, the light does not go on at all, nor does it have these locking problems.  It almost seems that konqueror is not only accessing my hard drive when it shoulden't need to, but perhaps also doing a lot of IO, which is why it kills the speed of a file copy so much.  What exactly is it doing, and is there any fix?  Thanks.
Comment 1 Dylan Taft 2005-08-07 10:35:04 UTC
I forgot to say, I'm running reiser4, perhaps FS latencies are part of the problem.   Maybe it's also just killing the speed of my copy because my write_expire is set to 5000ms and my read to 500, and konqueror is reading.

Still, it woulden't lock up at all if konqueror wasn't trying to access my drive while web browsing.  Hrm.
Comment 2 Dylan Taft 2005-08-07 11:37:37 UTC
open("/home/diefool/.kde/share/config/konquerorrctOlaQa.new", O_RDWR|O_CREAT|O_EXCL, 0600) = 13
umask(0)                                = 022
umask(022)                              = 0
fchmod(13, 0600)                        = 0
getgid32()                              = 100
getuid32()                              = 1000
fchown32(13, 1000, 100)                 = 0
fcntl64(13, F_SETFD, FD_CLOEXEC)        = 0
stat64("/home/diefool/.kde/share/config/konquerorrc", {st_mode=S_IFREG|0600, st_size=3565, ...}) = 0
getuid32()                              = 1000
getgid32()                              = 100
fchmod(13, 0100600)                     = 0
fchmod(13, 0600)                        = 0
fcntl64(13, F_GETFL)                    = 0x2 (flags O_RDWR)
fstat64(13, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
mmap2(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6445000
_llseek(13, 0, [0], SEEK_CUR)           = 0
write(13, "[$Version]\nupdate_info=kfmclient"..., 3565) = 3565
fdatasync(13)                           = 0
close(13)                               = 0

It seems to be looking at konquerorrctOlaQa.new when it locks and unlocks.  I wonder why.
Comment 3 Dylan Taft 2005-08-07 11:43:19 UTC
open("/home/diefool/.kde/share/config/konq_historyVFRsda.new", O_RDWR|O_CREAT|O_EXCL, 0600) = 12
umask(0)                                = 022
umask(022)                              = 0
fchmod(12, 0600)                        = 0
getgid32()                              = 100
getuid32()                              = 1000
fchown32(12, 1000, 100)                 = 0
fcntl64(12, F_SETFD, FD_CLOEXEC)        = 0
stat64("/home/diefool/.kde/share/config/konq_history", {st_mode=S_IFREG|0600, st_size=241, ...}) = 0
getuid32()                              = 1000
getgid32()                              = 100
fchmod(12, 0100600)                     = 0
fchmod(12, 0600)                        = 0
fcntl64(12, F_GETFL)                    = 0x2 (flags O_RDWR)
fstat64(12, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
mmap2(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb64d4000
_llseek(12, 0, [0], SEEK_CUR)           = 0
write(12, "[History]\nCompletionItems=unused"..., 241) = 241
fdatasync(freeze)

also happens with konq_history
Comment 4 Dylan Taft 2005-08-07 12:27:36 UTC
It looks like the problem stems from abusing the KConfig class.  Konq access the HD a lot, when adding new history elements, and for some reason rereads/writes konquerorrc when I switch tabs.

It would be best if this was all done in ram, and then dumped to the files when konqueror closes.

The KConfig class probably doesn't directly support that....is there an API that could be used to generate a file on disk that would actually be stored in ram?   then we could use like...konquerorrctemp and konq_historytemp or whatnot, those would be in ram, and then dump those files to konquerorrc and konq_history on exit.  An easy hack.
Comment 5 Dylan Taft 2005-08-07 13:04:07 UTC
For giggles, I thought I'd edit my startkde script.
I take ~/.kde/share, rename it to sharebak
copy it to /dev/shm, and softlink it to ~/.kde/.share

Upon exit, it copies the data from shm back to ~/.kde/share

So, I tried it out.

KDE STARTS AT LEAST 3x AS FAST
And konqueror also runs much much better, no freezing at all under heavy IO.

If the startkde script hack was a bit more robust than what I posted, for example, determined if KDE was already running and didn't copy over the share directory since it's already done, is there any reason NOT to copy that stuff over to /dev/shm?  Is it insecure in any way?
Comment 6 Daniel M.H. 2005-08-07 18:37:26 UTC
I've confirmed the freezing behavior here as well. Using Ubuntu breezy with KDE 3.4.2. My primary drive, hda, is a UDMA133 PATA Maxtor drive (hdparm -Tt /dev/hda: ~55MB/s) with hdparm tweaks (-c1 -d1 -u1 -m16). Kernel is 2.6.13-rc4-mm1.

If I copy any large, _uncached_ file to another location on the same drive, Konqueror will effectively freeze up while it's waiting for fdatasync() to sync data updates to disk.
Comment 7 Dylan Taft 2005-09-14 08:15:45 UTC
http://www.mail-archive.com/reiserfs-list%40namesys.com/msg19013.html

Apparently, it's a known problem with reiser4 that fsync() is slow.  I stumbled upon this.
Comment 8 Daniel M.H. 2005-09-14 19:00:18 UTC
> Apparently, it's a known problem with reiser4 that fsync() is slow.  I stumbled upon this.

I'm using ext3, so apparently it's slow with that as well. I still think it's a problem with Konqueror/KHTML/KDE, because Firefox is much bulkier and it most certainly doesn't suffer from the same issue. Probably because it doesn't needlessly call fsync/fdatasync.
Comment 9 Richard Jonsson 2005-10-25 22:39:41 UTC
I have made an utility that monitors file activity with inotify, here is the output when just refreshing www.google.com (same url that was already loaded).

This may not be that much file activity, but because KConfig issues a sync() after every close, it degrades the overall system performance as stated by others earlier.

~/.kde3.4/share/config/kdeglobals opened
~/.kde3.4/share/config/kdeglobals closed
~/.kde3.4/share/config/kwalletrc opened
~/.kde3.4/share/config/kwalletrc closed
~/.kde3.4/share/apps/kwallet/ opened
~/.kde3.4/share/apps/kwallet/ closed
~/.kde3.4/share/apps/konqueror/konq_history4Hgpha.new created
~/.kde3.4/share/apps/konqueror/konq_history4Hgpha.new opened
~/.kde3.4/share/apps/konqueror/konq_history4Hgpha.new metadata changed
~/.kde3.4/share/apps/konqueror/konq_history4Hgpha.new metadata changed
~/.kde3.4/share/apps/konqueror/konq_history4Hgpha.new metadata changed
~/.kde3.4/share/apps/konqueror/konq_history4Hgpha.new modified
~/.kde3.4/share/apps/konqueror/konq_history4Hgpha.new modified
~/.kde3.4/share/apps/konqueror/konq_history4Hgpha.new modified
~/.kde3.4/share/apps/konqueror/konq_history4Hgpha.new saved & closed
~/.kde3.4/share/apps/konqueror/konq_history4Hgpha.new moved from here (cookie: 3037)
~/.kde3.4/share/apps/konqueror/konq_history moved to here (cookie: 3037)
~/.kde3.4/share/config/kdeglobals opened
~/.kde3.4/share/config/kdeglobals closed
~/.kde3.4/share/config/kwalletrc opened
~/.kde3.4/share/config/kwalletrc closed
~/.kde3.4/share/apps/kwallet/ opened
~/.kde3.4/share/apps/kwallet/ closed
~/.kde3.4/share/config/kdeglobals opened
~/.kde3.4/share/config/kdeglobals closed
~/.kde3.4/share/config/kwalletrc opened
~/.kde3.4/share/config/kwalletrc closed
~/.kde3.4/share/apps/kwallet/ opened
~/.kde3.4/share/apps/kwallet/ closed
~/.kde3.4/share/config/kdeglobals opened
~/.kde3.4/share/config/kdeglobals closed
~/.kde3.4/share/config/kwalletrc opened
~/.kde3.4/share/config/kwalletrc closed
~/.kde3.4/share/apps/kwallet/ opened
~/.kde3.4/share/apps/kwallet/ closed
~/.kde3.4/share/config/kdeglobals opened
~/.kde3.4/share/config/kdeglobals closed
~/.kde3.4/share/config/kwalletrc opened
~/.kde3.4/share/config/kwalletrc closed
~/.kde3.4/share/apps/kwallet/ opened
~/.kde3.4/share/apps/kwallet/ closed
~/.kde3.4/share/apps/konqueror/konq_historyohdCra.new created
~/.kde3.4/share/apps/konqueror/konq_historyohdCra.new opened
~/.kde3.4/share/apps/konqueror/konq_historyohdCra.new metadata changed
~/.kde3.4/share/apps/konqueror/konq_historyohdCra.new metadata changed
~/.kde3.4/share/apps/konqueror/konq_historyohdCra.new metadata changed
~/.kde3.4/share/apps/konqueror/konq_historyohdCra.new modified
~/.kde3.4/share/apps/konqueror/konq_historyohdCra.new modified
~/.kde3.4/share/apps/konqueror/konq_historyohdCra.new modified
~/.kde3.4/share/apps/konqueror/konq_historyohdCra.new saved & closed
~/.kde3.4/share/apps/konqueror/konq_historyohdCra.new moved from here (cookie: 3038)
~/.kde3.4/share/apps/konqueror/konq_history moved to here (cookie: 3038)
Comment 10 jos poortvliet 2005-12-27 13:07:38 UTC
@richard: that's some hefty amount of files! i hope some konqi devs can have a look at this, as this would make konqi faster - isn't that what we all want?
Comment 11 Chris Spiegel 2006-01-06 08:23:40 UTC
*** This bug has been confirmed by popular vote. ***
Comment 12 jos poortvliet 2006-01-06 08:38:41 UTC
hey, i wonder, would it matter if the 'crashes' extension is turned on or off? i don't have time to test it now, but someone could... or i can test it later today.
Comment 13 Tommi Tervo 2006-01-17 14:00:48 UTC
*** Bug 120303 has been marked as a duplicate of this bug. ***
Comment 14 teemuki 2006-02-08 16:04:44 UTC
I mounted .kde/share as tmpfs (ram disk). Konqueror (and KDE in general) has never been this fast. The difference is huge.

I've got a laptop with a 5400rpm hard disk and ext3 filesystem. Disk activity caused by the fsyncs takes much longer than actually rendering a web page. The fsyncs also prevent the disk from spinning down while running on battery.
Comment 15 Dylan Taft 2006-02-09 08:44:43 UTC
Yeah.  I did that as well, but it's a hack.  I really hope someone can look at this.
Comment 16 Tommi Tervo 2006-04-10 21:44:06 UTC
*** Bug 118698 has been marked as a duplicate of this bug. ***
Comment 17 Tommi Tervo 2006-04-12 09:39:21 UTC
*** Bug 125406 has been marked as a duplicate of this bug. ***
Comment 18 Carsten Pfeiffer 2006-04-27 14:25:03 UTC
SVN commit 534549 by pfeiffer:

use read-only KConfig objects, they won't sync() on destruction
CCBUG: 110318


 M  +2 -2      kwallet.cc  


--- branches/KDE/3.5/kdelibs/kwallet/client/kwallet.cc #534548:534549
@@ -34,7 +34,7 @@
 
 
 const QString Wallet::LocalWallet() {
-	KConfig cfg("kwalletrc");
+	KConfig cfg("kwalletrc", true);
 	cfg.setGroup("Wallet");
 	if (!cfg.readBoolEntry("Use One Wallet", true)) {
 		QString tmp = cfg.readEntry("Local Wallet", "localwallet");
@@ -52,7 +52,7 @@
 }
 
 const QString Wallet::NetworkWallet() {
-	KConfig cfg("kwalletrc");
+	KConfig cfg("kwalletrc", true);
 	cfg.setGroup("Wallet");
 
 	QString tmp = cfg.readEntry("Default Wallet", "kdewallet");
Comment 19 Carsten Pfeiffer 2006-04-27 14:29:29 UTC
The above patch probably doesn't make much of a difference though, as the backend only sync()s when the KConfig object was modified (which it isn't in the above cases).
Comment 20 Carsten Pfeiffer 2006-04-27 15:00:20 UTC
kio/misc/kwalletd heavily (ab)uses KConfig, so there might be some performance to gain.
Comment 21 jos poortvliet 2006-04-27 16:28:42 UTC
well, its mostly kwallet, then? maybe fixing kwallet might also have an impact on other apps using it?
Comment 22 Becheru Petru-Ioan 2006-05-10 22:04:56 UTC
I have this freeze problem now in kde 3.5.2/debian with a lot of apps : Konqueror(always freezes when opening a web page), Kopete(when I start/switch to a chat), KMail(when I start viewing a mail). I think it is khtml problem.

Comment 23 Becheru Petru-Ioan 2006-05-10 22:10:18 UTC
Forgot : I have a 40 G 7200 RPM Maxtor and reiser partitions
Comment 24 Becheru Petru-Ioan 2006-05-10 22:14:23 UTC
I'm pretty sure its a sync problem because after the freeze the red led indicating hdd activity blinks for a sec
Comment 25 Marek Lotke 2007-01-30 22:40:21 UTC
I've asked myself why is Konqueror writing to disk even when I'm just refreshing simple pages. Firefox does not do that.
As noted above it was the konq_history file. I went up the chain from KonqHistoryManager::saveHistory() to KSaveFile::close() to KTempFile::sync().      Being curious what could brake I've cleared body of KTempFile::sync(). Running smoothly since then!
Anyway why is konq_history so important that it needs to be synced everytime?
Comment 26 Johannes Schriewer 2007-10-18 03:21:35 UTC
I created a small patch for that issue, works good for me and is already included in KDEmod of Archlinux. See attachment following...
Comment 27 Johannes Schriewer 2007-10-18 03:23:05 UTC
Created attachment 21849 [details]
Patch to make konqueror history saves asynchronous
Comment 28 Tobias Roeser 2007-10-29 18:23:11 UTC
This problem is even more noticable when using akregator to read feeds on my battery powered laptop. When viewing a new feed the disk have to spin up which takes some seconds and needs additional power. I've configured the laptop to use laptop-mode, so there should be no need to spin the disk up that often. The implicit fsync operation just to read and save the history shouldn't be necessary. 

I vote for the patch from Comment #27! 

I've created two Gentoo ebuilds (kdelibs-3.5.8 and libkonq-3.5.8) which include these patches. They are located in my portage overlay (http://lepetitfou.dyndns.org/projects/gentoo) for all those who what to try this patch under Gentoo. The browsing and feed-reading experience is much better now. 
Comment 29 jos poortvliet 2007-10-29 18:46:56 UTC
hm, yes, this does look sensible to me... But then again, even though I took a peek at the code, I wouldn't say I'm qualified to have a say aside from being an user ;-)
Comment 30 Sami Liedes 2008-04-19 03:44:00 UTC
Ehh, WTF is KConfig doing fsync()ing things at all? Sorry but that's just plain stupid. Normal applications should pretty much never fsync(), the kernel will write stuff to the disk when its time comes, and before that no program notices the difference (except in speed).
Comment 31 Bram Schoenmakers 2008-04-19 13:07:44 UTC
This delay is also made possible thanks to KonqHistoryManager::saveHistory() being called 3 times for every page I load. That's no fun if you store a history of 5000 items and your computer is under high load.

I'm going to try the patch in comment 27 and see if that improves things.
Comment 32 jos poortvliet 2008-05-05 07:28:39 UTC
Did it work, Bram?

I was thinking about this recently - it's a real shame this slows down browsing so much sometimes, considering all the work which went into performance.

I now also get why the lockups are so dramatical in the face of a few concurrent readers - because the kernel gives a huge priority boost to readers, writes (syncs) can become very expensive. If you're compiling in the background, the sync will try to write out a lot of data - while reading is going on, so it'll take a while. Not good ;-)
Comment 33 FiNeX 2008-05-05 10:00:07 UTC
@Jos: did you do your tests even on KDE4 or only to 3.5.x?
Comment 34 jos poortvliet 2008-05-05 14:58:21 UTC
To be honest, I haven't really tried this lately... Besides, I run KDEMOD from Archlinux so my KDE 3.5.x has been fixed already in this regard. I haven't run KDE 4.x SVN extensively enough to know if the issue still exists. I wouldn't know how I could see if konqi sends a sync command when browsing. Maybe I could try to powerdown the harddrive and then try browsing, but I won't have time for that in the coming few days.
Comment 35 Bram Schoenmakers 2008-06-19 19:26:41 UTC
Unfortunately I haven't hard facts, but my impression is that it improved things.
Comment 36 Bram Schoenmakers 2008-06-19 19:28:03 UTC
Forgot to mention, I'm working with Konqueror 3.5.9.
Comment 37 jdxyz 2009-04-28 17:57:28 UTC
In my case, it doesn't matter what browser is running. A box appears withe the message "usable auto proxy config script".....sometimes it helps to click config tools....otherwise it's just  pain, disappearing/jumping mouse I suppose i shouldn't have waited until finals to report it...sry for typos, glta, l8r
Comment 38 Björn Ruberg 2009-11-30 01:30:44 UTC
KDE 3.5 is unmaintained. Is this still a problem in KDE 4? If not, this bug can be closed.
Comment 39 FiNeX 2009-11-30 11:54:44 UTC
@Lemma: from kwallet side? any idea?

Anyway big I/O operations are still a bottleneck in GNU/Linux enviroment, but it mostly depends from the kernel scheduler.
Comment 40 FiNeX 2009-11-30 11:57:15 UTC
I've forget to write one thing: if konqueror needs to write/read the disk and a big copy operation is active, konqueror performance obviously depends from the current scheduler.
Comment 41 Michael Leupold 2009-12-01 22:05:26 UTC
Nothing I can think of FiNeX. Of course the KWallet API reads kwalletrc but it shouldn't actually write (or even sync) it. If that's the case that would be a problem with KConfig writing back unchanged config files.

Strange thing is I never really stumbled on this bug despite having used reiser4 and KDE3 for quite some time.

Apart from that, if saving a large history using KConfig is a PITA, maybe switching all of it to something non-KConfig could help (KConfig syncing on saving doesn't seem like that bad an idea).
Comment 42 Sami Liedes 2009-12-01 23:11:54 UTC
As I see it, it's the syncing that's the problem, and specifically that calling fsync() actually does something different than is actually wanted in this case (I believe).

Note that what fsync() does is effectively say: Write this out as soon as possible, block until that is done. It's a tool to play on exact ordering of writes to facilitate recovery.

What it seems KDE folks want, since they don't depend on the exact ordering of writes for recovery, is: Write this out as soon as possible, but also return as soon as possible (don't block until it's done). Is there a case, real one I mean, not a hypothetical one, where the first case is desired by the applications using KConfig?

Unfortunately I don't think POSIX offers a better way to do the latter than spawning a new thread and calling fsync() from there while the main thread continues (and doesn't freeze Konqueror).

Whether this is still a problem with Konqueror, I don't know; I switched to Firefox when Konqueror was outright unusably buggy around 4.1, and have yet to switch back. I do hope to switch one day back, since I don't really like Firefox and its bloat...
Comment 43 jdxyz 2009-12-05 16:57:06 UTC
sam,
 you said, Sami Liedes <sliedes cc hut fi>  2009-12-01 23:11:54 ---
As I see it, it's the syncing that's the problem, and specifically that calling
fsync() does is effectively say: Write this out as soon as
possible, block until that is done. It's a tool to play on exact ordering of
writes to facilitate recovery.
first question, did you access the fsync? or kconfig and how.

KDE folks want, since they don't depend on the exact ordering of
writes for recovery, is: Write this out as soon as possible, but also return as soon as possible (don't block until it's done). 
 makes sense, please refer to question #1
ffox seems to try harder when erasing personal info, cach, etc when closing. I notice that something is sucking ram after browser startup. I suspect adware or spyware designed for linux. imho

good luck to all,
jd



____________________________________________________________
Nutrition
Improve your career health. Click now to study nutrition!
http://thirdpartyoffers.juno.com/TGL2141/c?cp=1un6vkbKCDop5sF6BbZcJwAAJ1C5rjx__MSrDJtOPAULkXkGAAYAAAAAAAAAAAAAAAAAAADNAAAAAAAAAAAAAAAAAAASQwAAAAA=
Comment 44 Dawit Alemayehu 2012-01-07 05:42:01 UTC
Can anyone confirm if this issue is valid in KDE v4.7.4 or higher. I do not see this problem on my machine at all.
Comment 45 Dawit Alemayehu 2012-01-07 17:59:10 UTC
If this issue is valid in KDE 4, please comment on this ticket and provide a method you used to reproduce the problem.
Comment 46 Myriam Schweingruber 2012-06-18 17:46:58 UTC
Closing based on comments #44 and #45