[SERVER-43371] Break up some tests to fix -fvar-tracking-assignments note. Created: 18/Sep/19  Updated: 29/Oct/23  Resolved: 06/Jan/20

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.3.3

Type: Task Priority: Trivial - P5
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-43841 Break up query_planner_test.cpp to fi... Closed
is related to SERVER-43842 Break up json_schema_parser_test.cpp ... Closed
Backwards Compatibility: Fully Compatible
Sprint: Dev Tools 2020-01-13
Participants:

 Description   

This annoyance affects every build `all`.

The function that's getting too big and throwing the compiler message is `__static_initialization_and_destruction_0(int,int)`. This grows with the # of namespace-scope objects, and in these cases that's going to be the objects defined by TEST and TEST_F macros.

I think that if these massive files were simply broken up the problem would go away.

 
[918/919] CXX build/dynamic_gcc_ninja/mongo/s/transaction_router_test.o
src/mongo/s/transaction_router_test.cpp: In function ‘void __static_initialization_and_destruction_0(int, int)’:
src/mongo/s/transaction_router_test.cpp:4777:1: note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without

As part of this ticket we should look to see whether we can make fvar-tracking-assignments trigger a compiler error rather than a warning.



 Comments   
Comment by Githook User [ 06/Jan/20 ]

Author:

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

Message: SERVER-43371 StringData for unit test registration
Branch: master
https://github.com/mongodb/mongo/commit/4d662310ee40288ee63f0bc761ab49539a86fe9b

Comment by Billy Donahue [ 02/Jan/20 ]

It's a subtle thing having to do with the optimizer keeping annotations about data flow through a function, in this case, through the hidden function that initializes all the statics in these large test files. The more TEST/TEST_Fs, the more statics, and the more little std::strings to track. Changing the unittest::RegistrationAgent to be StringData based instead of std::string based does the trick.  The annotation note is only emitted at a threshold somewhere between 1000 and 5000 TEST_Fs, rather than just 114 of them.

https://mongodbcr.appspot.com/527400020/

 

Comment by James Wahlin [ 02/Jan/20 ]

I wonder if something changed to make this more restrictive? After fixing a few of the tests earlier the only one I saw failing was transaction_router_test.cpp. mutable_bson_test.cpp has not changed since June 14th 2019, which was before these efforts.

Comment by Billy Donahue [ 02/Jan/20 ]

The magic number seems to be 114.
If there are 114 TEST_F decls in a file, the warning appears.

Tested by a trivial suite consisting only of trivial tests...

 

class VarTrackingLimitTest : public unittest::Test {};
TEST_F(VarTrackingLimitTest, Test_001){}
TEST_F(VarTrackingLimitTest, Test_002){}
...
TEST_F(VarTrackingLimitTest, Test_113){} 

 

Comment by Billy Donahue [ 02/Jan/20 ]

This seems to have gotten much worse again since the initial reporting.
(or maybe the initial report was incomplete)

$ grep tracking-assignments build.out | cut -d: -f1-2
src/mongo/db/query/query_planner_operator_test.cpp:1615
src/mongo/db/query/query_planner_array_test.cpp:2715
src/mongo/db/query/query_planner_tree_test.cpp:2360
src/mongo/db/query/query_request_test.cpp:1648
src/mongo/db/transaction_participant_test.cpp:3915
src/mongo/db/modules/enterprise/src/fle/query_analysis/encryption_schema_tree_test.cpp:3168
src/mongo/s/transaction_router_test.cpp:4775
src/mongo/db/query/collation/collator_factory_icu_test.cpp:1170
src/mongo/db/repl/topology_coordinator_v1_test.cpp:5860
src/mongo/bson/mutable/mutable_bson_test.cpp:3452
src/mongo/db/repl/storage_interface_impl_test.cpp:2661
src/mongo/db/pipeline/pipeline_test.cpp:3533
src/mongo/util/options_parser/options_parser_test.cpp:5137
src/mongo/db/repl/replication_coordinator_impl_test.cpp:6388

 

Comment by Nicholas Zolnierz [ 04/Oct/19 ]

billy.donahue is the full list in the description? Surprised to see expression_test.cpp didn't make the cut, we have SERVER-40933 on our backlog tracking it.

Comment by Billy Donahue [ 04/Oct/19 ]

That's great news, James. Thanks.

Comment by James Wahlin [ 04/Oct/19 ]

The Query team has created SERVER-43841 and SERVER-43842 to address breaking up query_planner_test.cpp and json_schema_parser_test.cpp. We will look to do this work over the next several weeks. I am removing both from the scope of this ticket.

Comment by Sara Williamson [ 23/Sep/19 ]

We'd like to find a compiler flag that would make this a hard error.

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