Hi all,

I've started a small side project to see where OpenJPA stands against
the other JPA providers. Idea was to see, if we have a performance regression
from 4.1 to 4.2 ;-)

  Code:    https://github.com/rzo1/jpa-bench
  Results: https://rzo1.github.io/jpa-bench/

It is a JMH benchmark (in the spirit of jpab.org): the same model, the
same deterministic data and equivalent settings for every provider
(CONFIG.md).

Runners:
  - OpenJPA 4.1.1 and 4.2.0-SNAPSHOT (build-time and javaagent
    enhancement)
  - Hibernate 6.6 and 7.x (plain and enhanced)
  - EclipseLink 4 and 5 (unwoven and woven)

on H2 and PostgreSQL.

Besides time, it records the SQL statements and JDBC calls per
operation, and all read results are cross-checked, so every provider
does the same work.

First full run (MacBook Pro, dataset S), OpenJPA 4.2 vs. Hibernate 7 /
woven EclipseLink 5 (>1 = OpenJPA slower):

H2 (database cost close to zero, so it shows provider overhead):
OpenJPA is clearly behind, with the same statement counts:
  - findById:                        2.2x / 2.8x
  - lazy N+1 navigation:             2.2x / 3.7x
  - ManyToMany + ElementCollection:  3.1x / 4.3x

The cost seems to be per transaction and per loaded entity; profiling
is the next step.

PostgreSQL: OpenJPA leads overall, mostly because single-row reads are
about 2x faster. That is not faster SQL: with the default optimistic
transactions OpenJPA sends no COMMIT for read-only transactions, while
Hibernate and EclipseLink commit, i.e. one round trip less (visible in
the jdbcCommits metric).

removeBatch: OpenJPA sends 429 statements instead of 251 (229 SELECTs
instead of 51), because it loads the referenced customers and products
before deleting (RelationFieldStrategy.delete). 1.6x / 3.9x slower on
PostgreSQL. Looks like a good candidate for an improvement.

joinFetch: same single statement, but 1.5x / 1.8x slower on H2 and 2.2x
slower than EclipseLink on PostgreSQL, so the fetch-join result
processing is worth a look.

4.1 and 4.2 are on par, which is the good news:
build-time and runtime enhancement make no
difference in throughput.

One machine and one run so far, so please read the numbers with that
in mind. If you think a provider is configured unfairly, issues and PRs
are welcome. Runs from other machines can be contributed as a PR
against the "results" branch (see the README).

Gruß
Richard

Reply via email to