Using disk streaming ( the natural way ) with Linuxsampler may be greatly enhanced, regarding the xrun issue, by switching disks to "noatime", at least the disk dedicated to .gig files.

This operation is quite simple but i strongly advise you to read first the different warnings i will write.

The first warning is classical: you are on your own responsibility, i assume absolutely nothing if anything go wrong, nor do it the forum on which you are reading this.

The second warning: you are about to modify /etc/fstab, and the littlest error here may render your system _unbootable_ ( i will give the correction procedure ), and so your are in danger to loose all your stored data ( until you pay a professional disk-rescue company to do the job for you, they will probably charge you 500$ for one minute of work, business is business ).

Lastly, this is not a warning but you will easily find better documented procedures on internet, just "yahoo" or "google" for it.

Synthesis

1/ What is "noatime" ? What is a dedicated disk2/ Why switching to "noatime"3/ Will i loose anything with "noatime" ? Why not switching to "noatime"3.1/ Consequences of switching only a dedicated disk versus the whole system4/ How to verify that "noatime" is applied5/ The procedure to switch to "noatime"5.1/ Starting5.2/ Security ( do not skip )5.3/ Modifying /etc/fstab ( the long story )5.4/ Modifying /etc/fstab ( the short story )5.5/ Two samples5.6/ Making tmpwatch happy with "noatime"5.7/ Ending6/ The correction procedure if anything went wrong

1/ What is "noatime" ? What is a dedicated disk

First of all, "noatime" is only relevant for ext2/ext3 filesystem, if you are using Reiserfs, or JFS, or XFS, you can stop reading here.

Mostly all distro ( excepted Suse/openSuse i believe ) came with physical disk defined as "atime" per default.

"atime" required the system to write a file/timestamp on the disk at any attempt to read, and obviously write, for any file ( even if already preloaded in memory ).

"noatime" is the exact contrary of "atime": the system do not write a timestamp on the disk when reading a file ( a file/timestamp is still written when writing/updating a file ).

A dedicated disk is a physical disk ( the piece, the stuff, so basically this a new disk and _not_ a partition or mount point on the existing disk ) which is used only for data like .gig files. Having no programs at all on the dedicated disk is the main topic here. The idea is that the magnetic head(s) of the disk have nothing else to do than reading your .gig files. This doesn't change the disk speed, but reduces the latency time to access a file, remember the head doesn't need to go on /bin/this_program or /lib/that_driver.

2/ Why switching to "noatime"

In few words: switching all the disks to "noatime" will reduce your average number of disk write by 20% to 40% ( some kernel developers report over 60% for a compilation ).

In fewest words: you will discover a penguin on steroid.

Technically, apart the mandatory time spent to write on a disk ( which obviously prevents reading it at the same time. This short explanation is somewhat false for SCSI disks and modern SATA disks with NCQ really working, another story ), this will also reduce the number of I/O interruptions, and interruptions are not good friends with music on a computer, even DMA's one.

3/ Will i loose anything with "noatime" ? Why not switching to "noatime"

Basically no ( excepting (*) (**) (***) ), _but_, if you are using a backup software the advise will be:

c) switch only the dedicated disk, _if_ there is nothing to backup on it.

Formally: every softwares relying on the read file/timestamp modification can't work anymore ( they "think" that time had stopped at the exact moment of your switch to "noatime", and forever ), period.

Practically: they are very few softwares relying on the read file/timestamp ( keep in mind that backup softwares are strong candidates for requesting "atime" defined disks, at least for some of their functions ).

(*) for sample, and without modification of the software parameters, this will break the "package statistical tool' of Mandrake. Please also note that this is the _only_ software complaining about "noatime" on Mandrake ( backups untested ).

(**) some report Mutt ( a console email reader ) to be worried by it, some report the contrary. On my system (RHEL5), i can't see any problem.

