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: Lazy-load public-api dependencies to reduce baseline memory usage #5049

Merged
merged 3 commits into from
Jan 2, 2023

Conversation

netroy
Copy link
Member

@netroy netroy commented Dec 28, 2022

This reduces the startup memory spike from 200MB to 150MB, and the baseline memory usage from 110MB to 99MB

image

PS: This is with public-api enabled, but swagger-ui disabled. With swagger-ui (which is the default), there is no reduction in the baseline memory usage, but the initial memory spike is still flattened to 160-170MB.

@netroy netroy changed the title refactor: Reduce baseline memory usage by lazy loading some dependencies perf: Reduce baseline memory usage by lazy loading some dependencies Dec 28, 2022
@@ -19,6 +19,9 @@ if (inE2ETests) {
EXTERNAL_FRONTEND_HOOKS_URLS: '',
N8N_PERSONALIZATION_ENABLED: 'false',
};
}
if (inTest) {
process.env.N8N_PUBLIC_API_DISABLED = 'true';
Copy link
Member Author

Choose a reason for hiding this comment

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

This helps with cutting down the heap usage in tests by about 15%, which in turn helps avoid OOM issues.

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Dec 28, 2022
@netroy netroy force-pushed the lazy-load-dependencies branch from 40cd619 to 98daae4 Compare December 29, 2022 11:04
@netroy netroy force-pushed the lazy-load-dependencies branch from 98daae4 to d031a96 Compare December 29, 2022 11:06
@netroy netroy changed the title perf: Reduce baseline memory usage by lazy loading some dependencies perf: Reduce baseline memory usage by lazy loading public-api dependencies Dec 29, 2022
@netroy netroy changed the title perf: Reduce baseline memory usage by lazy loading public-api dependencies perf: Lazy-load public-api dependencies to reduce baseline memory usage Dec 29, 2022
@netroy netroy requested a review from ahsanv January 2, 2023 10:55
Copy link
Member

@ahsanv ahsanv left a comment

Choose a reason for hiding this comment

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

🚀

@netroy netroy merged commit a455cce into master Jan 2, 2023
@netroy netroy deleted the lazy-load-dependencies branch January 2, 2023 11:14
@n8n-assistant n8n-assistant bot added the Upcoming Release Will be part of the upcoming release label Jan 2, 2023
@janober
Copy link
Member

janober commented Jan 5, 2023

Got released with n8n@0.210.0

@janober janober removed the Upcoming Release Will be part of the upcoming release label Jan 5, 2023
netroy added a commit that referenced this pull request Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants