Fix test performance of Drupal\system\Tests\Cache\PageCacheTagsIntegrationTest

Created on 29 April 2014, about 10 years ago
Updated 23 January 2024, 5 months ago

Problem/Motivation

Speed up testbot and simplify tests by using the testing profile instead of the standard profile.

Steps to reproduce

Proposed resolution

Convert Drupal\node\Tests\NodeAccessBaseTableTest to use the testing profile, not the standard profile.

On gitlab CI, the test running time changes from 24.35s to 9.17s.

Remaining tasks

Update patch
Review
Commit

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

πŸ“Œ Task
Status

Fixed

Version

10.2 ✨

Component
SystemΒ  β†’

Last updated 1 day ago

No maintainer
Created by

πŸ‡©πŸ‡ͺGermany sun Karlsruhe

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    I have been playing with this while down with a bug. I am stuck on creating the cache tags for 'config:search.settings'

  • Issue was unassigned.
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Oh I'll leave for you then.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    @smustgrave, leaving it to me is not a good idea. When I said I was stuck I meant it. I do not know how to fix the remaining test errors.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • Status changed to Needs review 7 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Crediting @catch for helping with the user-role cache tag issue. https://drupal.slack.com/archives/C04CHUX484T/p1701362984050229

  • Status changed to Needs work 6 months ago
  • πŸ‡΅πŸ‡ͺPeru marvil07

    A few more modules may be removed from the install list, please find details at https://git.drupalcode.org/project/drupal/-/merge_requests/5625#note_238407 .

  • Status changed to Needs review 6 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    @marvil07 , thanks for pointing out that the list of modules could be reduced. I did my own testing as well and adjusted the list.

    but I am not quite sure how they can be used without declaring them; maybe it they are enabled indirectly?

    As a functional test using BrowserTestBase this uses the moduleInstaller which will install modules that are declared as dependencies.

  • Status changed to RTBC 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Removal of additional modules seems good.

  • Status changed to Needs work 6 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    This is kind of defeating the purpose πŸ˜… The purpose was to ensure that Page Cache works well in real scenarios, and that's best served by the Standard install profile (or Umami at this point).

    However, if there's a significant speed-up, I'd agree this is worth it β€” a fine trade-off. 😊 πŸ‘

    What's missing from the issue summary: the actual speed-up is of GitLab CI test runs?

  • Merge request !5709Draft: Resolve #2254209 "Before" β†’ (Open) created by marvil07
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    @marvil07 before we open a new MR can we agree if the test coverage is being lost by changing this.

    And if we need to update can use the existing MR as it's pointing to the correct 11.x branch. Just to avoid multiple branches floating around.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    So wonder if we should copy the existing test to standard folder

    And keep what's specific for page_cache in this file.

  • πŸ‡¬πŸ‡§United Kingdom catch

    What's missing from the issue summary: the actual speed-up of GitLab CI test runs?

    This test class only has a single test method and isn't one of the very slowest tests, so it's more about overall load than job speed.

    gitlab does record how long a test method takes to run, but it's not that easy to find:

    https://git.drupalcode.org/project/drupal/-/pipelines/59193/test_report

    Click through to functional tests, then click through the pages, until you get to PageCacheTagsIntegrationTest - then would have to do the same for a core test run on the default environment too.

    I assume that this timing includes ::setUp() but haven't actually confirmed that.

  • πŸ‡΅πŸ‡ͺPeru marvil07

    marvil07 β†’ changed the visibility of the branch 2254209-before to hidden.

  • πŸ‡΅πŸ‡ͺPeru marvil07

    @smustgrave, hey sorry for the noise here πŸ˜…

    I have been trying to answer the question from Wim.

    Measuring

    What's missing from the issue summary: the actual speed-up of GitLab CI test runs?

    On gitlab CI, it is not as trivial to find out.

    Using the codebase at the point the code changes started is a good way to compare the running time.
    That is what I have tried, opened a new MR without the changes (I needed to add one so pipelines are triggered, but it is just adding a comment), only for comparison.

    Locally, as reported above πŸ“Œ Fix test performance of Drupal\system\Tests\Cache\PageCacheTagsIntegrationTest Needs work , I see a time change from 24s to 18s on the changed test running time.

    We could compare the total running time, but I am guessing that may have lots of other variables that could influence the run.
    E.g. test runners may change in time, the actually used ones can differ, the context they are in at the time of the run is important for performance measuring, etc.

    Having all that in mind, I see a jump from 12 minutes 14 seconds to 7 minutes 24 seconds.
    That is unlikely explained by the test change, see above in this comment that the jump on a not-that-fast local computer is of just 6s.

    @catch, thanks a lot for pointing that out.
    I was surprised that there is no download to explore in a text file πŸ˜…

    Looking at the results of the two runs of testPageCacheTags:

    - without the change, MR 5709, reports 24.35s, on page 7 at https://git.drupalcode.org/issue/drupal-2254209/-/pipelines/60135/test_r...
    - with the change, MR 5625, reports 9.17s, on page 59 at https://git.drupalcode.org/project/drupal/-/pipelines/59193/test_report

    Approach

    @Wim Leers, re: #32:

    If the idea is to test in a real scenario, and standard profile can represent that, we should document that the test is not expecting to be moved to a different profile.
    Idem if the target profile is umami, but in that case it sounds way out of scope here.

    I would suggest to actually use the topic branch, the test is not doing performance testing, it is ensuring right behavior.
    That should not be affected by the context profile; but if that is the case, the test is likely wanted to be expanded to cover multiple scenarios, including with multiple profiles, and again that is likely out of scope of this issue.

  • Status changed to Needs review 6 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    - without the change, MR 5709, reports 24.35s, on page 7 at https://git.drupalcode.org/issue/drupal-2254209/-/pipelines/60135/test_r...
    - with the change, MR 5625, reports 9.17s, on page 59 at https://git.drupalcode.org/project/drupal/-/pipelines/59193/test_report

    This seems about right for the change to me. For one test it has very little impact at all, but if we do it for lots of tests (which we've been slowly doing) it will eventually make a difference.

    Not sure what that means for the loss of coverage here though - it might be better to just move this test to the standard profile so it's taken out of the list of targets to move to the testing profile?

  • πŸ‡΅πŸ‡ͺPeru marvil07

    @catch, thanks for the feedback!

    This seems about right for the change to me. For one test it has very little impact at all, but if we do it for lots of tests (which we've been slowly doing) it will eventually make a difference.

    The way I think about it πŸ’‘: we run the test suite a lot every day, so any improvement over time running will be multiplied by the number of times it is executed, which is a lot, and therefore the change likely makes sense.
    Here there is around 15 seconds gained on every testsuite run, let us say 10s, which multiplied by the runs for every MR push on any issue fork, plus the actual commits on core, is likely a reasonable gain itself.

    Not sure what that means for the loss of coverage here though [...]

    @Wim Leers, I guess this is a question for you.
    Please find the Approach section in comment #34 above, with some ideas on next steps.

  • Status changed to RTBC 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    @Wim Leers feel free to move back if you disagree

    But looking at the test it seems to just be about the functionality of page_cache, which wasn't lost because we are installing the appropriate modules.

    If the concern is that the Standard profile doesn't have page_cache test coverage then a follow up could be opened to add a standard specific page_cache test I think. And probably could be expanded on to include the other modules and config that ship with standard.

  • Status changed to Needs review 6 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    Let's get a definitive answer from @Wim Leers first. I am setting back to NR.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    I pinked @Wim Leers in Slack #contribute about this.

  • Status changed to RTBC 6 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    #38:

    - without the change, MR 5709, reports 24.35s, […]
    - with the change, MR 5625, reports 9.17s, […]

    #42:

    If the concern is that the Standard profile doesn't have page_cache test coverage then a follow up could be opened to add a standard specific page_cache test I think. And probably could be expanded on to include the other modules and config that ship with standard.

    That was indeed my concern. But to be fair, it is a test owned by the page_cache module, not the Standard install profile.

    Let me get out of the way here, but thank you for showing how much faster this made the test, that is still a valuable addition after my pushback in #32 😊

    • catch β†’ committed 56c825fc on 10.2.x
      Issue #2254209 by smustgrave, marvil07, quietone, sun, catch, Wim Leers...
    • catch β†’ committed 57ca853a on 11.x
      Issue #2254209 by smustgrave, marvil07, quietone, sun, catch, Wim Leers...
  • Status changed to Fixed 5 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Committed/pushed to 11.x and cherry-picked to 10.2.x, thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024