-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Router: use fast-json-stringify to improve the performance #97
Comments
AFAICT from JSONStream's README, it's solving a different problem. In LoopBack, we have a single object/array returned by a remote method (a Controller method) that we want to write to the HTTP response stream. JSONStream allows users to write the JSON array-items/object-properties via a streaming interface. I don't see how this is going to improve our performance in the case where we already have the full response object available? It would be useful if our ORM/DAO implementation provided methods returning a stream of array items (think of |
This is totally different. The performance increase is similar to ProtoBuffs minus the binary (footprint) benefits. I'm guessing this approach uses the fact that the JSONSchema acts as essentially a template that is rendered by the serializer instead of Rendering the template is much simpler than walking the tree since the template basically gives the serializer a map of where to go. |
I'm also concerned about the requirement of a schema. The API input/output tends to be flexible and extensible. The JSON parse/stringify is not only CPU intensive, but also memory heavy. We see issues at both incoming http req/res and outgoing REST calls to other services. It often involves |
I am closing this issue because we are not going to have time to work on this in the next 6-9 months. However, we are happy to accept a pull request contributing this feature. |
See https://github.com/fastify/fastify/blob/master/docs/Validation-And-Serialize.md#serialize, https://www.npmjs.com/package/fast-json-stringify, consider also https://www.npmjs.com/package/fast-safe-stringify.
The fastify framework claims it's gaining 1-4x speed-up from using this module.
Since our routes (controller methods) provide swagger metadata describing the expected output format in a JSON-Schema-like format, we should be able to leverage this metadata to improve the performance.
The text was updated successfully, but these errors were encountered: