Howdy guys. Sorry for the crosspost. Patch to speed up taglib.

Manuel Amador (Rudd-O) rudd-o at
Fri Oct 5 17:32:12 CEST 2007

Here's a patch.  Hope it's useful.

I dunno how to make KMail not linewrap, so I'm attaching it and pasting it as 

This patch implements on posix systems the fadvise system call that makes the 
system not readahead mp3 while scanning for tags.  It's absurd to introduce 
readahead to a problem that entails reading two or three 64 K pages at most.  
Less I/O is good. right?

This has also been posted to:



rudd-o at karen:~/Projects/amaroK/newamarok/kdesupport/taglib$ svn diff
Index: taglib/toolkit/tfile.cpp
--- taglib/toolkit/tfile.cpp    (revisión: 721576)
+++ taglib/toolkit/tfile.cpp    (copia de trabajo)
@@ -41,6 +41,10 @@
 # define W_OK 2

+#include <fcntl.h>
 using namespace TagLib;

 class File::FilePrivate
@@ -73,6 +77,7 @@

 File::File(const char *file)
+  int fadvise_retvalue = 0;
   d = new FilePrivate(::strdup(file));

   // First try with read/write mode, if that fails, fall back to read only.
@@ -87,6 +92,15 @@

     debug("Could not open file " + String(file));
+  /* Rudd-O: we don't want the kernel to cache this file descriptor or 
perform any readahead -- but only if no one else opens the file.  see 
posix_fadvise(2) */
+  if(d->file) {
+    fadvise_retvalue = posix_fadvise(fileno(d->file),0,0,POSIX_FADV_RANDOM);
+    if (fadvise_retvalue != 0)
+      debug("Could not tell the kernel to not cache the file " + 
+  }




	Manuel Amador (Rudd-O) <rudd-o at> -
	GPG key ID 0xC8D28B92 at

Now playing, courtesy of Amarok: Vincent Vargas feat. Kissey Asplund - Why 
You will be honored for contributing your time and skill to a worthy cause.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: taglib arrogant speedup patch.diff
Type: text/x-diff
Size: 1062 bytes
Desc: not available
Url : 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : 

More information about the taglib-devel mailing list