From owner-freebsd-current@FreeBSD.ORG Wed Dec 10 00:12:50 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5735316A4CE for ; Wed, 10 Dec 2003 00:12:50 -0800 (PST) Received: from mailspool.ops.uunet.co.za (mailspool.ops.uunet.co.za [196.7.0.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE74443D13 for ; Wed, 10 Dec 2003 00:12:48 -0800 (PST) (envelope-from ianf@za.uu.net) Received: from copernicus.so.cpt1.za.uu.net ([196.30.72.32]) by mailspool.ops.uunet.co.za with esmtp (Exim 3.36 #1) id 1ATzSG-000Im7-00; Wed, 10 Dec 2003 10:12:20 +0200 Received: from localhost ([127.0.0.1] helo=za.uu.net) by copernicus.so.cpt1.za.uu.net with esmtp (Exim 3.36 #1) id 1ATzSF-000CvQ-00; Wed, 10 Dec 2003 10:12:19 +0200 To: Mathew Kanner In-reply-to: Your message of "Tue, 09 Dec 2003 14:25:57 EST." <20031209192557.GE11072@cnd.mcgill.ca> References: <20031209192557.GE11072@cnd.mcgill.ca> From: Ian Freislich X-image-url: http://www.freislich.nom.za/gallery/ian-small.gif X-BOFH: true X-LART: Depleted uranium X-No-Junk-Mail: I do not want to get *any* junk mail. You have been deleted Date: Wed, 10 Dec 2003 10:12:19 +0200 Message-ID: <49687.1071043939@za.uu.net> Sender: ianf@za.uu.net cc: freebsd-current@freebsd.org Subject: Re: Why are sound ioctl calls so slow? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Dec 2003 08:12:50 -0000 Mathew Kanner wrote: > > 3224 mpg123 0.000748 CALL ioctl(0x3,SNDCTL_DSP_SETFMT,0xbfbff834) > > 3224 mpg123 0.026260 RET ioctl 0 > > > > Can someone firstly tell me whether or not if it is reasonable to > > expect the ioctl call to be any faster. Perhaps my reasoning is > > flawed, but I'd expect about 61000 instructions to be executed by > > the CPU (133MHz) in 23ms at an average of 50 clock cycles per > > instruction not taking cache misses into account. I cannot concieve > > of any reason why it should take 61000 instructions to write the > > format, speed or stereo to the sound hardware. > > > > Does each ioctl result in a context switch which means that the cpu > > spends time on other processes for each ioctl call? I'm not sure > > that this is what happens because mpg123 uses 100% cpu for about > > 10 seconds and then settles down to about 40% once it actually > > starts decoding the mp3. > > Ian, > Sounds like you understand the problem, maybe you should > investigate :) Hmm, I was hoping someone familiar with the sound stuff would be able to say whether I was smoking my socks or not. This is very uncharted territory for me. I'll try to have a look and see if I can figure out what gives this week end. > My first guess would be the device is rebuilding feeder/mixer > chains every time mpg123 changes format. I would run the test one > more time, disabling vchans and rate conversion. > > sysctl hw.snd.report_soft_formats=0 hw.snd.maxautovchans=0 That didn't make a (noticeable) difference: 4090 mpg123 0.000603 CALL ioctl(0x3,SNDCTL_DSP_STEREO,0xbfbff864) 4090 mpg123 0.026047 RET ioctl 0 4090 mpg123 0.000582 CALL ioctl(0x3,SNDCTL_DSP_SPEED,0xbfbff864) 4090 mpg123 0.017735 RET ioctl 0 4090 mpg123 0.000414 CALL ioctl(0x3,SNDCTL_DSP_SETFMT,0xbfbff864) 4090 mpg123 0.026004 RET ioctl 0 > I didn't notice which version of fbsd that you are using. 5.2-CURRENT (2003-10-21 00:00:00 GMT) and 4.9-STABLE. Ian