Replies: 1 comment 2 replies
-
Thank you for your detailed analysis and proposed solution! 🙌 I completely agree with your approach to improving performance by introducing memoization. It aligns perfectly with the goals of making the package faster ⚡ and more developer-friendly 👩💻👨💻. I believe there is room for significant optimization, and centralizing this behavior would indeed benefit all Schema components without requiring developers to implement it manually. 🛠️ Additionally, this could open the door for broader discussions on how to streamline the package further. 🚀 Please proceed with preparing a more reliable PR. I’d be happy to collaborate and discuss any additional tasks or improvements needed to ensure we deliver the best version of this package. Looking forward to seeing your proposed changes! 💡 Big thanks 🙏 |
Beta Was this translation helpful? Give feedback.
-
TLDR
I've investigated initially some memoization possibilities while building components:
📓 main...jpedryc:laravel-openapi:caching-tmp-v2
User Benefit
Improved performance by removing unnecessary
build()
calls.Full story
In our Schema components we're loading a bit of stuff for the descriptions, enums etc. (e.g. from the DB) and it seems for every referencable object all these things are loaded (
build()
) every time. Because the OpenAPI Endpoint is being loaded by an external UI tool and we want it to be working fast and "quiet" (limit external calls while generating the doc), we have limited the required calls by using a simple memoization variable, e.g.Started this discussion on two grounds:
build()
behaviour - it has to be done like that in every Schema component 🙈What's happening now?
Assuming we're having something like:
For this case the
ExampleSchema
component will be build 12 times. In my initial PoC (main...jpedryc:laravel-openapi:caching-tmp-v2) it will only once.What do you think @TartanLeGrand? Would it be of interest and should I investigate/prepare a more reliable PR? 🤔
Beta Was this translation helpful? Give feedback.
All reactions