Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7db8cfa
Add antlr+llvm template
stewkk Oct 30, 2025
39d4db6
Add postgresql grammar
stewkk Oct 30, 2025
806c6b3
Upgrade C++ standard
stewkk Oct 30, 2025
105b986
Add build with sanitizers
stewkk Oct 30, 2025
fdcd843
Add library target
stewkk Nov 1, 2025
4c901fb
Impl getting ast from antlr
stewkk Nov 12, 2025
8c86456
Impl parsing simple select statement
stewkk Nov 12, 2025
a6829ac
Support select statement with single column output
stewkk Nov 14, 2025
c366e9f
Support multiple columns projection in select stmt
stewkk Nov 14, 2025
88f896b
Support where clause
stewkk Nov 18, 2025
cc3366c
Change attributes list to be pair (table, column)
stewkk Nov 20, 2025
2b62495
Refactor
stewkk Nov 26, 2025
93565fa
Add basic error handling
stewkk Nov 26, 2025
51eac13
Improve error handling
stewkk Nov 26, 2025
d8e1e4f
Report unsupported statements
stewkk Nov 26, 2025
550fb6b
Add empty query test
stewkk Nov 26, 2025
1d0f363
Implement proper handling of selectstmt
stewkk Nov 27, 2025
6492b8b
Implement arbitrary expressions parsing
stewkk Dec 3, 2025
aadaaef
Add bool expression test
stewkk Dec 3, 2025
57a8ca7
Refactor
stewkk Dec 3, 2025
f0a259c
Impl cross joins
stewkk Dec 9, 2025
99c57fd
Impl outer joins
stewkk Dec 9, 2025
3495310
Impl simple select execution
stewkk Dec 14, 2025
5881a63
Impl seq_scan for more than 10 tuples
stewkk Dec 16, 2025
73b196a
Add parallelizm test
stewkk Dec 16, 2025
0b9dba8
Impl projection execution
stewkk Dec 16, 2025
61f0cc6
Impl filter
stewkk Dec 18, 2025
1ea65e6
Impl cross join
stewkk Dec 18, 2025
37fc077
Impl inner join
stewkk Dec 19, 2025
2bcf4f7
Impl left join
stewkk Dec 19, 2025
582a8a4
Add right join test
stewkk Dec 19, 2025
4688566
Refactor
stewkk Dec 20, 2025
aaef50b
Add llvm jit
stewkk Dec 20, 2025
e5d6813
Impl basic benchmark
stewkk Jan 9, 2026
77f844d
Impl benchmarks
stewkk Jan 9, 2026
eb2b51d
Fix complex query
stewkk Jan 9, 2026
561f6e3
Add more benchmarks
stewkk Jan 10, 2026
5d51dc2
Add benchmarks analysis
stewkk Jan 10, 2026
e348076
Add report
stewkk Jan 10, 2026
f467034
Done report
stewkk Jan 18, 2026
32db3ae
Fix
stewkk Jan 19, 2026
16efa22
Fix speedup
stewkk Feb 4, 2026
53d53d9
Fix report
stewkk Feb 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
BasedOnStyle: Google
AccessModifierOffset: '-2'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AlwaysBreakTemplateDeclarations: 'No'
BreakBeforeBraces: Attach
ColumnLimit: '100'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
IncludeBlocks: Preserve
IndentPPDirectives: AfterHash
IndentWidth: '2'
NamespaceIndentation: None
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: 'true'
...
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.cache/
/build/
/CMakeFiles/
**/codegen/
/build-sanitizers/
/build-release/
FlameGraph/
/.vscode/
/perf.data
/perf.data.old
**/.auctex-auto/
**/build/
50 changes: 50 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
cmake_minimum_required(VERSION 3.15..3.29)

project(
sql-compiler
VERSION 0.0.1
LANGUAGES CXX
)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")

option(SANITIZE_ADDRESS "Enable AddressSanitizer" OFF)
option(SANITIZE_UNDEFINED "Enable UndefinedBehaviorSanitizer" OFF)
option(SANITIZE_THREADS "Enable ThreadSanitizer" OFF)

add_compile_options(-Wno-deprecated-declarations)

if (SANITIZE_ADDRESS)
add_compile_options(-fsanitize=address -fno-omit-frame-pointer -g)
add_link_options(-fsanitize=address)
endif()

if (SANITIZE_UNDEFINED)
add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer -g)
add_link_options(-fsanitize=undefined)
endif()

if (SANITIZE_THREADS)
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer -g)
add_link_options(-fsanitize=thread)
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)

set(FETCHCONTENT_QUIET OFF)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_subdirectory(src/stewkk/sql)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
add_subdirectory(benchmarks)

include(CTest)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
endif()
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CURRENT_DIR := $(shell pwd)
CODEGEN_DIR := $(CURRENT_DIR)/src/stewkk/sql/logic/parser/codegen
PARSER_SOURCE_DIR := $(CURRENT_DIR)/src/stewkk/sql/logic/parser

build:
cmake --build build -- -j 6

codegen:
@antlr -Dlanguage=Cpp -visitor -o $(CODEGEN_DIR) -package stewkk::sql::codegen $(PARSER_SOURCE_DIR)/PostgreSQLParser.g4 $(PARSER_SOURCE_DIR)/PostgreSQLLexer.g4

.PHONY: codegen build
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```sh
docker run --rm -it --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword postgres
docker exec -it some-postgres psql -U postgres
```


```sh
git clone https://github.com/brendangregg/FlameGraph.git

sed -i 's|#!/usr/bin/perl -w|#!/usr/bin/env perl|' FlameGraph/stackcollapse-perf.pl
sed -i 's|#!/usr/bin/perl -w|#!/usr/bin/env perl|' FlameGraph/flamegraph.pl

perf record -F 99 -g ./build-release/bin/benchmarks --benchmark_filter="BM_SQL<CachedJitCompiledExpressionExecutor.*"

perf script | FlameGraph/stackcollapse-perf.pl | FlameGraph/flamegraph.pl > benchmarks/flamegraph-jit.svg
```
16 changes: 16 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(FetchGBenchmark)

add_executable(benchmarks main.cpp)
target_compile_features(benchmarks PRIVATE cxx_std_23)
set_target_properties(benchmarks PROPERTIES
CXX_STANDART 23
CXX_STANDART_REQUIRED YES
CXX_EXTENSIONS YES
)
target_compile_options(benchmarks PRIVATE ${BASE_COMPILE_FLAGS})
target_link_options(benchmarks PRIVATE ${BASE_LINK_FLAGS})
target_link_libraries(benchmarks PRIVATE stewkk::libsql benchmark::benchmark
Boost::asio
Boost::thread
Boost::filesystem
)
Loading