[SERVER-72752] Add C++ CodeFragment pretty printing of stackSize and fixups Created: 11/Jan/23  Updated: 29/Oct/23  Resolved: 28/Feb/23

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

Type: Task Priority: Major - P3
Reporter: Anna Wawrzyniak Assignee: Kevin Cherkauer
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Backwards Compatibility: Fully Compatible
Sprint: QE 2023-02-20, QE 2023-03-06
Participants:

 Description   

[SERVER-74240 has been created for the Python pretty printer used by gdb. The current ticket is narrowed to just the C++ pretty printer. --kevin.cherkauer@mongodb.com ]

 

Add pretty printing of sbe CodeFragment for stackSize, maxStackSize and all fixups. Possibly something like suggested by david.percy@mongodb.com  in

https://github.com/10gen/mongo/pull/9493#discussion_r1060674192

https://github.com/10gen/mongo/pull/9493#discussion_r1060681436

 

Possibly something along the lines of:

 

-- CODE:
[0x0000-0x002f] stackSize: 1, maxStackSize: 3
0x0000: pushConstVal(value: 10);
...
0x0014: pushConstVal(value: Nothing);
0x001e: sub(popLhs: 0, offsetLhs: 2, popRhs: 0, offsetRhs: 1);
0x0022:    fixup: <frameId>
0x0024:    fixup: <frameId>

 



 Comments   
Comment by Githook User [ 25/Feb/23 ]

Author:

{'name': 'Kevin Cherkauer', 'email': 'kevin.cherkauer@mongodb.com', 'username': 'kevin-cherkauer'}

Message: SERVER-72752 Add CodeFragment pretty printing of stackSize and fixups
Branch: master
https://github.com/mongodb/mongo/commit/e0d916063a07ff33c48bdf2546d2c588760ed19d

Comment by Kevin Cherkauer [ 06/Feb/23 ]

More info:

Q1. What should the "stack effects" output capture?

Anna Wawrzyniak: its a number that indicates how stack size will change after this code runs (so positive => the stack will be come larger, negative => stack will be smaller).
_stackSize variable holds that information today:
https://github.com/10gen/mongo/blob/anna.wawrzyniak/sort_perf/src/mongo/db/exec/sbe/vm/vm.h#L970

Q2. Where is the C++ pretty printer?

Anna Wawrzyniak: this is where printer lives
https://github.com/10gen/mongo/blob/anna.wawrzyniak/sort_perf/src/mongo/db/exec/sbe/vm/vm_printer.h#L38

Comment by Anna Wawrzyniak [ 03/Feb/23 ]

This change is mostly intended for in-process debugging rather than golden tests (although it's still beneficial for golden tests).

The motivation is, that when working with a EExpression -> CodeFragment compilation it is often of interest to be able to inspect the CodeFragments in their partial forms. Normally, when EExpression is compiled, the finished CodeFragment has stack effect of 1 (the result of the expression that will be left on the stack), and has no remaining fixups (as otherwise it wouldn't be valid). However, during the compilation partial CodeFragments may have different overall stack effects and may have outstanding variable frames and variable references that need fixups. We would like to include, that in the pretty printing output.

Ideally we would do the change to both c++ and python pretty printer. C++ is used for both debugging and golden tests, while python is only used for debugging.

Generated at Thu Feb 08 06:22:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.