(***) tmpwatch ( a very important program, it regularly purges your /tmp directory ) rely on "atime", but a simple switch is sufficient to make it work with "noatime", the necessary modification will be described on paragraph 5 - The procedure to switch to "noatime".

3.1/ Consequences of switching only a dedicated disk versus the whole system

Switching all the disks is obviously better regarding performances. On an another hand, only switching the dedicated disk remains interesting for performances if Linuxsampler is heavily using its disk streaming, while preserving your current software backup functions, and setup, for the system disk ( and other non-switched disks ).

4/ How to verify that "noatime" is applied

A rather unconventional answer is: the first time you will boot with "noatime", you will immediately know it, don't worry

A more classical one could be:

As root ( or sudo it ), 'mount' can report this. 'cat /proc/mounts' is more informative ( do not forget the 's' ).

Typical results are:

mount /dev/sda1 on /DATA type ext3 (rw,noatime,user_xattr)

cat /proc/mounts/dev/sda1 /DATA ext3 rw,noatime,data=ordered 0 0

5/ The procedure to switch to "noatime"

There is no need to be system engineer, but if you don't feel confident with the basis ( some knowledge on the boot process, using root and editing a text file ), please make you a favor: stop reading here.

WARNING, if you don't have the original CD/DVD of the distro, or a CD/DVD with a rescue distro ( and obviously a CD/DVD reader configured to be bootable ), please make you another favor: stop reading here.

5.1/ Starting

Typically backup the whole system ( yes, i know, the classical joke, but this is always a good idea ).

The only thing which matters is the partition where /etc is installed, here it is /dev/hda6. As a rule of thumb what you need is the the ( whole ) left word of the second line.

Now write this information on a paper and do not throw it away.

Seriously, the previous sentences are mandatory.

Well, the other way to restore is to reinstall the distro...

...eventually you had duplicated /etc/fstab and stored the physical location of /etc. How smart you are

5.3/ Modifying /etc/fstab ( the long story )

Your best friends are: 'man mount' and 'man fstab'.

Now take your favorite text editor, and open /etc/fstab.

What you can find is a system with, or without label.

With label typical lines are:

LABEL=/ / ext3 defaults 1 1LABEL=/DATA /DATA ext3 defaults 1 2

Without label typical lines are:

/dev/hda6 / ext3 defaults 1 1/dev/sda1 /DATA ext3 defaults 1 2

Now we will carefully read this file.

- the first parameter ( the first word ) is the physical location ( this is less obvious with label, but remains the physical location )

- the second parameter is the mount point ( the directory name you can see via your file explorer, or with a console command like 'ls' )

- the third parameter is the filesystem type ( which is always 'ext3' in the four lines presented as samples )

- the fourth parameter is/are the options used by the system to mount the partition, this is what we want to modify

- the fifth and sixth parameters define the order of mount. always keep them _unchanged_.

The main point is as soon as you can read a 'space' ( a ' ' ), the system understand 'next parameter' and don't care about the number of ' ' between them , which means that the following lines are strictly the same for the system:

/dev/sda1 /DATA ext3 defaults 1 2/dev/sda1 /DATA ext3 defaults 1 2

( the forum 'eats' the 'space', the result is less meaningful than intended )

This is fine, but you can easily introduce a bug as soon as you fill a 'space' _inside_ a parameter:

LABEL=/DATA /DATA ext3 defaults 1 2 is OK

but if you want to "beautify" the line and write:

LABEL = /DATA /DATA ext3 defaults 1 2 is no more valid

Why ? The system understands that the first parameter is only the word 'LABEL' ( which doesn't exist, contrary to 'LABEL=/DATA' ), the second parameter is '=' ( there is no mount point named '=' ) and so on. The penalty is quite simple: if you are doing this on a disk containing the system ( a data disk is without importance, but will remain unmounted until you correct the corresponding line ), Linux will not be able to find its programs and will refuse to boot. PLease, explain me why you are running to paragraph 5.2 - Security

You are back ? Fine.

FIRST and SECOND PARAMETERS> If you want to switch only the dedicated disk, you need to inspect the first and second parameters ( if you want to switch the whole system, this doesn't matter, go directly to THIRD PARAMETER ), to find which line ( and only one ) is defining your dedicated disk.

Two approaches meet the two different notations ( with or without label ):

a) whithout label. You will find as first parameter something as /dev/hdb[n] ( where [n] is a number ) for a second IDE disk, /dev/sda[n] for a second SATA disk over a first IDE one, and /dev/sdb[n] for a second SATA disk over a first SATA one. If you are using an external USB disk, this will be ( depending on the disks already assigned before the installation of the USB disk. Even during a fresh install of Linux with the USB disk connected, all disks are assigned before the USB ones ) either /dev/sda[n] or /dev/sdb[n]. Anyway, you can check your result with the approach b).

b) whith label. The first parameter is not useful, you must look at the second one ( the mount point ), and here you will need to use some 'intuition'. To avoid mistake you can clearly ignore each line containing either: / or /boot or /tmp or /var or /dev/something or /proc or /sys or /usr or /usr/local or swap ( swap without leading / ). Very often CD/DVD and USBkey/disk are mounted on /mnt or /media, so you will find something like /media/a_suggesting_name.

To sum up, on a classical install:

the first parameter is your second IDE disk will be named /dev/hdb1 your second SATA disk will be named /dev/sda1 or /dev/sdb1 your external USB disk will be named /dev/sda1 or /dev/sdb1

the second parameter is your second IDE disk will be mounted on /somename or, quite rare, /mnt/somename or /media/somename your second SATA disk will be mounted on /somename or, quite rare, /mnt/somename or /media/somename your external USB disk will be mounted on /mnt/somename or /media/somename

where 'somename' could be everything excepted: boot bin sbin lib usr var tmp proc sys dev root, but this could be home or opt ( quite rare ).

THIRD PARAMETER> We are only interested by ext2 and ext3, so if the third parameter is either sysfs , devpts , tmpfs , swap , proc : ignore the corresponding line ( obviously this do _not_ mean destroy the line, just _keep_ it as it is ).

this case is OK, we will see later how to modify them. Typically CD is /dev/hdc, DVD /dev/hdd and USBkey or USBdisk /dev/sd(a)or(b)and a number, so /dev/sda1 or /dev/sdb1 and so on.

b) a line defining a system disk ( so mount point are / /boot /usr /var /tmp ), for sample:

LABEL=/ / auto defaults 1 1 or /dev/hda6 / auto defaults 1 1

Well, you can verify via 'mount' the filesystem type of each entry, and modifying them accordingly ( if they are etx2 or ext3 type, of course ), but i strongly suggest to stop here.

FOURTH PARAMETER> Ok, so far we know which lines we want to modify, now lets take a look at what we want to modify, the mount options.

Excepted for the CD and USBdisk, this parameter is always 'defaults' in the previous samples, you might find 'rw,defaults' instead. This doesn't matter too much. If you find 'defaults' change it for 'defaults,noatime', If you find 'rw,defaults' change it for 'rw,defaults,noatime'.

Warning 1: do _not_ introduce any 'space' here: 'defaults , noatime" is not valid.Warning 2: _preserve_ the 'space(s)' with the preceding and following parameters: 'ext3 defaults,noatime 1 2' is valid, 'ext3 defaults,noatime1 2' is not valid.

To finish with the fourth parameter, the CD/DVD/USBdisk case. Remember, they are type 'auto' or 'vfat' ( you might find an USBdisk formatted as ext3, but generally they stay formatted in FAT or FAT32, read: Windows. CD/DVD are ISO ).

Here is an exception to what was said in the introduction: all those filesystem also support "noatime" ( to be precise usbfs and isofs support it ). But the options are generally more complex than the simple 'defaults'. You _must_ respect the following rule: "noatime" have to be introduced after user,suid/nosuid,dev/nodev _and_ before auto/noauto.

For a switch of every disks, edit /etc/fstab and find every lines containing ext2 or ext3 or /dev/hdd or /dev/hdc or the USBdisk. For each line found change the word 'defaults' ( without the ' ) by 'defaults,noatime', and leaves all the rest _unchanged_, including the 'space' ( ' ' ). if there is no 'defaults' , introduce ',noatime' before ',auto' or ',noauto'.

For a switch of only the dedicated disk, find the line corresponding to the disk in /etc/fstab , and do the same as preceding.

Before:

/dev/sda1 /DATA ext3 defaults 1 2

After:

/dev/sda1 /DATA ext3 defaults,noatime 1 2

5.5/ Two samples

The first one is a non labeled system, with two IDE disks, one CD and an USBdisk, and we want to switch two dedicated disk: the second IDE and the USBdisk, so keeping the system disk with "atime".

The answer will be /etc/cron.daily/tmpwatch , /etc/cron.daily/cups and maybe /etc/cron.daily/tetex-something ( you can ignore everything with 'selinux' ).

So, you need to edit the three files ( tetex is rarely used, so you can wait for only two files ) /etc/cron.daily/tmpwatch /etc/cron.daily/cups and /etc/cron.daily/tetex-something.

In each file you must change the word 'tmpwatch' ( without the ' ) by 'tmpwatch --ctime'. do not introduce or remove any 'space'. You will find several times the word 'tmpwatch', do it for each occurrence.

Do not be confused:

/etc/cron.daily/tmpwatch is a script of the scheduler ( cron ).

/usr/sbin/tmpwatch is the program which is actually doing the job of removing old files from /tmp.

The file ( one of them ) we are modifying is the script /etc/cron.daily/tmpwatch.

And the modification we are doing is to add a parameter ( --ctime ) to the program /usr/sbin/tmpwatch, inside the scripts we had found via the 'find /etc' command.

Only in case of mistake during the modification of /etc/fstab, the system will refuse to boot.

You _must_ had done the operations specified in paragraph 5.2 to use this.

Boot either the rescue mode of your CD/DVD distro or a rescue distro CD/DVD. ( you will be root, if not log on root ).

You are automaticaly set on a virtual filesystem mounted in memory, so /mnt or /media at this moment have nothing to do with your system /mnt or /media directory. In particular, you can find at this moment an /etc directory. This is the /etc directory of the virtual filesystem and have nothing to do with your system /etc directory. Read: it is useless to try to write anything in /etc at this moment.

Create a directory to mount the partition containing /etc of your system ( depending on the rescue disk configuration, you can use /mnt or /media, otherwise you can create something like ./i.am.not.very.happy.with.the.noatime.option ), so run either:

i can't agree more, distros should have done this switch a long time ago.

I am interested and currently doing a lot of tests about performances and linuxsampler. Several ways are explored, in particular an external instrumentation of the audio driver and Linuxampler itself ( libaudit or things like that ), unfortunately i have not yet found something unobtrusive enough to not disturbe the audio driver while benchmarking it. Counting interruptions and finding their relations with realtime requirements is no more an easy task. So remains the classical way, running and lot of tests and extracting statistically the results. On this point, things will be easier with the next Linuxsampler allowing a dynamic setup of memory and other parameters.

Anyway, following your suggestion about noatime and disk streaming, i had found something really surprising: Linuxsampler never reads the same quantity of information to play the same midi piece, obviously granted that the situation is rigorously the same at the start of playing, for example not a single note is played before playing the midi file, i even do a reboot between each run.

My understanding of the way Linuxsampler is working was: when a note is about to be played, either Linuxsampler finds the corresponding .wav file in memory, or it reads it from the disk. So in the same configuration of every preceding events, either it will ask nothing from the disk , or it will read the .wav file ( or articulation, or whatever, this doesn't matter ) from the disk. So, i was expecting the same disk load between two run, at every moments. This is not the case, even the total amount of disk load at the end of the piece is not the same ( at first i had imagined some possible "delay" in the way Linuxsampler retrieves its informations from the .gig file ).

Two runs for illustrating that:

* each line represents the cumulative load of the last second, and you have exactly one line per second* the piece duration is 134 seconds* this is the load of a dedicated disk, and nothing here is involved excepted the .gig file ( the writes on the second run sample is the result of atime, versus noatime for the first one ).

--dsk/sda--.read..writ...0.....0....0.....0....0.....0....0.....0...14M....0. <== Start of play5428k....0.7912k....0.2036k....0.1020k....0.1356k....0.5000k....0.5248k....0.6152k....0.4756k....0.5332k....0.4184k....0.3500k....0.5920k....0.5756k....0.3384k....0.6848k....0.4276k....0.4564k....0.5032k....0.1648k....0.2612k....0.3124k....0.3492k....0.2388k....0.2832k....0.2408k....0.2684k....0.2184k....0.2444k....0.1868k....0.2092k....0.1420k....0.1172k....0.2608k....0.2080k....0.1960k....0.1192k....0..688k....0..908k....0.2660k....0.3908k....0.1368k....0.1456k....0.1536k....0.1464k....0.1288k....0.1052k....0.1084k....0.1248k....0.1428k....0.1356k....0..800k....0..316k....0..540k....0..260k....0..200k....0..620k....0..540k....0..556k....0.2256k....0..500k....0..400k....0...76k....0....0.....0..124k....0..232k....0..560k....0..116k....0...72k....0...80k....0..280k....0..280k....0..452k....0..544k....0..372k....0..280k....0..296k....0..228k....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0.1020k....0....0.....0....0.....0....0.....0....0.....0....0.....0..288k....0..668k....0..812k....0..900k....0..624k....0..524k....0..348k....0..128k....0....0.....0....0.....0.4096B....0....0.....0..304k....0..376k....0..284k....0..284k....0..668k....0..564k....0..392k....0..284k....0...28k....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0....0.....0. <== End of play

--dsk/sda--.read..writ...0.....0....0.....0....0.....0....0.....0.7360k....0. <== Start of play.9.9M....0.6380k....0.4344k....0.2040k....0.1104k...16k2080k....0.4688k....0.7256k....0.5588k....0.4356k...16k5468k....0.3636k....0.4900k....0.4952k....0.5204k....0.5188k...16k5796k....0.4576k....0.6700k....0.1736k....0.1692k...16k2748k....0.4244k....0.2516k....0.2500k....0.2864k...16k1884k....0.2764k....0.2688k....0.2004k....0.1924k...16k1600k....0.1120k....0.2292k....0.2220k....0.1016k....0.1940k...16k.728k....0..580k....0.1128k....0.4104k....0.2432k...16k1460k....0.1728k....0.1704k....0.1368k....0.1004k....0.1420k...16k1296k....0.1376k....0.1376k....0.1220k....0..852k...16k1128k....0..988k....0..640k....0..784k....0..672k...16k.288k....0.1104k....0.1656k....0..628k....0..180k....0....0....16k..24k....0..408k....0..448k....0..448k....0..236k...16k.120k....0..128k....0..268k....0..316k....0..652k....0..212k...16k..72k....0..104k....0....0.....0....0.....0....0....16k...0.....0....0.....0....0.....0....0.....0....0.....0....0....16k...0.....0..760k....0.1516k....0..152k....0....0....16k...0.....0....0.....0...24k....0..312k....0..808k...16k.836k....0..928k....0..824k....0..708k....0..436k....0....0....16k.256k....0..280k....0..308k....0..256k....0..228k....0..300k...16k.264k....0..284k....0..548k....0..496k....0..284k...16k.172k....0....0.....0....0.....0....0.....0....0.....0....0....16k..80k....0..516k....0..532k....0..536k....0..544k....0..520k...16k.380k....0....0.....0....0.....0....0.....0....0.....0....0....16k...0.....0....0.....0. <== End of play