next-runtime icon indicating copy to clipboard operation
next-runtime copied to clipboard

Optimizing Performance: Concurrent Execution of Async Functions with `Promise.all` ✈

Open sanjaiyan-dev opened this issue 2 years ago • 15 comments

Hi, this PR introduces a very minor performance gain by running async functions concurrently using Promise.all.

Extremely sorry, if I made any mistakes :(

sanjaiyan-dev avatar Sep 26 '23 06:09 sanjaiyan-dev

Deploy request for netlify-plugin-nextjs-nx-monorepo-demo pending review.

Visit the deploys page to approve it

Name Link
Latest commit c17d04a0aa7fc2de0ffe602a242dc16b64b87213

netlify[bot] avatar Sep 26 '23 06:09 netlify[bot]

Deploy request for netlify-plugin-nextjs-static-root-demo pending review.

Visit the deploys page to approve it

Name Link
Latest commit c17d04a0aa7fc2de0ffe602a242dc16b64b87213

netlify[bot] avatar Sep 26 '23 06:09 netlify[bot]

Deploy request for netlify-plugin-nextjs-next-auth-demo pending review.

Visit the deploys page to approve it

Name Link
Latest commit c17d04a0aa7fc2de0ffe602a242dc16b64b87213

netlify[bot] avatar Sep 26 '23 06:09 netlify[bot]

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
Latest commit c17d04a0aa7fc2de0ffe602a242dc16b64b87213
Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/652d84dc5834ab00089a0e84
Deploy Preview https://deploy-preview-2303--next-plugin-edge-middleware.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.

netlify[bot] avatar Sep 26 '23 06:09 netlify[bot]

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
Latest commit c17d04a0aa7fc2de0ffe602a242dc16b64b87213
Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/652d84dca0b1e100086317b4
Deploy Preview https://deploy-preview-2303--netlify-plugin-nextjs-export-demo.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.

netlify[bot] avatar Sep 26 '23 06:09 netlify[bot]

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot https://conventionalcommits.org/

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
Latest commit c17d04a0aa7fc2de0ffe602a242dc16b64b87213
Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/652d84dcb200330008cd1e89
Deploy Preview https://deploy-preview-2303--netlify-plugin-nextjs-demo.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.

netlify[bot] avatar Sep 26 '23 07:09 netlify[bot]

Deploy Preview for netlify-plugin-nextjs-demo-all-flags ready!

Name Link
Latest commit c17d04a0aa7fc2de0ffe602a242dc16b64b87213
Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo-all-flags/deploys/652d84dc1c6b260008d5e5c9
Deploy Preview https://deploy-preview-2303--netlify-plugin-nextjs-demo-all-flags.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.

netlify[bot] avatar Sep 26 '23 07:09 netlify[bot]

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
Latest commit c17d04a0aa7fc2de0ffe602a242dc16b64b87213
Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/652d84dc3a369c0008225901
Deploy Preview https://deploy-preview-2303--nextjs-plugin-custom-routes-demo.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.

netlify[bot] avatar Sep 26 '23 07:09 netlify[bot]

Deploy Preview for next-plugin-canary ready!

Name Link
Latest commit c17d04a0aa7fc2de0ffe602a242dc16b64b87213
Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/652d84dc1e40c3000706835e
Deploy Preview https://deploy-preview-2303--next-plugin-canary.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.

netlify[bot] avatar Sep 26 '23 07:09 netlify[bot]

Deploy Preview for next-i18next-demo ready!

Name Link
Latest commit c17d04a0aa7fc2de0ffe602a242dc16b64b87213
Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/652d84dc896dd300088cf802
Deploy Preview https://deploy-preview-2303--next-i18next-demo.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.

netlify[bot] avatar Sep 26 '23 07:09 netlify[bot]

Hello @sanjaiyan-dev, thank you for your contribution! However, AFAIK, this will not result in a performance optimization because file IO is blocking - so only one file can be moved at a time - and there is nothing else for the process to do while it is awaiting.

orinokai avatar Oct 16 '23 11:10 orinokai

Hello @sanjaiyan-dev, thank you for your contribution! However, AFAIK, this will not result in a performance optimization because file IO is blocking - so only one file can be moved at a time - and there is nothing else for the process to do while it is awaiting.

Hi @orinokai , I understand your concern, but currently, we are moving public files and static pages. With Node.js default 4-thread pool, we can utilize parallel processing to potentially optimize performance. For more information on how code runs in the thread pool, you can refer to this link: https://nodejs.org/en/docs/guides/dont-block-the-event-loop#what-code-runs-on-the-worker-pool

Extremely sorry if I am wrong :)

sanjaiyan-dev avatar Oct 16 '23 19:10 sanjaiyan-dev

thanks @sanjaiyan-dev but, even if each file copy/rename is happening in a separate thread, i still think there are hardware filesystem limitations to the performance gain here, but we're actually running a benchmark in a separate project for something similar so i'll let you know

orinokai avatar Oct 18 '23 10:10 orinokai

thanks @sanjaiyan-dev but, even if each file copy/rename is happening in a separate thread, i still think there are hardware filesystem limitations to the performance gain here, but we're actually running a benchmark in a separate project for something similar so i'll let you know

Okay 🤝

sanjaiyan-dev avatar Oct 18 '23 14:10 sanjaiyan-dev

Superseded by v5 rewrite.

serhalp avatar Jun 04 '24 15:06 serhalp