Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(reporters): update summary only when needed #7291

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

AriPerkkio
Copy link
Member

@AriPerkkio AriPerkkio commented Jan 19, 2025

Description

  • Fixes Vitest 3 runs 3 times slower than Vitest 2 #7285
  • Summary (and dot reporter) now instruct window renderer when an update is needed to render. Window rendered also schedules updates every 1s. In v3.0.2 and ^v2 Vitest was updating whole terminal every 16ms.

I'm unable to reproduce this using repro from #7285, but generated artificial test setup inside Windows VM. Using cmd.exe the execution time dropped from 50s to 38s in that setup. With Git Bash or Powershell there were no performance issues or any changes. On MacOS I'm unable to reproduce this at all.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

pkg-pr-new bot commented Jan 19, 2025

@vitest/browser

npm i https://pkg.pr.new/@vitest/browser@7291

@vitest/coverage-v8

npm i https://pkg.pr.new/@vitest/coverage-v8@7291

@vitest/expect

npm i https://pkg.pr.new/@vitest/expect@7291

@vitest/coverage-istanbul

npm i https://pkg.pr.new/@vitest/coverage-istanbul@7291

@vitest/mocker

npm i https://pkg.pr.new/@vitest/mocker@7291

@vitest/pretty-format

npm i https://pkg.pr.new/@vitest/pretty-format@7291

@vitest/runner

npm i https://pkg.pr.new/@vitest/runner@7291

@vitest/spy

npm i https://pkg.pr.new/@vitest/spy@7291

@vitest/snapshot

npm i https://pkg.pr.new/@vitest/snapshot@7291

@vitest/ui

npm i https://pkg.pr.new/@vitest/ui@7291

@vitest/utils

npm i https://pkg.pr.new/@vitest/utils@7291

vite-node

npm i https://pkg.pr.new/vite-node@7291

@vitest/web-worker

npm i https://pkg.pr.new/@vitest/web-worker@7291

vitest

npm i https://pkg.pr.new/vitest@7291

@vitest/ws-client

npm i https://pkg.pr.new/@vitest/ws-client@7291

commit: 428c6c5

@vitest-ecosystem-ci
Copy link

vitest-ecosystem-ci bot commented Jan 19, 2025

📝 Ran ecosystem CI: Open

suite result
vitest-reporters-large ✅ success

Copy link
Contributor

@TheJaredWilcurt TheJaredWilcurt left a comment

Choose a reason for hiding this comment

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

This PR fixed the performance issue for me.

Comment on lines +81 to +94
/**
* Queue new render update
*/
schedule() {
if (!this.renderScheduled) {
this.renderScheduled = true
this.flushBuffer()

setTimeout(() => {
this.renderScheduled = false
}, 100).unref()
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

@AriPerkkio AriPerkkio force-pushed the perf/summary-reporter branch from ede40e0 to 428c6c5 Compare January 20, 2025 06:50
@AriPerkkio AriPerkkio marked this pull request as ready for review January 20, 2025 06:51
Copy link

netlify bot commented Jan 20, 2025

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 428c6c5
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/678df23fa8dec10008410941
😎 Deploy Preview https://deploy-preview-7291--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sheremet-va sheremet-va merged commit 7f36b6f into vitest-dev:main Jan 20, 2025
14 checks passed
@AriPerkkio AriPerkkio deleted the perf/summary-reporter branch January 20, 2025 14:17
renovate bot added a commit to mmkal/eslint-plugin-mmkal that referenced this pull request Jan 21, 2025
##### [v3.0.3](/~https://github.com/vitest-dev/vitest/releases/tag/v3.0.3)

#####    🐞 Bug Fixes

-   **browser**:
    -   Don't throw a validation error if v8 coverage is used with filtered instances  -  by [@sheremet-va](/~https://github.com/sheremet-va) in vitest-dev/vitest#7306 [<samp>(fa463)</samp>](vitest-dev/vitest@fa4634b2)
    -   Don't fail when running --browser.headless if the browser projest is part of the workspace  -  by [@sheremet-va](/~https://github.com/sheremet-va) in vitest-dev/vitest#7311 [<samp>(e43a8)</samp>](vitest-dev/vitest@e43a8f56)

#####    🏎 Performance

-   **reporters**: Update summary only when needed  -  by [@AriPerkkio](/~https://github.com/AriPerkkio) in vitest-dev/vitest#7291 [<samp>(7f36b)</samp>](vitest-dev/vitest@7f36b6f9)

#####     [View changes on GitHub](vitest-dev/vitest@v3.0.2...v3.0.3)
renovate bot added a commit to mmkal/eslint-plugin-mmkal that referenced this pull request Jan 21, 2025
##### [v3.0.3](/~https://github.com/vitest-dev/vitest/releases/tag/v3.0.3)

#####    🐞 Bug Fixes

-   **browser**:
    -   Don't throw a validation error if v8 coverage is used with filtered instances  -  by [@sheremet-va](/~https://github.com/sheremet-va) in vitest-dev/vitest#7306 [<samp>(fa463)</samp>](vitest-dev/vitest@fa4634b2)
    -   Don't fail when running --browser.headless if the browser projest is part of the workspace  -  by [@sheremet-va](/~https://github.com/sheremet-va) in vitest-dev/vitest#7311 [<samp>(e43a8)</samp>](vitest-dev/vitest@e43a8f56)

#####    🏎 Performance

-   **reporters**: Update summary only when needed  -  by [@AriPerkkio](/~https://github.com/AriPerkkio) in vitest-dev/vitest#7291 [<samp>(7f36b)</samp>](vitest-dev/vitest@7f36b6f9)

#####     [View changes on GitHub](vitest-dev/vitest@v3.0.2...v3.0.3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vitest 3 runs 3 times slower than Vitest 2
3 participants