Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-9963

Performance degradation when reading system properties on each NodeImpl

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.22.11
    • None
    • jcr
    • None

    Description

      Reading system properties on each NodeImpl causes performance issues especially on Java 8.
      Code:

          public NodeImpl(T dlg, SessionContext sessionContext) {
              super(dlg, sessionContext);
              logWarnStringSizeThreshold = Integer.getInteger(
                      OakJcrConstants.WARN_LOG_STRING_SIZE_THRESHOLD_KEY,
                      OakJcrConstants.DEFAULT_WARN_LOG_STRING_SIZE_THRESHOLD_VALUE);
          }
      

      One more important point on system property lookup in Oak. There is a huge difference between running the code on Java 8 and 11. 

      The following test looks up a system property with 32 concurrent threads. Each reading the system property 10M times.

          @Test
          public void run() throws Exception {
              List<Thread> threads = new ArrayList<>();
              for (int i = 0; i < 32; i++) {
                  threads.add(new Thread(this::getProperty));
              }
              Stopwatch sw = Stopwatch.createStarted();
              threads.forEach(Thread::start);
              for (Thread t : threads) {
                  t.join();
              }
              System.out.println("time: " + sw);
          }
      
          private void getProperty() {
              for (int i = 0; i < 10_000_000; i++) {
                  System.getProperty("foo");
              }
          }
      

      On my machine the outputs are:

      Java 8: ~20 seconds
      Java 11: 0.5 seconds
      Reason is how Properties implementation changed with Java 11. It is now using a ConcurrentHashMap.

      Attachments

        Activity

          People

            Unassigned Unassigned
            chibulcu Paul Chibulcuteanu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: