Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Benno Senoner <sbenno@gardena.net>
To: linux-sound@vger.kernel.org
Subject: mmap() better than read() fro streaming, Was: Re: Streaming disk I/O kills file buffering and makes
Date: Wed, 25 Aug 1999 14:33:00 +0000	[thread overview]
Message-ID: <marc-linux-sound-93559157930421@msgid-missing> (raw)
In-Reply-To: <marc-linux-sound-93559158330469@msgid-missing>

> 
> > I'm afraid, if we want that Linux will be a good multimedia OS, this is a
> > _STRONGLY_NEEDED_  feature.
> 
> debatable.  first, you mean "media _producer_ OS", since media clients
> do not generally mess with this kind of bandwidth.  next, you're also 
> assuming that media production apps should be naive about how they do IO.
> for instance, have you tried using mmap, with explicit munmap's on data
> that you're done with?  or played with some of the parameters on the 
> current code that attempts to prevent cache flushing?

I adapted my file streaming app to use mmap() instead of using read() to read
chunks of up  to 512k into a buffer.
As you suggested I do basically the following:
- ptr=mmap() at current offset with lenQ2k
- memcpy(targetbuffer,ptr,len)   (I must use the memcpy since targetbuffer has
to   be mlocked() since the audio-playing thread can't tolerate pagefaults
because   it runs in a low-latency cycle.
- munmap(ptr,len)

I must say it works quite well, and firing up apps, or accessing the KDE menus,
is faster, 
launching my famous "xterm" still produces disk accesses, 
(cached files are still trown away after a while, but not so agressively like
in the read() case )
but it's now faster and the system seems more usable,
especially painting into a GIMP window, since gimp uses the hd quite a lot.
I'm now able to stream about 50 mono audio tracks (44kHz 16bit) from my
IBM 16GB EIDE UDMA disk, while browsing the web, very fun !
Of course if I copy a large file in background, sooner of later, I get a
ring-buffer overrun , because the streaming-app and the cp must share disk
bandwidth.  ( I'm missing SGI's  guaranteed rate I/O of XFS , sigh .. :-)  )  

again , thank you for your suggestion !
It was a bit tricky to mess with all this page aligns, and special cases,
but it pretty fun to code ! ( got nice segfaults at the beginning  :-) )

> 
> in short, cache flushing is well-understood and media production is just
> one minor case where it comes up.  hinting (via O_ flags, madvise, ioctl)
> are the right way to turn up the agressiveness of the existing free-behind
> and pre-fetching mechanisms.

Does anyone know if there it/will be a way to do unbuffered mmap()  ?
I think streaming apps would benefit quite a bit from this.
> 
> regards, mark hahn.

regards,
Benno.

  reply	other threads:[~1999-08-25 14:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-25 14:21 mmap() better than read() fro streaming, Was: Re: Streaming disk I/O kills file buffering and ma Alan Cox
1999-08-25 14:33 ` Benno Senoner [this message]
1999-08-25 15:02 ` Benno Senoner
1999-08-25 15:39 ` mmap() better than read() fro streaming, Was: Re: Streaming disk Andrea Arcangeli
1999-08-25 16:16 ` mmap() better than read() fro streaming, Was: Re: Streaming disk I/O kills file buffering and ma Benno Senoner
1999-08-26 16:55 ` Stephen C. Tweedie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-sound-93559157930421@msgid-missing \
    --to=sbenno@gardena.net \
    --cc=linux-sound@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox