PATCH: Improve Java build times

Zack Weinberg
Sun May 19 11:09:00 GMT 2002

On Sun, May 19, 2002 at 09:58:56AM -0700, Mark Mitchell wrote:
> I analyzed why building libjava (and presumably any other Java
> program) took so long to build.

> 1. Cache negative lookups of class names so that we do not do them 
>    again.  (This is the part of the patch responsible for the
>    reduction in user time; we avoid running through the linked list
>    of directories.)
> 2. Cache the contents of directories in the class path (using scandir
>    to read the directory) and avoid calling stat for files we know do
>    not exist.

I see that find_class uses stat() to determine whether files exist,
then calls open() later on its final choice.  This incurs an extra
in-kernel namei (directory walk) operation on systems that don't have
a "dcache" (i.e. everyone except Linux and *BSD).  There is an
additional performance gain to be had from switching this around, so
that it determines whether files exist by calling open(), then uses
fstat() to get at the modification times.

Also, JCF_USE_STDIO is defined nowhere -- suggest ripping out that
option entirely.  Code that uses stat does not gain any portability
from using stdio.

A broader question: Why is this code using the obsolete DEFUN()
notation?  These programs are only compiled with GCC - why do they
have K+R compat notation at all?


More information about the Java mailing list