qzind / tray

Browser plugin for sending documents and raw commands to a printer or attached device.
https://qz.io
Other
854 stars 277 forks source link

Stream JSON Data #282

Open tresf opened 6 years ago

tresf commented 6 years ago

Currently JSON Data is transferred in one large String causing large heap allocations, especially for base64 jobs.

The JSON parser we use today doesn't offer steaming capabilities, and those that have been attempted vastly change the codebase for the would seem like a marginal gain.

Strategically we may be able to mimic the JSON API used today by wrapping Java EE's JSON parser (which does have streaming capabilities)

tresf commented 6 years ago

Turns out streaming JSON is entirely possible, but validating the signature would become impossible without stashing the contents before sending, which would negate the performance gains. Closing as wontfix for now.

Vzor- commented 6 years ago

I'm going to take a crack at this one. I think this can be done with chunking instead of a streaming.

tresf commented 6 years ago

So data chucking from a JavaScript perspective certainly helps the memory consumption, but the increased chatter to the websocket and signing cause it to double and triple the print times when compared to just sending the large data to begin with. I think we'll close this as wontifx and place the big-data branch on the shelf for now.