Title: ElementTree parse is about 300 times slower under Jython (compared to CPython)
Type: Severity: normal
Components: Versions:
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: boisgera, kfitch42, pjenvey, zyasoft
Priority: high Keywords:

Created on 2009-05-07.20:21:22 by kfitch42, last changed 2009-05-10.20:01:33 by zyasoft.

File name Uploaded Description Edit Remove kfitch42, 2009-05-07.20:21:22
msg4655 (view) Author: Kevin Fitch (kfitch42) Date: 2009-05-07.20:21:21
$ wget
$ python
$ jython

I have done some testing on a variety of files using jython 2.5b4 and
current trunk (r6311) on ubuntu 8.04 (both 64bit and 32bit), and
slowdown of a factor of 300 to 400 is pretty common.
msg4657 (view) Author: Philip Jenvey (pjenvey) Date: 2009-05-07.20:32:20
Sébastien - can you look into this?
msg4659 (view) Author: (boisgera) Date: 2009-05-08.08:02:23
Yes, I'm on it. I was expecting a poor performance for the Jython version 
of ElementTree (the expat module being pure Jython, not Java), but 
definitely not 5 secs for a 200-line xml file.
msg4660 (view) Author: (boisgera) Date: 2009-05-08.11:48:22
I think that I've found the bottleneck: shame on me for using 'eval' for
convenience ... expect a fix in the next few days.
msg4662 (view) Author: Philip Jenvey (pjenvey) Date: 2009-05-08.19:20:11
Thanks Sébastien. FYI we're aiming to release a release candidate on about 
msg4663 (view) Author: (boisgera) Date: 2009-05-09.10:17:25
fixed in r72 of Expect a
slowdown factor of 20 instead (rough estimate) with respect to CPython.

A benchmark has been added to measure this performance:
benchmark$ python
ElementTree benchmark -- Python 2.5 on linux2
  alice.fodt    : 0.11465 s
  tiny.xml      : 0.00010 s
  lion.svg      : 0.00396 s
  cd_catalog.xml: 0.00957 s

benchmark$ jython
ElementTree benchmark -- Python 2.5b3 on java1.6.0
  alice.fodt    : 0.81000 s
  tiny.xml      : 0.00200 s
  lion.svg      : 0.06600 s
  cd_catalog.xml: 0.09600 s
msg4666 (view) Author: Philip Jenvey (pjenvey) Date: 2009-05-10.19:11:29
Thanks a bunch Sébastien, speedup applied in r6330
msg4667 (view) Author: Jim Baker (zyasoft) Date: 2009-05-10.20:01:32
When I run the original test by kfitch42 with 100 iterations (to allow
hotspot to kick in), Jython is now about 7x slower. No doubt there is
still room for optimizations, but this is not so bad.

However, that's the python version of ET. cElementTree on CPython is
about 100x faster still! So there is significant room for improvement by
profiling and writing the core of our Jython implementation in Java.
Date User Action Args
2009-05-10 20:01:33zyasoftsetnosy: + zyasoft
messages: + msg4667
2009-05-10 19:11:29pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg4666
2009-05-10 06:53:36pjenveysetpriority: high
assignee: pjenvey
2009-05-09 10:17:26boisgerasetmessages: + msg4663
2009-05-08 19:20:12pjenveysetmessages: + msg4662
2009-05-08 11:48:23boisgerasetmessages: + msg4660
2009-05-08 08:02:23boisgerasetmessages: + msg4659
2009-05-07 20:32:20pjenveysetnosy: + pjenvey, boisgera
messages: + msg4657
2009-05-07 20:21:22kfitch42create