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

Removed usage of getters for api endpoints #19876

Conversation

allouis
Copy link
Contributor

@allouis allouis commented Mar 18, 2024

ref ENG-761
ref https://linear.app/tryghost/issue/ENG-761

By removing getters we ensure that each endpoint is only instantiated once. This may have an adverse effect on boot time, so we're going to keep an eye on that, and make any necessary adjustments to the implementation.

ref ENG-761
ref https://linear.app/tryghost/issue/ENG-761

By removing getters we ensure that each endpoint is only instantiated once.
This _may_ have an adverse effect on boot time, so we're going to keep an eye
on that, and make any necessary adjustments to the implementation.
@vikaspotluri123
Copy link
Member

Out of curiosity, is there any memory overhead with doing this? i.e. now that the require calls are no longer deferred, will any services that were previously not loaded now be loaded even if they're never called? I'm not sure if all services are expected to be loaded e.g. in the bootstrap, making this a non-issue 😁

@allouis
Copy link
Contributor Author

allouis commented Mar 18, 2024

@vikaspotluri123 There is an initial memory overhead yes, but as soon as the API is accessed, we're back to the same footprint

@vikaspotluri123
Copy link
Member

Right, but I'm wondering if/how many APIs are rarely/never instantiated during a boot lifetime. E.g. webhook management might not be done often. (With the asterisk that I'm not sure how the API is accessed within the core, just thinking from an Admin/Public API aspect)

@allouis
Copy link
Contributor Author

allouis commented Mar 18, 2024

The way the API is mounted means that - once any Admin API endpoint is mounted - every Admin API endpoint file is loaded - same for the Content API - so it's not granular on a endpoint by endpoint basis

@allouis
Copy link
Contributor Author

allouis commented Mar 18, 2024

Closing for now, in favour of #19880

We have a lot of circular dependencies which are hidden by the lazy-loading of files here - and cleaning it up should be part of a larger task than optimising controller instantiation.

@allouis allouis closed this Mar 18, 2024
@allouis allouis deleted the egg-eng-761-api-pipeline-is-cpu-intensive-and-created-on-the-fly branch March 18, 2024 16:02
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.

None yet

2 participants