-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
generic
-
generic
Although sun.misc.Unsafe.invokeSpecial() and invokeVirtual() are faster than
reflection for invoking no-arg methods, they are significantly slower for
methods which accept one or more parameters. This performance difference is
particularly important from the standpoint of object serialization--our merlin
prototype (which uses Unsafe invocation) runs significantly slower than the
reflection-based kestrel baseline on benchmarks which involve calling custom
serialization methods (e.g., class-defined writeObject()/readObject() methods).
Attached is a simple benchmark which compares the performance of
Unsafe.invokeVirtual/invokeSpecial vs. reflective invocation on a target method
accepting one argument. A typical result:
$ java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Server VM (build
product+2.0+unsafe-master+compiler2+20000811-180904-release, mixed mode)
$ java InvokeOneArg 1000000
direct invocation: 63
reflective invocation: 15906
unsafe invokeSpecial: 21092
unsafe invokeVirtual: 22529
While it may be outside the scope of merlin to optimize unsafe invocation of
methods with arbitrary numbers of parameters, the optimization of the
one-argument case alone would boost serialization performance significantly.
reflection for invoking no-arg methods, they are significantly slower for
methods which accept one or more parameters. This performance difference is
particularly important from the standpoint of object serialization--our merlin
prototype (which uses Unsafe invocation) runs significantly slower than the
reflection-based kestrel baseline on benchmarks which involve calling custom
serialization methods (e.g., class-defined writeObject()/readObject() methods).
Attached is a simple benchmark which compares the performance of
Unsafe.invokeVirtual/invokeSpecial vs. reflective invocation on a target method
accepting one argument. A typical result:
$ java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Server VM (build
product+2.0+unsafe-master+compiler2+20000811-180904-release, mixed mode)
$ java InvokeOneArg 1000000
direct invocation: 63
reflective invocation: 15906
unsafe invokeSpecial: 21092
unsafe invokeVirtual: 22529
While it may be outside the scope of merlin to optimize unsafe invocation of
methods with arbitrary numbers of parameters, the optimization of the
one-argument case alone would boost serialization performance significantly.