This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Exception Handling


Hello,

I am working with gcj for PowerPC linux, and was looking for some insight into the cause of some poor benchmark performance on exception handling, esp. when compiling java to native code. The UCSD benchmark (available from here http://waitaki.otago.ac.nz/~bryce/gcj/) was **absurdly** dominated by exception handling time, especially when compared to other java implementations. I also ran the benchmark (also compiled with gcj to native code) on an x86, and Sun SPARC computer as well to make sure that it was a problem with gcj, not a PowerPC specific issue. I also noticed the problem when using gij to interpret byte code (even byte code that had been compiled w/ Sun's javac).

To give you an idea of how slow exceptions are here are the results of running the benchmark on a Sun Ultra 60, first compiled to native code with -O3 using gcj vs. interpreted, unoptimized compile, using javac/java. (I've included the full output at the end of this message). Even though gcj was about 20% faster with the exception test factored out, it lost by a _factor_ of 15.2x overall just because of exception handling.

                                   Exception Handling
               Total Time Taken         Test Time
Compiler     (smaller is better)  (smaller is better)
gcj -O3        67.765 seconds       66.224 seconds
javac          4.472 seconds        2.646 seconds


Does anybody know why exceptions in gcj are so slow? How are they currently implemented?


Thanks,
--Vincent

Here is the full output from the benchmark.
$ gcj Benchmark.java Timer.java --main=Benchmark -O3
$ ./a.out
Benchmark                                             Time (sec)
----------------------------------                    ----------

Empty loop iterated 1000000 times:                         0.002
Added 1000000 ints in loop:                                0.028
Multipled 1000000 ints in loop:                            0.076
Added 1000000 doubles in loop:                             0.031
Multipled 1000000 doubles in loop:                         0.031
Assigned to 1000000 array ints:                            0.025
1000000 object int field accesses:                         0.011
1000000 method calls in same object:                       0.079
1000000 method calls in other object:                      0.090
Threw and caught 1000000 exceptions:                      66.224
3 threads, switched 10000 times each:                      0.107
System.gc() w/ 1335296B memory avail of 8118272B total
GC'd 2535424B, leaving 3870720B of 8118272B total:         0.042
2000 obj rand. new'd/assigned (avg 2530B), 880 GC'd:       0.161
100000 writes of 1 byte:                                   0.784
1 write of 100000 bytes:                                   0.002
Cumulative runtime:                                       67.765
System Configuration
--------------------
Architecture:                                            unknown
OS:                                                      unknown
OS version:                                              unknown
Java interpreter vendor:          Free Software Foundation, Inc.
Java version:                                              3.2.2
Benchmark version:                                           1.0
Benchmark mode:                                      application
Benchmark optimization:                              unspecified



$ javac Benchmark.java Timer.java
$ java Benchmark
Benchmark                                             Time (sec)
----------------------------------                    ----------
Empty loop iterated 1000000 times:                        0.0090
Added 1000000 ints in loop:                                0.028
Multipled 1000000 ints in loop:                            0.043
Added 1000000 doubles in loop:                             0.031
Multipled 1000000 doubles in loop:                         0.030
Assigned to 1000000 array ints:                            0.026
1000000 object int field accesses:                         0.011
1000000 method calls in same object:                      0.0090
1000000 method calls in other object:                      0.028
Threw and caught 1000000 exceptions:                       2.646
3 threads, switched 10000 times each:                      0.042
System.gc() w/ 4081160B memory avail of 8388608B total
GC'd 4170048B, leaving 8251208B of 8388608B total:         0.014
2000 obj rand. new'd/assigned (avg 2530B), 724 GC'd:       0.100
100000 writes of 1 byte:                                   1.242
1 write of 100000 bytes:                                  0.0040
Cumulative runtime:                                        4.472
System Configuration
--------------------
Architecture:                                              sparc
OS:                                                        SunOS
OS version:                                                  5.8
Java interpreter vendor:                   Sun Microsystems Inc.
Java version:                                              1.2.2
Benchmark version:                                           1.0
Benchmark mode:                                      application


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]