Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-1667

Expression parser performance optimization

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1M3
    • 3.1B1
    • Core Library
    • 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.

      Attachments

        Activity

          People

            andrus Andrus Adamchik
            andrus Andrus Adamchik
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: