From mboxrd@z Thu Jan 1 00:00:00 1970 From: daniel.baluta@gmail.com (Daniel Baluta) Date: Fri, 25 Feb 2011 19:15:59 +0200 Subject: syscalls performance In-Reply-To: References: Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Hi Mauro, On Fri, Feb 25, 2011 at 7:03 PM, Mauro Romano Trajber wrote: > I was doing some performance tests of system calls and I find an interesting > behavior. > Using RDTSC to count the CPU cycles, a single call to the getpid() consumes > about 7k of CPU clock cycles and ten calls consume approximately 9,800 > cycles. > The fact is that from the second call, the CPU cycles grows at a rate of > about 350 CPU cycles per call. > Why does this happen? There is some hardware optimization when the syscall > ID is already in EAX register ? Use strace and check to number of getpid() syscalls. You'll notice that only 1 system call is made, glibc caching the pid value. thanks, Daniel.