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

test: speed up "create and sync data" test #689

Merged
merged 3 commits into from
May 29, 2024

Conversation

EvanHahn
Copy link
Contributor

@EvanHahn EvanHahn commented May 28, 2024

I recommend reviewing this with whitespace changes disabled.

This speeds up our "create and sync data" test. On my machine, it went from ~73 seconds to ~12.

I did this by making a few changes:

  • Decrease the number of managers from 10 to 5, dramatically reducing the amount of connections required. I don't think 10 really offers much here, other than perhaps a stress test, and lowering it offers a huge speedup.

  • Run assertions concurrently.

  • When comparing sets, use Set instead of sorted arrays. This speeds things up a bit.

  • Use node:assert instead of Brittle for a slight performance boost. We also plan to drop Brittle in the future and this will ease the transition.

Each of these could theoretically be done separately.

I've been running this test a lot which is why I'm fixing this now.

*I recommend reviewing this with whitespace changes disabled.*

This speeds up our "create and sync data" test. On my machine, it went
from ~73 seconds to ~12.

I did this by making a few changes:

- Decrease the number of managers from 10 to 5, dramatically reducing
  the amount of connections required. I don't think 10 really offers
  much here, other than perhaps a stress test, and lowering it offers a
  huge speedup.

- Run assertions concurrently.

- When comparing sets, use `Set` instead of sorted arrays. This speeds
  things up a bit.

- Use `node:assert` instead of Brittle for a slight performance boost.
  We also plan to drop Brittle in the future and this will ease the
  transition.

Each of these could theoretically be done separately.

I've been running this test a lot which is why I'm fixing this now.
@EvanHahn EvanHahn requested a review from achou11 May 28, 2024 20:59
test-e2e/sync.js Outdated
Promise.all(
map(projects, async (project) => {
const deviceId = project.deviceId.slice(0, 7)
// @ts-ignore - to complex to narrow `schemaName` to valid values
Copy link
Member

Choose a reason for hiding this comment

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

nit: may as well fix the grammar 😄

Suggested change
// @ts-ignore - to complex to narrow `schemaName` to valid values
// @ts-ignore - too complex to narrow `schemaName` to valid values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in da8dba0.

test-e2e/sync.js Outdated
// NOTE: Unlike other tests in this file, this test uses `node:assert` instead
// of `t` to ease our transition away from Brittle. We can remove this comment
// when Brittle is removed.
const COUNT = 5
Copy link
Member

Choose a reason for hiding this comment

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

having this stay higher to stress test seems generally useful, but maybe there's an alternative approach to achieve that? i know we introduced something like a FAST_TESTS env variable but i don't think it's being used 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nah, I think it's useful too. Reverted to 10 in 340bf82. I might consider using FAST_TESTS in the future, but not necessary now.

Copy link
Member

@achou11 achou11 May 29, 2024

Choose a reason for hiding this comment

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

curious how much faster the test is now for you, since the only thing related change is parallelizing the assertions?

EDIT: the major thing changed is parallelizing the assertions. there are other things as mentioned that probably help a bit too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It sped things up by about 10 seconds on my machine.

@EvanHahn EvanHahn merged commit 5f9d41a into main May 29, 2024
7 checks passed
@EvanHahn EvanHahn deleted the create-and-sync-data-test-speedup branch May 30, 2024 17:52
EvanHahn added a commit that referenced this pull request Jul 30, 2024
*This is a test-only change.*

I've been working on sync lately, and this test takes a long time. This
change speeds it up if the `FAST_TESTS` environment variable is set.

Stole this [idea from Andrew][0].

[0]: #689 (comment)
EvanHahn added a commit that referenced this pull request Jul 30, 2024
*This is a test-only change.*

I've been working on sync lately, and this test takes a long time. This
change speeds it up if the `FAST_TESTS` environment variable is set.

Stole this [idea from Andrew][0].

[0]: #689 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants