Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-2118

Change some boundary checks in ArrayInputStream to ASSERTs to improve performance

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 10.2.1.6
    • 10.3.1.4
    • None
    • None
    • Performance

    Description

      Profiling shows that a significant amount of CPU is spent doing boundary checking in ArrayInputStream.setPosition() and ArrayInputStream.setLimit(). These checks appear to be there to detect error conditions, so it seems more appropriate to make them ASSERTs. Especially since they are so expensive.

      DTrace analysis seems to confirm that these methods get called very frequently:

      Knut Anders Hatlen wrote the following in a message on derby-dev:

      FYI, I just ran the DERBY-1961 test clients and traced them with a
      DTrace script that printed how often each method was called. For the
      join client, ArrayInputStream.setPosition() was the most frequently
      called method (43837.7 calls/tx). For the single-record select client,
      it was third (58.4 calls/tx), only beaten by Object.<init>() and
      DDMWriter.ensureLength(). I think this means that setPosition() is the
      engine method that is most frequently called, at least in read-mostly
      transactions. ArrayInputStream.setLimit() also appeared near the top
      of the list. See http://wiki.apache.org/db-derby/Derby1961MethodCalls
      for the details.

      Attachments

        1. setlimit.diff
          1 kB
          Knut Anders Hatlen
        2. cleanup_flat_profile.txt
          85 kB
          Dyre Tjeldvoll
        3. d2018_clearlimit_cleanup_diff.txt
          4 kB
          Daniel John Debrunner
        4. derby-2118.v2.diff
          2 kB
          Dyre Tjeldvoll
        5. derby-2118.diff
          2 kB
        6. derby-2118.stat
          0.4 kB

        Activity

          People

            dyret Dyre Tjeldvoll
            dyret Dyre Tjeldvoll
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: