A few micro-benchmarks for Jython 2 and two other ideas

Jeff Allen <[email protected]> Tue, 5 Jan 2021 23:55:15 +0000
Newsgroups gmane.comp.lang.jython.devel
Message-ID <[email protected]>
I've been thinking about the implementation of a Jython core that would 
make proper use of dynamic language features in Java.

Although peformance is secondary to correctness, one would like to avoid 
producing elegantly correct code that could only ever run like a slug. 
Numerical operations are indispensible, so I constructed JMH benchmarks 
for dispatch of unary and binary operations on int and float, when these 
are "hot code". The short version of the results is:

1. A core may be implemented (called here VSJ 2) that broadly follows 
CPython, but uses a Java method handle in place of each C pointer to 
function, and it will run at an acceptable speed. (Comparison is 
difficult between JMH and timeit, but it is fair to say VSJ 2 has "about 
the speed of CPython".)

2. Jython 2 is a lot faster than VSJ 2, almost certainly because HotSpot 
in-lines and specialises virtual calls so effectively.

3. We may use the method handles from VSJ 2 in invokedynamic call sites. 
The result is a little faster than Jython 2 in places, and significantly 
slower in others. However, there is scope for further optimisation.

A longer version is here: 
https://the-very-slow-jython-project.readthedocs.io/en/latest/performance/_performance.html

Jeff

-- 
Jeff Allen