Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Improve jest execution time #9512

Closed
wants to merge 7 commits into from

Conversation

florianduros
Copy link
Contributor

@florianduros florianduros commented Oct 27, 2022

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

Following the issue element-hq/element-web#21971, the purpose here is to improve the execution time of jest tests.

  • 27/10/2022: ~14mins
  • 27/10/2022: ~13mins (removing output)

Analysis

  • When removing the output: 14mins to 11mins
    I executed multiple times the test, sometimes the executing is lesser, sometimes the same....
  • The longest test suite in the CI are the one which have a MaxListenersExceededWarning
    (node:78368) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 OwnBeaconStore.LivenessChange listeners added to [OwnBeaconStore]. Use emitter.setMaxListeners() to increase limit
    This point is interessant, in my laptop which has more ressources, the warning is present but the tests are not slowed by this issue.
    I expected to have a different execution time between the environnement but to have the same tests and test suites in the TOP 10 below.
  • Execution time analysis in the CI:
Top 10 slowest tests (12.905 seconds, 18.1% of total time):
  useDebouncedCallback should not call the callback if it’s disabled
    3.127 seconds ./test/hooks/useDebouncedCallback-test.tsx
  useDebouncedCallback should not debounce slow changes
    3.126 seconds ./test/hooks/useDebouncedCallback-test.tsx
  <Notifications /> renders spinner while loading
    1.865 seconds ./test/components/views/settings/Notifications-test.tsx
  useDebouncedCallback should debounce quick changes
    1.174 seconds ./test/hooks/useDebouncedCallback-test.tsx
  MVideoBody does not crash when given a portrait image
    0.822 seconds ./test/components/views/messages/MVideoBody-test.tsx
  ForwardDialog shows a preview with us as the sender
    0.619 seconds ./test/components/views/dialogs/ForwardDialog-test.tsx
  ThreadView sends a message with the correct fallback
    0.596 seconds ./test/components/structures/ThreadView-test.tsx
  useDebouncedCallback should be able to handle empty parameters
    0.563 seconds ./test/hooks/useDebouncedCallback-test.tsx
  useDebouncedCallback should call the callback with the parameters
    0.507 seconds ./test/hooks/useDebouncedCallback-test.ts
  useDebouncedCallback should handle multiple parameters
    0.506 seconds ./test/hooks/useDebouncedCallback-test.tsx

Top 10 slowest test suites (133.876 seconds, 20.3% of total time):
  54.939 seconds ./test/stores/SpaceStore-test.ts
  11.347 seconds ./test/components/views/rooms/RoomHeader-test.tsx
  10.808 seconds ./test/components/views/dialogs/UserSettingsDialog-test.tsx
  10.002 seconds ./test/hooks/useDebouncedCallback-test.tsx
  8.699 seconds ./test/components/views/dialogs/SpotlightDialog-test.tsx
  8.608 seconds ./test/components/views/settings/tabs/user/SessionManagerTab-test.tsx
  8.512 seconds ./test/components/views/elements/AppTile-test.tsx
  8.101 seconds ./test/components/structures/RoomView-test.tsx
  7.128 seconds ./test/components/views/rooms/MessageComposer-test.tsx
  5.732 seconds ./test/components/views/dialogs/ForwardDialog-test.tsx
  • Execution time analysis on my laptop:
Top 10 slowest tests (11.166 seconds, 25.0% of total time):
  useDebouncedCallback should not call the callback if it’s disabled
    3.138 seconds ./test/hooks/useDebouncedCallback-test.tsx
  useDebouncedCallback should not debounce slow changes
    3.127 seconds ./test/hooks/useDebouncedCallback-test.tsx
  useDebouncedCallback should debounce quick changes
    1.183 seconds ./test/hooks/useDebouncedCallback-test.tsx
  <Notifications /> renders spinner while loading
    0.948 seconds ./test/components/views/settings/Notifications-test.tsx
  useDebouncedCallback should be able to handle empty parameters
    0.548 seconds ./test/hooks/useDebouncedCallback-test.tsx
  useDebouncedCallback should call the callback with the parameters
    0.508 seconds ./test/hooks/useDebouncedCallback-test.tsx
  useDebouncedCallback should handle multiple parameters
    0.508 seconds ./test/hooks/useDebouncedCallback-test.tsx
  useLatestResult should return results
    0.421 seconds ./test/hooks/useLatestResult-test.tsx
  RightPanel navigates from room summary to member list
    0.394 seconds ./test/components/structures/RightPanel-test.tsx
  AccessSecretStorageDialog Considers a valid key to be valid
    0.391 seconds ./test/components/views/dialogs/AccessSecretStorageDialog-test.tsx

Top 10 slowest test suites (41.674 seconds, 12.2% of total time):
  9.453 seconds ./test/hooks/useDebouncedCallback-test.tsx
  5.798 seconds ./test/components/views/dialogs/SpotlightDialog-test.tsx
  4.143 seconds ./test/components/views/rooms/RoomHeader-test.tsx
  3.521 seconds ./test/components/views/settings/tabs/user/SessionManagerTab-test.tsx
  3.469 seconds ./test/components/views/rooms/MessageComposer-test.tsx
  3.243 seconds ./test/components/views/rooms/RoomListHeader-test.tsx
  3.029 seconds ./test/components/views/beacon/RoomCallBanner-test.tsx
  3.018 seconds ./test/components/views/rooms/RoomPreviewCard-test.tsx
  3.001 seconds ./test/components/views/rooms/EventTile-test.tsx
  2.999 seconds ./test/components/views/rooms/VoiceRecordComposerTile-test.tsx

This change is marked as an internal change (Task), so will not be included in the changelog.

@florianduros florianduros added the T-Task Refactoring, enabling or disabling functionality, other engineering tasks label Oct 27, 2022
@@ -26,7 +26,7 @@ jobs:
run: "./scripts/ci/install-deps.sh --ignore-scripts"

- name: Run tests with coverage
run: "yarn coverage --ci --silent > /dev/null 2>&1"
run: "yarn test --coverage --ci --reporters=jest-silent-reporter '--reporters=<rootDir>/test/reporter.js'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please use the github-actions reporter like we do for js-sdk? This shows the failures in the diff tab. It also silences the output in the logs. https://github.com/matrix-org/matrix-js-sdk/blob/develop/.github/workflows/tests.yml#L29

Copy link
Contributor Author

@florianduros florianduros Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll use it for the "final" run

Fyi, this PR is in a very WIP stage, more a playground for analysis and improvement :)

@florianduros florianduros deleted the tech/improve-execution-time-jest-test branch February 8, 2024 16:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Task Refactoring, enabling or disabling functionality, other engineering tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants