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

chore: speed up serving-functions test by pre-generating oclif manifest #3517

Merged
merged 2 commits into from
Oct 18, 2021

Conversation

netlify-team-account-1
Copy link
Contributor

- Summary

oclif promises to only require the files that are neccessary for the command that is run. This is true if there's a oclif.manifest.json found - if it doesn't find it, it will require every single command synchronously. Since serving-functions.test.js runs ntl dev once for every test (~25 at the moment), and there's no require caching since each test runs its own child process, this is a big time sink.

By generating the oclif.manifest.json, we can speed up these tests.

- Test plan

tests shall still pass

- A picture of a cute animal (not mandatory but encouraged)

oclif spends a lot of time scanning the functions directory.
this adds up if we do it for every test, so we pre-generate it for testing.
@netlify-team-account-1 netlify-team-account-1 added the type: chore work needed to keep the product and development running smoothly label Oct 16, 2021
@github-actions
Copy link

github-actions bot commented Oct 16, 2021

📊 Benchmark results

Comparing with 8b95a5c

Package size: 357 MB

(no change)

^  353 MB  353 MB  353 MB  353 MB  352 MB  352 MB  352 MB  352 MB  352 MB  352 MB  352 MB  352 MB  357 MB 
│   ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

@@ -65,7 +66,8 @@
"test:ci:ava": "nyc -r json ava",
"docs": "node ./site/scripts/docs.js",
"watch": "nyc --reporter=lcov ava --watch",
"prepack": "oclif-dev manifest && npm prune --prod",
"build:manifest": "oclif-dev manifest",
"prepack": "npm run build:manifest && npm prune --prod",
"postpack": "rm -f oclif.manifest.json && npm i",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see we currently try to only generate the manifest during the packing process. What's the idea behind that? Do we fear it becoming stale during development?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we fear it becoming stale during development?

I'm not sure this was a very conscious choice, but yes - this can happen.
We could add another cleanup step to remove it (we'll need to propagate the exit code from the test run though).

@netlify-team-account-1
Copy link
Contributor Author

(this PR is similar to #3508, but for speeding up local testing instead of CI)

Copy link
Contributor

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

Thanks @netlify-team-account-1, added a comment - I don't think it's a blocker.

Also, I think we can remove the change done in #3508, as this PR includes it

@netlify-team-account-1 netlify-team-account-1 added the automerge Add to Kodiak auto merge queue label Oct 18, 2021
@kodiakhq kodiakhq bot merged commit 3ec4a54 into main Oct 18, 2021
@kodiakhq kodiakhq bot deleted the speed-up-functions-serving branch October 18, 2021 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Add to Kodiak auto merge queue type: chore work needed to keep the product and development running smoothly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants