[SERVER-59514] Inlined BufBuilder's grow_reallocate() method consumes a lot of stack space Created: 23/Aug/21  Updated: 29/Oct/23  Resolved: 24/Aug/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Martin Neupauer Assignee: Martin Neupauer
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

When various append methods of BSONObjBuilder get inlined they all sooner or later inline grow_reallocate().

The grow_reallocate has std::stringstream variable on a local stack (~400 bytes). All that space is allocated in the caller stack frame when the callee is inlined. 

There is code that calls append many times and each inlined call incurs 400 bytes penalty. It quickly adds up to huge stack frames.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 24/Aug/21 ]

Author:

{'name': 'Martin Neupauer', 'email': 'martin.neupauer@mongodb.com', 'username': 'MartinNeupauer'}

Message: SERVER-59514 Isolate the failure path into its own noinline method.
Branch: master
https://github.com/mongodb/mongo/commit/0b5cc6d8cddea7f970b2c808031e78df540abb8b

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