go-json icon indicating copy to clipboard operation
go-json copied to clipboard

High CPU usage when decode json string contains numerous '\'

Open igotcha opened this issue 1 year ago • 2 comments

When json string contains numerous '\' (eg: Windows file path), "decoder.decodeEscapeString" will do too many memory move works. This is my pprof graph: image And I think the problem is here

igotcha avatar Mar 02 '24 06:03 igotcha

I have meet the same problem.

HaoKunT avatar Mar 05 '24 09:03 HaoKunT

Also seeing a difference in parsing large JSON blobs with escaped JSON embedded within a string value but only whilst using the Decoder.

As soon as I remove the nested escaped JSON the Decoder performance is much closer to Unmarshal.

jamiecuthill avatar Mar 19 '24 10:03 jamiecuthill