On Another Level: How to Debug Compiling Query Engines Timo Kersten - - PowerPoint PPT Presentation

on another level how to debug compiling query engines
SMART_READER_LITE
LIVE PREVIEW

On Another Level: How to Debug Compiling Query Engines Timo Kersten - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

On Another Level: How to Debug Compiling Query Engines

Timo Kersten and Thomas Neumann Technical University of Munich

On Another Level: How to Debug Compiling Query Engines

kersten@in.tum.de | DBTEST ‘20 1

slide-2
SLIDE 2

On Another Level: How to Debug Compiling Query Engines kersten@in.tum.de | DBTEST ‘20 2

Debugging

Example Problem

Problem: Result count is zero, but there are two matching tuples!

slide-3
SLIDE 3

On Another Level: How to Debug Compiling Query Engines kersten@in.tum.de | DBTEST ‘20 3

Code Generation

Compile Time: Generate code

Runtime System

Query Executable

100 1010 01

Code Generator

  • S

R

Query Plan Code Generation

Runtime Compile Time

for Query Execution

Runtime: Run generated code

slide-4
SLIDE 4

On Another Level: How to Debug Compiling Query Engines kersten@in.tum.de | DBTEST ‘20 4

Example Problem

Code Generation

Runtime System

Query Executable

100 1010 01

Code Generator

  • S

R

Query Plan Code Generation

Runtime Compile Time

%8 = rotr i64 %7, 32

1 2

%9 = xor i64 %6, %8

1 3

%10 = call i64 TextRuntime::hash(%4924, %9)

1 4

%11 = call ptr HashTable::lookup(%ht, %10)

1 5

%12 = isnotnull ptr %11

1 6

condbr %12 %block4 %block1 void JoinOperator::consume(ConsumerScope scope) # probe side consume hashTable.find(keys, scope, entry -> { ConsumerScope nestedScope(scope) unpack(leftValues, entry, nestedScope) parent.consume(nestedScope) })

slide-5
SLIDE 5

On Another Level: How to Debug Compiling Query Engines kersten@in.tum.de | DBTEST ‘20

Debug at compile time: ✗ Bug does not show here Debug at runtime: ✗ Code is very low-level

5

Debugging

Code Generation

%8 = rotr i64 %7, 32

1 2

%9 = xor i64 %6, %8

1 3

%10 = call i64 TextRuntime::hash(%4924, %9)

1 4

%11 = call ptr HashTable::lookup(%ht, %10)

1 5

%12 = isnotnull ptr %11

1 6

condbr %12 %block4 %block1 void JoinOperator::consume(ConsumerScope scope) # probe side consume hashTable.find(keys, scope, entry -> { ConsumerScope nestedScope(scope) unpack(leftValues, entry, nestedScope) parent.consume(nestedScope) })

slide-6
SLIDE 6

On Another Level: How to Debug Compiling Query Engines kersten@in.tum.de | DBTEST ‘20

Debug compile time and runtime simultaneously! Time-travel debugger * + unique instruction identifiers = Step through execution, context from compile time

6

Multi-Level Debugger

Context Included

Runtime System

Query Executable

100 1010 01

Code Generator

  • S

R

Query Plan Code Generation

Runtime Compile Time

10 101 01

* thanks rr-project.org!

*

slide-7
SLIDE 7

On Another Level: How to Debug Compiling Query Engines kersten@in.tum.de | DBTEST ‘20 7

Multi-Level Debugger

Demo

slide-8
SLIDE 8

On Another Level: How to Debug Compiling Query Engines kersten@in.tum.de | DBTEST ‘20

Core GDB command: Implementation effort:

  • Reuse of debugger components
  • Extensions to GDB with Python: ~ 70 lines

8

Add it to Your System

> tbreak IRProgram.cpp:972 if instr == 5038

slide-9
SLIDE 9

On Another Level: How to Debug Compiling Query Engines kersten@in.tum.de | DBTEST ‘20

Runtime overhead:

  • RR recording of TPC-H Q1 scale factor 1
  • 470MB of recorded data
  • Runtime 10 seconds (vs. 1 second without RR)

9

Evaluation

slide-10
SLIDE 10

On Another Level: How to Debug Compiling Query Engines kersten@in.tum.de | DBTEST ‘20 10

Multi-Level Debugger

Questions?

%8 = rotr i64 %7, 32

1 2

%9 = xor i64 %6, %8

1 3

%10 = call i64 TextRuntime::hash(%4924, %9)

1 4

%11 = call ptr HashTable::lookup(%ht, %10)

1 5

%12 = isnotnull ptr %11

1 6

condbr %12 %block4 %block1 void JoinOperator::consume(ConsumerScope scope) # probe side consume hashTable.find(keys, scope, entry -> { ConsumerScope nestedScope(scope) unpack(leftValues, entry, nestedScope) parent.consume(nestedScope) })

Runtime System

Query Executable

100 1010 01

Code Generator

  • S

R

Query Plan Code Generation

Runtime Compile Time

10 101 01