Cayenne
  1. Cayenne
  2. CAY-1667

Expression parser performance optimization

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1M3
    • Fix Version/s: 3.1B1
    • Component/s: Core Library
    • Labels:
      None

      Description

      Inspecting some profiling data from a customer I see an inefficiency inside Expression.fromString. It was actually discovered inside Ordering class, that compiles path string on demand, so it affects even the queries that do not use 'fromString', as well Orderings created for in-memory sorting. There are 2 culprits in JavaCharStream that is generated by javaCC (although JavaCharStream is not a part of the parser, so we can probaby change the code on top of the generated class) :

      1. JavaCharStream.fillBuff() has throw new java.io.IOException(); that is caught right in that same method (!!!) Throwable.fillStackTrace() shows as a "hot spot" in the profile. There should be a better way to handle if/else condition

      2. Expression.fromString -> new ExpressionParser(Reader) -> new JavaCharStream(Reader, int startline, int startcolumn)
      JavaCharStream constructor is heavy and shows as a hotspot. For one thing it creates 4 int/char buffers with size of 4096 each. I don't think we have such long expressions ever, and don't need all this memory. Moreover we can probably guess the max needed buffer size from the original String length. My guess is that most expressions are under 100-300 chars. Certainly true for the orderings.

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Andrus Adamchik
            Reporter:
            Andrus Adamchik
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development