Bug 51922 - JSON.stringify processing time exponentially grows with size of object
Summary: JSON.stringify processing time exponentially grows with size of object
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-01-05 05:59 PST by Mirko Tschäni
Modified: 2013-02-28 02:07 PST (History)
7 users (show)

See Also:


Attachments
Reproduces the bug, open index.html, it will show a report showing the processing time of JSON.stringify calls (5.84 KB, application/octet-stream)
2011-01-05 05:59 PST, Mirko Tschäni
no flags Details
Replacement for: Reproduces the bug, open index.html, it will show a report showing the processing time of JSON.stringify calls (5.84 KB, application/octet-stream)
2011-01-05 06:03 PST, Mirko Tschäni
no flags Details
Patch (1.50 KB, patch)
2011-01-25 13:03 PST, Oliver Hunt
barraclough: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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)