Hacker Newsnew | past | comments | ask | show | jobs | submit | evab's commentslogin

Can anyone explain why the "gemini" framework with an ORM outperforms raw servlets/queries in almost all the cases?

What kind of optimizations are done ?


Evab, Gemini is our in-house framework [1] that we've included in these tests for our own learning experience. We're not obsessed with performance, but we do try to avoid problems that are easily avoided. :) For instance, where possible, we have used Java's concurrent data structures and reduced the use of locks.

A difference in these tests is that we have our own connection pool. Speed was not a main objective when we wrote it--it's so old that if my memory is correct, it predates the availability of the connection pool that now ships with the MySQL driver, which is what we've used in the Servlet tests. Nevertheless, my conjecture is that perhaps it's just a tad quicker at selecting an idle connection. Incidentally, for a while in an earlier round, the Go guys had an alternate test implementation that used a concurrent queue for connections and it performed fantastically. We've been toying with changing Gemini to do the same at some point.

For the benchmarks project, we classified ORMs as "raw" (no ORM), micro, or full. In Gemini, we have a micro ORM. The following are examples of its use in the test code [2]:

    // Get all rows from Fortunes table.
    final List<Fortune> fortunes = store.list(Fortune.class);

    // Get a random World row.
    worlds[i] = store.get(World.class, random.nextInt(DB_ROWS) + 1);

    // Run a batch of updates from a List of entity objects.
    store.putAll(Arrays.asList(worlds));
"Micro ORM" is loosely defined, but we've applied it to ORM options that offer some abstraction over plain old SQL, but aren't as comprehensive as the standard-bearers. For example, while we have a data structure that represents relationships, we do not have a higher-level query language that traverses relationships automatically nor any similar mechanism for easy relationship traversal. It turns out that across all of these frameworks, there are dozens of what we are calling Micro ORMs.

Getting back to your question, the Gemini ORM does leverage a few tricks for performance such as ReflectASM for object creation and prepared statements for queries. But there isn't a whole lot of fancy work going on.

It's not glamorous, but the most important high-performance elements we make use of in Gemini are the JVM platform and Java's concurrent data structures. As demonstrated by the likes of Undertow (the web server component of JBoss WildFly), mind-boggling performance is available on the JVM.

[1] https://groups.google.com/d/msg/framework-benchmarks/p3PbUTg...

[2] https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast...


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: