You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After migration to OpenAPI 3.1 specs we are experiencing memory consumption spikes leading to OOMs in our Node.js applications. Our investigation revealed that creating Swagger clients from OpenAPI 3.1 spec requires about 20% more memory than it was for 3.0.1 spec. For large specs (186 kB) it's even six times more and we have plenty of such specs. Unfortunately, we cannot execute promises one-by-one to limit the consumption because it would take ages to build all clients (sometimes even 50).
Petstore spec:
% /usr/bin/time -l node app.js 3.0.1 40
Using spec version: 3.0.1, executions: 40
40
0.70 real 0.35 user 0.09 sys
138412032 maximum resident set size
% /usr/bin/time -l node app.js 3.1.0 40
Using spec version: 3.1.0, executions: 40
40
1.39 real 1.59 user 0.07 sys
160399360 maximum resident set size
Large spec:
% /usr/bin/time -l node app.js 3.0.1 40
Using spec version: 3.0.1, executions: 40
40
0.85 real 0.60 user 0.09 sys
144490496 maximum resident set size
% /usr/bin/time -l node app.js 3.1.0 40
Using spec version: 3.1.0, executions: 40
40
30.93 real 32.17 user 0.48 sys
903905280 maximum resident set size
To reproduce...
Steps to reproduce the behavior:
(Optional) Replace petstore-spec file with some large spec file
Execute /usr/bin/time -l node app.js 3.0.1 40 to get results for 3.0.1 spec
Execute /usr/bin/time -l node app.js 3.1.0 40 to get results for 3.1.0 spec
Expected behavior
Memory consumption for large 3.1.0 specs is as close as possible to 3.0.1 specs
Additional context or thoughts
Is there a way to configure swagger-client so it consumes less memory for 3.1.0 specs?
The text was updated successfully, but these errors were encountered:
After investigating, we have determined that the cause lies within the ApiDOM structure.
The result of refracting a definition of 10 MB size will leave 100 MB of memory footprint for the JSON structure. For the ApiDOM AST interpretation, the footprint will be 200 MB, and the dehydrated result will take 400 MB.
We need to further investigate the possibilities of amending the ApiDOM and its elements to address this issue.
Q&A (please complete the following information)
Content & configuration
Swagger/OpenAPI definition:
https://petstore31.swagger.io/api/v31/openapi.json
Swagger-Client usage:
Describe the bug you're encountering
After migration to OpenAPI 3.1 specs we are experiencing memory consumption spikes leading to OOMs in our Node.js applications. Our investigation revealed that creating Swagger clients from OpenAPI 3.1 spec requires about 20% more memory than it was for 3.0.1 spec. For large specs (186 kB) it's even six times more and we have plenty of such specs. Unfortunately, we cannot execute promises one-by-one to limit the consumption because it would take ages to build all clients (sometimes even 50).
Petstore spec:
Large spec:
To reproduce...
Steps to reproduce the behavior:
petstore-spec
file with some large spec file/usr/bin/time -l node app.js 3.0.1 40
to get results for 3.0.1 spec/usr/bin/time -l node app.js 3.1.0 40
to get results for 3.1.0 specExpected behavior
Memory consumption for large 3.1.0 specs is as close as possible to 3.0.1 specs
Additional context or thoughts
Is there a way to configure swagger-client so it consumes less memory for 3.1.0 specs?
The text was updated successfully, but these errors were encountered: