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

Severe performance regression in 3.0.4+ #7488

Closed
6 tasks done
jacquesg opened this issue Feb 13, 2025 · 12 comments
Closed
6 tasks done

Severe performance regression in 3.0.4+ #7488

jacquesg opened this issue Feb 13, 2025 · 12 comments

Comments

@jacquesg
Copy link

Describe the bug

I've noticed a severe performance regression, first appearing in 3.0.4, 3.0.3 is not affected:

Before 3.0.4:

 RUN  v3.0.3 /Users/jacquesg/dev/projects/asterias/antaeus

 ✓ src/features/ng/admincompanymodal/admincompanymodal.test.tsx (17 tests) 7838ms
   ✓ admincompanymodal > name > min length
   ✓ admincompanymodal > name > max length 739ms
   ✓ admincompanymodal > address line 1 > min length
   ✓ admincompanymodal > address line 1 > max length 715ms
   ✓ admincompanymodal > address line 2 > min length
   ✓ admincompanymodal > address line 2 > max length 702ms
   ✓ admincompanymodal > street name > min length
   ✓ admincompanymodal > street name > max length 706ms
   ✓ admincompanymodal > locality > min length
   ✓ admincompanymodal > locality > max length 725ms
   ✓ admincompanymodal > county > min length
   ✓ admincompanymodal > county > max length 680ms
   ✓ admincompanymodal > region > min length
   ✓ admincompanymodal > region > max length 688ms
   ✓ admincompanymodal > postal code > min length
   ✓ admincompanymodal > postal code > max length 684ms
   ✓ admincompanymodal > submit 1222ms

 Test Files  1 passed (1)
      Tests  17 passed (17)
   Start at  17:09:13
   Duration  10.78s (transform 1.16s, setup 210ms, collect 2.34s, tests 7.84s, environment 150ms, prepare 34ms)

3.0.4 and 3.0.5:

 RUN  v3.0.5 /Users/jacquesg/dev/projects/asterias/antaeus

 ✓ src/features/ng/admincompanymodal/admincompanymodal.test.tsx (17 tests) 23507ms
   ✓ admincompanymodal > name > min length
   ✓ admincompanymodal > name > max length 879ms
   ✓ admincompanymodal > address line 1 > min length
   ✓ admincompanymodal > address line 1 > max length 1129ms
   ✓ admincompanymodal > address line 2 > min length
   ✓ admincompanymodal > address line 2 > max length 1410ms
   ✓ admincompanymodal > street name > min length
   ✓ admincompanymodal > street name > max length 1687ms
   ✓ admincompanymodal > locality > min length
   ✓ admincompanymodal > locality > max length 1991ms
   ✓ admincompanymodal > county > min length 329ms
   ✓ admincompanymodal > county > max length 2320ms
   ✓ admincompanymodal > region > min length 374ms
   ✓ admincompanymodal > region > max length 2663ms
   ✓ admincompanymodal > postal code > min length 412ms
   ✓ admincompanymodal > postal code > max length 3003ms
   ✓ admincompanymodal > submit 6202ms

 Test Files  1 passed (1)
      Tests  17 passed (17)
   Start at  17:11:06
   Duration  25.82s (transform 1.01s, setup 142ms, collect 1.82s, tests 23.51s, environment 90ms, prepare 30ms)

Reproduction

Quite hard to provide, this is what the submit test case looks like (5x slower than before):

  test('submit', async () => {
    render(<AdminCompanyModal {...defaultProps} />);

    const openButton = screen.getByRole('button', { name: 'Open' });
    await userEvent.click(openButton);

    const modal = await screen.findByRole('dialog');
    expect(modal).toBeInTheDocument();

    const nameInput = screen.getByRole('textbox', { name: 'name' });
    await userEvent.type(nameInput, 'admin');

    const addressLine1Input = screen.getByRole('textbox', { name: 'addressLine1' });
    await userEvent.type(addressLine1Input, 'address line 1');

    const addressLine2Input = screen.getByRole('textbox', { name: 'addressLine2' });
    await userEvent.type(addressLine2Input, 'address line 2');

    const streetNameInput = screen.getByRole('textbox', { name: 'streetName' });
    await userEvent.type(streetNameInput, 'street name');

    const localityInput = screen.getByRole('textbox', { name: 'locality' });
    await userEvent.type(localityInput, 'locality');

    const countyInput = screen.getByRole('textbox', { name: 'county' });
    await userEvent.type(countyInput, 'county');

    const regionInput = screen.getByRole('textbox', { name: 'region' });
    await userEvent.type(regionInput, 'region');

    const postalCodeInput = screen.getByRole('textbox', { name: 'postalCode' });
    await userEvent.type(postalCodeInput, 'postal code');

    const countrySelect = screen.getByRole('combobox', { name: 'countryCode' });
    await userEvent.type(countrySelect, 'ire');
    const option = await screen.findByText('Ireland');
    await userEvent.click(option);

    const groupSelect = screen.getByRole('combobox', { name: 'groupId' });
    expect(groupSelect).toBeInTheDocument();
    await userEvent.click(groupSelect);
    await userEvent.click(screen.getByText('Group 2'));

    const saveButton = screen.getByRole('button', { name: 'Save' });
    await userEvent.click(saveButton);

    expect(mockUpdateCompany).toHaveBeenCalledWith({
      name: 'admin',
      addressLine1: 'address line 1',
      addressLine2: 'address line 2',
      streetName: 'street name',
      locality: 'locality',
      county: 'county',
      region: 'region',
      postalCode: 'postal code',
      groupId: '2',
      countryCode: 'IE',
    });
  });

