[SERVER-40866] Use JSON.stringify() to serialize string in tojson() Created: 26/Apr/19  Updated: 29/Oct/23  Resolved: 28/Apr/19

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: 3.4.21, 3.6.13, 4.0.10, 4.1.11

Type: Improvement Priority: Major - P3
Reporter: Siyuan Zhou Assignee: Siyuan Zhou
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.0, v3.6, v3.4
Sprint: Repl 2019-05-06
Participants:
Linked BF Score: 50

 Description   

Serializing long string is very slow in tojson(). Calling tojson() takes about 15 seconds for a 16MB long string.

 

$ ./mongo --nodb
MongoDB shell version v0.0.0
> var start = Date.now(); tojson("x".repeat(16 * 1024 * 1024)); print(Date.now() - start)
14320



 Comments   
Comment by Githook User [ 13/May/19 ]

Author:

{'name': 'Siyuan Zhou', 'username': 'visualzhou', 'email': 'siyuan.zhou@mongodb.com'}

Message: SERVER-40866 Use JSON.stringify() to serialize string in tojson()

(cherry picked from commit b877bd0172b613e77365f29886d359e5230f1a3e)
Branch: v4.0
https://github.com/mongodb/mongo/commit/7c958ef34989959984983126be0ff3bc9513d489

Comment by Githook User [ 13/May/19 ]

Author:

{'email': 'siyuan.zhou@mongodb.com', 'name': 'Siyuan Zhou', 'username': 'visualzhou'}

Message: SERVER-40866 Use JSON.stringify() to serialize string in tojson()

(cherry picked from commit b877bd0172b613e77365f29886d359e5230f1a3e)
Branch: v3.6
https://github.com/mongodb/mongo/commit/20107d15da5ff360378f2bf98acb8040b7a5f8a3

Comment by Githook User [ 13/May/19 ]

Author:

{'email': 'siyuan.zhou@mongodb.com', 'name': 'Siyuan Zhou', 'username': 'visualzhou'}

Message: SERVER-40866 Use JSON.stringify() to serialize string in tojson()

(cherry picked from commit b877bd0172b613e77365f29886d359e5230f1a3e)
Branch: v3.4
https://github.com/mongodb/mongo/commit/27dd7882d3ff006628830b63c5ddfd83ff1a2909

Comment by Githook User [ 28/Apr/19 ]

Author:

{'email': 'siyuan.zhou@mongodb.com', 'name': 'Siyuan Zhou', 'username': 'visualzhou'}

Message: SERVER-40866 Use JSON.stringify() to serialize string in tojson()
Branch: master
https://github.com/mongodb/mongo/commit/b877bd0172b613e77365f29886d359e5230f1a3e

Comment by Judah Schvimer [ 26/Apr/19 ]

We should check if any tests with these two tags can be untagged: https://github.com/mongodb/mongo/blob/064297825d97e928d40d3117b5c81e4828629728/buildscripts/resmokeconfig/suites/multi_shard_multi_stmt_txn_kill_primary_jscore_passthrough.yml#L406-L411

Comment by Judah Schvimer [ 26/Apr/19 ]

We should consider if any of the tests blacklisted in SERVER-40747 can be unblacklisted.

Generated at Thu Feb 08 04:56:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.