[SERVER-27175] Address slowness in Explain::getPlanSummary Created: 23/Nov/16  Updated: 05/Apr/17  Resolved: 27/Dec/16

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 3.4.2, 3.5.2

Type: Improvement Priority: Major - P3
Reporter: James Wahlin Assignee: James Wahlin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File vtune_Queries_IntNonIdFindOn.png    
Issue Links:
Backports
Depends
Related
is related to SERVER-27193 Consider adding "small integer" optim... Closed
Backwards Compatibility: Fully Compatible
Sprint: Query 2017-01-23
Participants:
Linked BF Score: 0

 Description   

While profiling mongod under VTune, running the Queries.IntNonIdFindOn mongo-perf test with 8 threads I found that roughly 6% of the FindCmd run time is spent in Explain::getPlanSummary, generating a plan summary string. Of this 6%, 2/3rds is spent in StringBuilderImpl::appendDoubleNice(), converting index direction (in this case the number 1) from double to string.

We should look to optimize this path, either with StringBuilder optimization or custom parsing in getPlanSummary.

It is worth noting that changing the createIndex call in "Queries.IntNonIdFindOn" to pass a NumberInt(1) rather than the default of double reduces the cost by 50%. The remaining 50% is spent in StringBuilderImpl operator<<(int) which could be optimized for small integers as was done in our itoa() implementation.

See attachment for VTune screenshot



 Comments   
Comment by Githook User [ 09/Jan/17 ]

Author:

{u'username': u'jameswahlin', u'name': u'James Wahlin', u'email': u'james.wahlin@10gen.com'}

Message: SERVER-27175 Improve performance of planSummary string generation

(cherry picked from commit ac7b0469bdb57a3593dc8b97e5a7045db0efbb24)
Branch: v3.4
https://github.com/mongodb/mongo/commit/eb8c2542fd7f3881ae0dbf0f89a1293410de95bc

Comment by Githook User [ 27/Dec/16 ]

Author:

{u'username': u'jameswahlin', u'name': u'James Wahlin', u'email': u'james.wahlin@10gen.com'}

Message: SERVER-27175 Improve performance of planSummary string generation
Branch: master
https://github.com/mongodb/mongo/commit/ac7b0469bdb57a3593dc8b97e5a7045db0efbb24

Comment by James Wahlin [ 28/Nov/16 ]

One means of addressing this outside of the getPlanSummary path would be to do the following:

  1. Add StringBuilder optimizations for small integer values (SERVER-27193).
  2. Force index direction (1, -1) to be of type integer. We currently support both double and integer types. Even without SERVER-27193 there is savings to be had by this change.
Generated at Thu Feb 08 04:14:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.