Subject: Re: Performance Problem: malloc() is calling madvise()
To: Bill Dorsey <dorsey@lila.com>
From: David Brownlee <abs@netbsd.org>
List: current-users
Date: 05/19/2000 12:40:05
	(Reply-to set to current-users as netbsd-ports is for porting to
	new platforms)

	What happens if you set MALLOC_OPTIONS to 'h' in the environment
	with the new libc?



		David/absolute
				       -- www.netbsd.org: No hype required --

On Fri, 19 May 2000, Bill Dorsey wrote:

> Hi,
> 
> I upgraded to the 20000505 snapshot yesterday (1.4Y) and noticed
> a serious performance loss when running one of my programs.
> 
> The program I was running is a number-crunching program that
> uses malloc() pretty heavily (via the C++ new function).
> Between the 1.4.2_Alpha release I was running and the 1.4Y
> release I upgraded to, the program slowed down by a factor
> of 4 on my Personal Workstation!!!
> 
> Looking at top, I had my first clue as to what the problem
> was.  It was showing about 33% of the CPU time being spent
> running my program and 66% of the time in the system.  I
> proceeded to run a ktrace on the program and was rewarded
> with data at the rate of more than 1 megabyte per second
> being written to ktrace.out!
> 
> After stopping the ktrace, I ran kdump to see what was going
> on.  The madvise() system call was being called millions of
> times per second from what I could see.
> 
> Investigating further, I discovered that madvise() is called
> by malloc in libc.so.  When I switched the libc.so with an
> older version (from 1.4.2_Alpha), the performance returned to
> normal.
> 
> If this hasn't been fixed in -current, I'd be pleased if someone
> would look into it.  I don't understand why you'd want to make
> a system call in malloc() anyway given the obvious performance
> implications so I assume this is in error.
> 
> In the meantime, I have noticed no ill effects from replacing
> the libc.so file with the older one from 1.4.2_Alpha and I'll
> continue to do so until this is addressed.
> 
> --
> Bill Dorsey
> 
>