forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ruby] Use Ruby autoload to lower memory usage and load times
Fixes OpenAPITools#12648 Requiring all models up front can be very expensive in both time and memory if there are many models. In an example client with 6000 models, this would consume nearly 400MB of memory and take about 7 seconds to load. This is mostly unnecessary as most users of the client library will only actually use a small percentage of the library. The changes in this commit use Ruby's autoload capability to defer the loading until the constant is actually used. In that same example client with 6000 models, when initially requiring the library, the memory usage dropped to ~20MB and loaded in 0.3 seconds. As the constants are loaded on-demand, the memory would increase towards that 400MB ceiling, but if only a few constants are actually used, then memory will never actually hit that ceiling. An additional side effect of using Ruby's autoload is that the order of declaring the constants is not important, as Ruby will naturally load them in the correct order when they are needed. Thus, this commit obviates PR OpenAPITools#9103 and fixes OpenAPITools#4690.
- Loading branch information
Showing
6 changed files
with
117 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters