Curious profiler result - allocating connections is a long process for MySql

From: Scott Ellsworth (scot..lodar.com)
Date: Mon Jan 26 2004 - 19:29:12 EST

  • Next message: Andrus Adamchik: "Re: Curious profiler result - allocating connections is a long process for MySql"

    Hi, all.

    I am using the most recent mysql.jar, and Cayenne 1.0.5. I have very
    simple code to find the number of Games in my Game table. (This will
    eventually get expressions and the like to limit it to active games,
    but for now, I am still learning the tool.) This trivial program takes
    3149 ms to find the 213 games. When I ran a profiler, about half that
    was in evaluating the shared context.

    The code:

            public static void main(String[] args) {
                    long startTime = System.currentTimeMillis();
                    System.out.println("Number of games: " + getGameCount());
                    long deltaTime = System.currentTimeMillis()-startTime;
                    System.out.println("Game calc time: "+deltaTime);

            }

            public static int getGameCount(){
                    return getQueryResults(null).size();
            }

            private static List getQueryResults(Expression e) {
                    DataContext ctxt = createContext();
                    SelectQuery q = new SelectQuery(Game.class);
                    q.setPageSize(1);
                    return ctxt.performQuery(q);
            }

            /**
             * Creates and returns DataContext object.
             */
            private static DataContext createContext() {
                    Configuration.bootstrapSharedConfiguration(GameSummary.class);
                    return
    Configuration.getSharedConfiguration().getDomain().createDataContext();
            }

    The profiler results:
    Hot spots

    Session:
    Cayenne test

    Time of export:
    Monday, January 26, 2004 4:08:27 PM PST

    JVM time:
    01:25
        



      44.1% - 2201 ms - 1 inv.
    org.objectstyle.cayenne.access.DataContext.performQuery
        



      38.6% - 1929 ms - 1 inv.
    org.objectstyle.cayenne.conf.Configuration.getSharedConfiguration
        



      13.5% - 673 ms - 1 inv.
    org.objectstyle.cayenne.conf.Configuration.bootstrapSharedConfiguration
        



      2.5% - 122 ms - 1 inv.
    org.objectstyle.cayenne.access.DataDomain.createDataContext
        



      0.6% - 27 ms - 2 inv. java.lang.Class.forName
        



      0.4% - 19 ms - 1 inv. com.alodar.starmap.GameSummary.getQueryResults
        



      0.2% - 12 ms - 1 inv. com.alodar.starmap.GameSummary.main

    I am still experimenting with ways to reduce the time spent in
    performQuery, but I found the amount of time spent in
    getSharedConfiguration surprising - this is a standalone app, on a
    pretty unloaded machine.

    Should I have expected this?

    Scott



    This archive was generated by hypermail 2.0.0 : Mon Jan 26 2004 - 19:52:22 EST