Bug 51922

Summary: JSON.stringify processing time exponentially grows with size of object
Product: WebKit Reporter: Mirko Tschäni <mirko.tschaeni>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, eric, filipjares, mirko.tschaeni, mrowe, oliver, webkit.review.bot
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Reproduces the bug, open index.html, it will show a report showing the processing time of JSON.stringify calls
none
Replacement for: Reproduces the bug, open index.html, it will show a report showing the processing time of JSON.stringify calls
none
Patch barraclough: review+

Description Mirko Tschäni 2011-01-05 05:59:14 PST
Created attachment 77991 [details]
Reproduces the bug, open index.html, it will show a report showing the processing time of JSON.stringify calls

JSON.stringify is very slow in WebKit (slower than the javascript JSON implementation from http://www.json.org). In addition the processing time grows exponentially to the size of the object that is passed to JSON.stringify. 

With bigger objects (resulting JSON string 600 kb) the processing time for the native JSON.stringify is more than 100 times bigger than the json.org implementation.

Google chrome (as well as firefox and ie8) does not have the problem. There native json is faster than json.org in most of the cases and if it is slower, then only marginally and the processing time is proportional to the size of the object passed to the JSON.stringify function.
Comment 1 Mirko Tschäni 2011-01-05 06:03:49 PST
Created attachment 77992 [details]
Replacement for: Reproduces the bug, open index.html, it will show a report showing the processing time of JSON.stringify calls

The first attachment had the test with large objects commented out.
Use this attachment to reproduce the bug!
Comment 2 Mark Rowe (bdash) 2011-01-05 06:09:00 PST
<rdar://problem/8822731>
Comment 3 Oliver Hunt 2011-01-25 13:03:28 PST
Created attachment 80108 [details]
Patch
Comment 4 Oliver Hunt 2011-01-25 13:14:15 PST
Committed r76635: <http://trac.webkit.org/changeset/76635>
Comment 5 WebKit Review Bot 2011-01-25 14:06:11 PST
http://trac.webkit.org/changeset/76635 might have broken Leopard Intel Release (Tests)