[SERVER-42261] improve inefficient GenericArgument predicates Created: 17/Jul/19  Updated: 29/Oct/23  Resolved: 17/Jul/19

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: 4.3 Desired
Fix Version/s: 4.3.1

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Dev Tools 2019-07-15
Participants:

 Description   

src/mongo/db/command_generic_argument.cpp defines:

bool isGenericArgument(StringData arg);
bool isRequestStripArgument(StringData arg);
bool isReplyStripArgument(StringData arg); 

These are implemented by a table lookup via linear search on a std::array of struct, and then returning the value of a bool member of the struct. Two improvements:

1) Switch from linear search to binary search.

2) Each predicate should not have to search through structs that contain a false. That is, search a smaller pre-filtered array such that successful find automatically means the predicate is true.

 

These predicates are called on every field of every request and response, so their speed feels important.



 Comments   
Comment by Githook User [ 17/Jul/19 ]

Author:

{'name': 'Billy Donahue', 'username': 'BillyDonahue', 'email': 'billy.donahue@mongodb.com'}

Message: SERVER-42261 faster generic args predicates
Branch: master
https://github.com/mongodb/mongo/commit/efeb79b3275f4ec6dc401a4c4a44fa4353d972ba

Comment by Billy Donahue [ 17/Jul/19 ]

https://mongodbcr.appspot.com/500150014/

Generated at Thu Feb 08 05:00:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.