From mboxrd@z Thu Jan 1 00:00:00 1970 From: jmk@plan9.bell-labs.com To: 9fans@cse.psu.edu Subject: Re: [9fans] Performance MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20010509125804.9473E199E7@mail.cse.psu.edu> Date: Wed, 9 May 2001 08:57:57 -0400 Topicbox-Message-UUID: 9c350ba6-eac9-11e9-9e20-41e7f4b1d025 On Wed May 9 04:44:05 EDT 2001, pschay@pobox.com wrote: > Hi, > > There are many things besides kernel compilation that > are also really fast compared to other systems: booting, > compiling the window system, running the window system, > .... > > Anyway, as fast as kernel compilation is, I do have some > questions about the performance. I tried a few ways of > profiling the kernel during kernel compilation. At first > I found that a lot of the kernel time was spent in halt() > so I changed HLT to NOP in l.s. Now almost a third of the > time is apparently spent in runproc(). > > Is this a fixable problem? Or is it actually the desired > behavior? (All I can imagine is that maybe the scheduler > sacrifices the good of the few for the good of the many and > me + my measly kernel compilation processes are not the > common case? Or perhaps scheduling typically consumes this > kind of overhead?) I know zilch about schedulers so > I'd greatly appreciate any insight, or pointers to > literature. I think I recall reading a brief posting a year > or two ago by one of the experts who said something to the > effect that the scheduler has lots of room for improvement. > Why? How? Could anybody elaborate? > > Thanks. > -Pete The system looks for processes to run by scanning the run queues in runproc(). If it doesn't find anything it just keeps looking until something is put in the queue. Nothing can be put in the queue except by an external event happening, i.e. some interrupt causes a process to change state. The HLT instruction waits until an interrupt occurs then continues. As you observed, you can replace HLT with a NOP (or take the call to the routine out entirely) to no ill effect, and this is what the system used to do. However, HLT gives the processor opportunities to conserve power and thereby run cooler and lengthen battery life, etc. Of course, on a multiprocessor, something can be put on the run queue by another processor without an external event occurring on this processor, so the HLT instruction isn't used in that case. --jim