System Info

System:
    OS: macOS 15.3.1
    CPU: (14) arm64 Apple M3 Max
    Memory: 3.28 GB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.13.0 - ~/.nvm/versions/node/v22.13.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - ~/dev/projects/asterias/antaeus/node_modules/.bin/npm
    pnpm: 9.15.5 - ~/.nvm/versions/node/v22.13.0/bin/pnpm
  Browsers:
    Brave Browser: 133.1.75.175
    Chrome: 133.0.6943.98
    Safari: 18.3
  npmPackages:
    @vitejs/plugin-react-swc: ^3.8.0 => 3.8.0 
    @vitest/coverage-v8: ^3.0.3 => 3.0.3 
    @vitest/ui: ^3.0.3 => 3.0.3 
    vite: ^6.1.0 => 6.1.0 
    vitest: ^3.0.5 => 3.0.5 
    vitest-canvas-mock: ^0.3.3 => 0.3.3 
    vitest-fail-on-console: ^0.7.1 => 0.7.1 
    vitest-preview: ^0.0.1 => 0.0.1

Used Package Manager

pnpm

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Feb 13, 2025

Your whole test uses methods from a non-vitest library. I don't see any changes that could affect it directly 🤔 Are you sure you didn't update something else alongside Vitest?

Copy link

Hello @jacquesg. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@jacquesg
Copy link
Author

Your whole test uses methods from a non-vitest library. I don't see any changes that could affect it directly 🤔 Are you sure you didn't update something else alongside Vitest?

No, I noticed in our CI that lots of tests we're timing out, and then dependency by dependency went through this.

I literally just updated vitest from 3.0.4 to 3.0.5.

@jacquesg
Copy link
Author

If I were to guess, I'd think something in #7289 may have caused this?

@sheremet-va
Copy link
Member

If I were to guess, I'd think something in #7289 may have caused this?

This fix doesn't affect tests, only before/after callbacks.

@jacquesg
Copy link
Author

Ok, don't know how to provide a reproduction here, as the issue is non-functional.

@kretajak
Copy link

I have similar issue with similar setup (React Testing Library + User Event). I've noticed the performance regression when moved from Vitest 2.1.8 to Vitest 3.0.5. Unit test execution went from 60 seconds to 100 seconds on CI. I can hardly see any different on my local machine, but on CI tests clearly executes much longer.

I've checked 3.0.5 vs 3.0.3 but see no difference in execution time on CI.

@hi-ogawa
Copy link
Contributor

Not sure if this is relevant, but can you check if toggling environments.client.dev.preTransformRequests: true/false changes anything? false is supposed to be faster, but it was true on Vite 6.0.x, then it's fixed in 6.1 vitejs/vite#19272

@jacquesg
Copy link
Author

Not sure if this is relevant, but can you check if toggling environments.client.dev.preTransformRequests: true/false changes anything? false is supposed to be faster, but it was true on Vite 6.0.x, then it's fixed in 6.1 vitejs/vite#19272

Tried both true and false, no material difference.

@AriPerkkio
Copy link
Member

System Info

  npmPackages:
    @vitest/coverage-v8: ^3.0.3 => 3.0.3 
    @vitest/ui: ^3.0.3 => 3.0.3 
    vitest: ^3.0.5 => 3.0.5 
    vitest-canvas-mock: ^0.3.3 => 0.3.3 
    vitest-fail-on-console: ^0.7.1 => 0.7.1 
    vitest-preview: ^0.0.1 => 0.0.1

Make sure all of your vitest and @vitest/* packages are on same version. Also I would recommend to try reducing the setup by removing those vitest-* packages if possible.

Could you try adding some time logging between the queries in the test case? Are those getting slower when upgrading? Without reproduction there's not much anyone can do, other than try guessing what's causing this in your setup.

@jacquesg
Copy link
Author

Upgrading those don't make any difference, what I did was to get this to the bare minimum change that exposes the problem, that is, upgrading vitest from 3.0.3 to 3.0.4.

What I've done is to remove all the queries from the tests, keeping just the render of the component. The result is that it is marginally slower in 3.0.4 but not noteworthy.

It does appear that these queries are running slower in 3.0.4 than before. Will post a screen recording...

@jacquesg
Copy link
Author

See below, in short:

  • Running the tests using 3.0.3
  • Upgrade to 3.0.4
  • Running the tests using 3.0.4

Image

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants