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
I've got a case of a large (~465MB) JSON file which happens to contain a bunch of strings with escaping in them. This decodes fairly readily using encoding/json in ~3.5s or so, but takes > 10min with go-json (long enough that I initially thought it was hanging, until I got further into the issue).
The issue seems to be here: https://github.com/goccy/go-json/blob/master/internal/decoder/string.go#L190
i.e. every time it hits an escaping backslash it shuffles the entire buffer (which seems to have eagerly read the entire payload) by one character, which is gonna be quadratic in the file size & hence pretty slow.
I'll attach a benchmark with a minimal reproduction. I'm unfamiliar with this library though so a bit less sure on the best approach to fix right now.
The text was updated successfully, but these errors were encountered:
I've got a case of a large (~465MB) JSON file which happens to contain a bunch of strings with escaping in them. This decodes fairly readily using
encoding/json
in ~3.5s or so, but takes > 10min with go-json (long enough that I initially thought it was hanging, until I got further into the issue).The issue seems to be here: https://github.com/goccy/go-json/blob/master/internal/decoder/string.go#L190
i.e. every time it hits an escaping backslash it shuffles the entire buffer (which seems to have eagerly read the entire payload) by one character, which is gonna be quadratic in the file size & hence pretty slow.
I'll attach a benchmark with a minimal reproduction. I'm unfamiliar with this library though so a bit less sure on the best approach to fix right now.
The text was updated successfully, but these errors were encountered: