Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-12265

Node type registration is inefficient during unit tests when using the JCR_OAK resolver type

Details

    Description

      I did some profiling on my company's slow-running unit tests today, and found that 70+% of the CPU time is spent inside NodeTypeDefinitionScanner, more specifically in the commit() call triggered by it. Our test classpath includes AEM Mocks and the Cloud SDK, resulting in 30+ CND files being detected, and as many commits done preparing the repository before each test. (Slightly more, because some commits fail and get retried later.)

      It should be possible to parse each CND into memory structures in a separate pass, then create the node types all at once in a single commit. This wouldn't just eliminate the extra commits, but would also remove the need to retry, since all dependencies would also be provided in the same call.

      Attachments

        Issue Links

          Activity

            Csaba Varga Csaba Varga added a comment -

            I have already made some experimental changes on this today, and my unit tests complete noticeably faster with my tentative improvement. I will open a PR today or tomorrow with the proposed changes.

            Csaba Varga Csaba Varga added a comment - I have already made some experimental changes on this today, and my unit tests complete noticeably faster with my tentative improvement. I will open a PR today or tomorrow with the proposed changes.
            sseifert Stefan Seifert added a comment -

            thanks for the contribution! i've added comments in the PR.

            sseifert Stefan Seifert added a comment - thanks for the contribution! i've added comments in the PR.
            sseifert Stefan Seifert added a comment - https://github.com/apache/sling-org-apache-sling-testing-sling-mock/commit/4ff35ad95143d85bc1f91888cd53a3f624f86e06

            People

              sseifert Stefan Seifert
              Csaba Varga Csaba Varga
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: