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

On Wed, 25 Aug 1999, Alan Cox wrote:
> > 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)
> 
> You can do 
> 	ptr=mmap(blah)
> 	mlock(ptr, ...)
> 	munmap(ptr, len)

will mlock() automatically cause all pages to be read from the file ?
(I don't think)

But since I already do an mlockall() at the beginnig, there is no need of
additional mlock()s

I had an additional idea: mmap()ing the data directly into the circular-buffer
and dirty the pages through writing one word for each page, it might be a
bit faster, because you avoid a memcpy() , but
the problem is that since the audio thread acesses this buffer, I have to
implement some communication to signal the disk thread to unmap the region,
or alternatively keep track of previously mapped regions in the disk thread,
which makes things more complicated.
I'm dealing with a data rate of about 5MB/sec (from disk), therefore the main
bottleneck is the disk not the memcpy() performance.
But I will try to mmap()/munmap() tracking and mmap() directly into the
circular-buffer, let's see if I can lower the CPU load of an additional 1-2%.
:-)

BTW, does anyone know the best method to measure the real % of CPU idle time,
since top is pretty unreliabe.

> 
> > 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.
> 
> mmap requires buffering - you are sharing the page with the system page
> cache. If you mean you want an mgoaway() to go with munmap() thats what
> madvise() provides on some other systems but not Linux yet

This will be nice, similar to O_DIRECT performance,
I will use whatever comes first. 
:-) 

regards,
Benno.

  parent reply	other threads:[~1999-08-25 15:02 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 ` mmap() better than read() fro streaming, Was: Re: Streaming disk I/O kills file buffering and makes Benno Senoner
1999-08-25 15:02 ` Benno Senoner [this message]
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-93559335100491@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