On Another Level: How to Debug Compiling Query Engines On Another Level: How to Debug Compiling Query Engines Timo Kersten and Thomas Neumann Technical University of Munich 1 kersten@in.tum.de | DBTEST ‘20
On Another Level: How to Debug Compiling Query Engines Debugging Example Problem Problem : Result count is zero, but there are two matching tuples! 2 kersten@in.tum.de | DBTEST ‘20
� � On Another Level: How to Debug Compiling Query Engines Code Generation for Query Execution Code Generator Query Plan R S Compile Time: Code Generate code Generation Compile Time Runtime: Runtime Run generated code Runtime System Query 100 1010 Executable 01 3 kersten@in.tum.de | DBTEST ‘20
� � On Another Level: How to Debug Compiling Query Engines Example Problem Code Generation Code Generator Query Plan void JoinOperator::consume(ConsumerScope scope) R S # probe side consume Code hashTable.find(keys, scope, entry -> { Generation ConsumerScope nestedScope(scope) unpack(leftValues, entry, nestedScope) parent.consume(nestedScope) Compile Time }) Runtime %8 = rotr i64 %7, 32 Runtime System %9 = xor i64 %6, %8 1 2 %10 = call i64 TextRuntime::hash(%4924, %9) 1 3 Query 100 1010 %11 = call ptr HashTable::lookup(%ht, %10) 1 4 Executable 01 %12 = isnot null ptr %11 1 5 cond br %12 %block4 %block1 1 6 4 kersten@in.tum.de | DBTEST ‘20
On Another Level: How to Debug Compiling Query Engines Debugging Code Generation Debug at compile time : void JoinOperator::consume(ConsumerScope scope) # probe side consume ✗ Bug does not show here hashTable.find(keys, scope, entry -> { ConsumerScope nestedScope(scope) unpack(leftValues, entry, nestedScope) parent.consume(nestedScope) }) %8 = rotr i64 %7, 32 Debug at runtime : %9 = xor i64 %6, %8 1 2 %10 = call i64 TextRuntime::hash(%4924, %9) 1 3 ✗ Code is very low-level %11 = call ptr HashTable::lookup(%ht, %10) 1 4 %12 = isnot null ptr %11 1 5 cond br %12 %block4 %block1 1 6 5 kersten@in.tum.de | DBTEST ‘20
� � On Another Level: How to Debug Compiling Query Engines Multi-Level Debugger Context Included Code Generator Debug compile time Query Plan R and runtime simultaneously! S Code Generation Time-travel debugger * * Compile Time + unique instruction identifiers 10 101 Runtime 01 = Step through execution, Runtime System ✓ Query context from compile time 100 1010 Executable 01 * thanks rr-project.org! 6 kersten@in.tum.de | DBTEST ‘20
On Another Level: How to Debug Compiling Query Engines Multi-Level Debugger Demo 7 kersten@in.tum.de | DBTEST ‘20
On Another Level: How to Debug Compiling Query Engines Add it to Your System Core GDB command: > tbreak IRProgram.cpp:972 if instr == 5038 Implementation effort: • Reuse of debugger components • Extensions to GDB with Python: ~ 70 lines 8 kersten@in.tum.de | DBTEST ‘20
On Another Level: How to Debug Compiling Query Engines Evaluation Runtime overhead: • RR recording of TPC-H Q1 scale factor 1 • 470MB of recorded data • Runtime 10 seconds (vs. 1 second without RR) 9 kersten@in.tum.de | DBTEST ‘20
� � On Another Level: How to Debug Compiling Query Engines Multi-Level Debugger Questions? Code Generator Query Plan void JoinOperator::consume(ConsumerScope scope) R S # probe side consume Code hashTable.find(keys, scope, entry -> { Generation ConsumerScope nestedScope(scope) unpack(leftValues, entry, nestedScope) parent.consume(nestedScope) Compile Time }) Runtime 10 %8 = rotr i64 %7, 32 101 Runtime System %9 = xor i64 %6, %8 1 2 01 %10 = call i64 TextRuntime::hash(%4924, %9) 1 3 Query 100 1010 %11 = call ptr HashTable::lookup(%ht, %10) 1 4 Executable 01 %12 = isnot null ptr %11 1 5 cond br %12 %block4 %block1 1 6 10 kersten@in.tum.de | DBTEST ‘20
Recommend
More recommend