Re: [cacao] RFC: class-loading is very slow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2007-05-16 at 19:44 +0200, Mark Wielaard wrote:
> Hi Christian,
> 
> On Thu, 2007-05-03 at 16:32 +0200, Christian Thalinger wrote:
> > I'm writing this to the list to get some feedback and to not forget this
> > issue.
> > 
> > I've written a testcase which loads all classes of the bootstrap
> > archives and it's much slower with cacao than with jamvm.  Sun's RI is
> > also much faster.
> > 
> > We should investigate that...
> 
> That is an interesting testcase. Could you post it to the classpath
> mailinglist to get some input from other runtime experts?

Sure.  This testcase was actually written to hit a bug in CACAO, that's
why there are these classcasts.

- twisti


---


import java.io.*;
import java.util.*;
import java.util.zip.*;

public class thread extends Thread {
    boolean doit = true;
    String classname = null;

    public thread() {
        new A().start();
        new B().start();
    }

    public static void main(String[] argv) {
        new thread();
    }

    class A extends Thread {
        public void run() {
            try {
                sleep(1000);
            } catch (Exception e) {
                e.printStackTrace();
            }

            sub(new Integer(1));
        }

        void sub(Object o) {
            Integer io = null;
            int i = 0;

            while (doit) {
                try {
                    io = (Integer) o;
                } catch (ClassCastException cce) {
                    cce.printStackTrace();
                    System.out.println("while loading " + classname);
                }

                i++;
            }

            System.out.println("done: io=" + io + ", i=" + i);
        }
    }

    class B extends Thread {
        public void run() {
            String bootclasspath = System.getProperty("sun.boot.class.path");

            for (String s: bootclasspath.split(":")) {
                System.out.println("file: " + s);
                File f = new File(s);
                ZipFile zf = null;

                try {
                    zf = new ZipFile(f);
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }

                System.out.println("size: " + zf.size());

                for (Enumeration<? extends ZipEntry> entries = zf.entries(); entries.hasMoreElements(); ) {
                    ZipEntry entry = entries.nextElement();
                    String name = entry.getName();

                    if (name.endsWith(".class")) {
                        int index = name.indexOf(".class");
                        classname = name.substring(0, index).replace("/", ".");

                        try {
                            Class.forName(classname, false, null);
                        } catch (ClassNotFoundException cnfe) {
                            cnfe.printStackTrace();
                        }
                    }
                }

                System.out.println("classes loaded");
            }

            doit = false;
        }
    }
}



[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux