Skip to content

Commit

Permalink
Merge pull request #9 from lnikon/feature/grpc-server
Browse files Browse the repository at this point in the history
Feature/grpc server
  • Loading branch information
lnikon authored Nov 24, 2024
2 parents 0ff2d46 + 50eebee commit 6dc1777
Show file tree
Hide file tree
Showing 54 changed files with 1,240 additions and 708 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BasedOnStyle: LLVM
ColumnLimit: 120
ColumnLimit: 80
IndentWidth: 4
TabWidth: 4
UseTab: Never
Expand All @@ -16,4 +16,4 @@ ExperimentalAutoDetectBinPacking: false
AllowAllParametersOfDeclarationOnNextLine: true
IncludeBlocks: Preserve
SortIncludes: Never
AlignConsecutiveDeclarations: true
AlignConsecutiveDeclarations: true
39 changes: 39 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,45 @@
],
"debuggerPath": "/usr/bin/gdb"
},
},
{
"name": "Debug - Main",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/Main", // Path to the compiled executable
"args": [
"-c",
"./assets/tkvpp_config.json"
], // Arguments to pass to the program
"stopAtEntry": false, // Set to true to stop at the program's entry point
"cwd": "${workspaceFolder}", // Current working directory
"environment": [],
"externalConsole": false, // Set to true if you want to use an external terminal
"MIMode": "gdb", // Use "lldb" if you're using clang on macOS
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build", // Ensure your program is built before launching
"miDebuggerPath": "/usr/bin/gdb", // Path to the gdb or lldb debugger
"logging": {
"trace": true, // Enable trace for debugging the launch.json config
"traceResponse": true,
"engineLogging": false
},
"launchCompleteCommand": "exec-run",
"targetArchitecture": "x86_64",
"pipeTransport": {
"pipeCwd": "",
"pipeProgram": "/bin/bash",
"pipeArgs": [
"-c"
],
"debuggerPath": "/usr/bin/gdb"
},
}
]
}
14 changes: 4 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED On)
set(CMAKE_CXX_EXTENSIONS Off)

# Enable ASAN for all targets
# set(CMAKE_BUILD_TYPE "Debug")
# -std=c++23 -Wall -Wextra -pedantic-errors -stdlib=libstdc++ -lstdc++_libbacktrace -fsized-deallocation -no-pie
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -Wall -Wextra -pedantic-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -Wall -Wextra -pedantic-errors")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer -Wall -Wextra -pedantic-errors")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic-errors")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
Expand All @@ -35,19 +31,17 @@ find_package(gRPC CONFIG REQUIRED)
include_directories(lib)

add_subdirectory(lib)
add_subdirectory(app)
add_subdirectory(src)
add_subdirectory(bench)
add_subdirectory(examples)
add_subdirectory(grpcapp)

# Custom targets to build docker images and run tests
add_custom_target(BuildGCCReleaseDockerImage
add_custom_target(GCCReleaseDockerImage
COMMAND sh scripts/build_gcc_release_docker_image.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

add_custom_target(BuildClangReleaseDockerImage
add_custom_target(ClangReleaseDockerImage
COMMAND sh scripts/build_clang_release_docker_image.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
ARG TARGET=gcc
FROM ${TARGET} AS build

ARG COMPILER=gcc
ARG BUILD_TYPE=release

# Install necessary packages for development in a single step to reduce layers and leverage caching
RUN apt-get update && \
apt-get -y install \
Expand All @@ -23,15 +26,19 @@ RUN python3 -m virtualenv "$VIRTUAL_ENV" && \

# Setup Conan profiles and install dependencies
COPY conanfile.txt .
RUN conan profile detect && \
conan install . --output-folder=build --build=missing
COPY conan conan
RUN test -f "conan/profiles/release-${COMPILER}" || (echo "Error: No Conan profile found for compiler ${COMPILER}" && exit 1)
RUN conan install . --output-folder=build \
--profile:build=conan/profiles/${BUILD_TYPE}-${COMPILER} \
--profile:host=conan/profiles/${BUILD_TYPE}-${COMPILER} \
--build=missing

# Copy project files after dependencies to maximize caching
COPY . .

# Generate and build the project
RUN cp -f ./build/CMakePresets.json . && \
cmake --preset conan-release && \
cmake --preset conan-${BUILD_TYPE} && \
cmake --build ./build

# Test stage for running tests
Expand Down
8 changes: 0 additions & 8 deletions app/CMakeLists.txt

This file was deleted.

209 changes: 124 additions & 85 deletions assets/database_config_schema.json
Original file line number Diff line number Diff line change
@@ -1,97 +1,136 @@
{
"$id": "https://json-schema.hyperjump.io/schema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$title": "Schema for tinykvpp's JSON config",
"type": "object",
"properties": {
"logging": {
"type": "object",
"properties": {
"loggingLevel": {
"$ref": "#/$defs/loggingLevel"
}
},
"required": [
"loggingLevel"
]
},
"database": {
"type": "object",
"properties": {
"path": {
"type": "string"
"$id": "https://json-schema.hyperjump.io/schema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$title": "Schema for tinykvpp's JSON config",
"type": "object",
"properties": {
"logging": {
"type": "object",
"properties": {
"loggingLevel": {
"$ref": "#/$defs/loggingLevel"
}
},
"required": [
"loggingLevel"
]
},
"walFilename": {
"type": "string"
"database": {
"type": "object",
"description": "Core database configuration settings",
"properties": {
"path": {
"type": "string",
"description": "Database storage directory path"
},
"walFilename": {
"type": "string",
"description": "Write-ahead log filename"
},
"manifestFilenamePrefix": {
"type": "string",
"description": "Prefix for manifest files"
}
},
"required": [
"path",
"walFilename",
"manifestFilenamePrefix"
]
},
"manifestFilenamePrefix": {
"type": "string"
"lsmtree": {
"type": "object",
"properties": {
"memtableFlushThreshold": {
"type": "integer",
"description": "The threshold of bytes at which the memtable should be flushed",
"minimum": 1,
"default": 1024
},
"levelZeroCompaction": {
"$ref": "#/$defs/compaction"
},
"levelNonZeroCompaction": {
"$ref": "#/$defs/compaction"
}
},
"required": [
"memtableFlushThreshold",
"maximumLevels",
"levelZeroCompaction",
"levelNonZeroCompaction"
]
},
"server": {
"type": "object",
"description": "Server configuration settings",
"properties": {
"transport": {
"$ref": "#/$defs/serverTransport"
},
"host": {
"type": "string",
"description": "Server host address"
},
"port": {
"type": "integer",
"description": "Server port number",
"minimum": 1024,
"maximum": 65535
}
},
"required": [
"transport",
"host",
"port"
]
}
},
"required": [
"path",
"walFilename",
"manifestFilenamePrefix"
]
},
"lsmtree": {
"type": "object",
"properties": {
"memtableFlushThreshold": {
"type": "number"
},
"maximumLevels": {
"type": "number"
"required": [
"database",
"lsmtree",
"server"
],
"$defs": {
"serverTransport": {
"type": "string",
"enum": [
"grpc",
"tcp"
]
},
"levelZeroCompaction": {
"$ref": "#/$defs/compaction"
"loggingLevel": {
"type": "string",
"enum": [
"info",
"debug",
"trace",
"off"
]
},
"levelNonZeroCompaction": {
"$ref": "#/$defs/compaction"
}
},
"required": [
"memtableFlushThreshold",
"maximumLevels",
"levelZeroCompaction",
"levelNonZeroCompaction"
]
}
},
"required": [
"database",
"lsmtree"
],
"$defs": {
"loggingLevel": {
"type": "string",
"enum": [
"info",
"debug"
]
},
"compactionStrategy": {
"type": "string",
"enum": [
"levelled",
"tiered"
]
},
"compaction": {
"type": "object",
"properties": {
"compactionStrategy": {
"$ref": "#/$defs/compactionStrategy"
"type": "string",
"enum": [
"levelled",
"tiered"
]
},
"compactionThreshold": {
"type": "number"
"compaction": {
"type": "object",
"properties": {
"compactionStrategy": {
"$ref": "#/$defs/compactionStrategy"
},
"compactionThreshold": {
"type": "integer",
"description": "Number of files that trigger compaction",
"minimum": 1
}
},
"required": [
"compactionStrategy",
"compactionThreshold"
]
}
},
"required": [
"logging,",
"compactionStrategy",
"compactionThreshold"
]
}
}
}
11 changes: 8 additions & 3 deletions assets/tkvpp_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"loggingLevel": "info"
},
"database": {
"path": "/home/nikon/tkvpp",
"path": "./var/tkvpp",
"walFilename": "wal",
"manifestFilenamePrefix": "manifest_"
},
Expand All @@ -12,11 +12,16 @@
"maximumLevels": 12,
"levelZeroCompaction": {
"compactionStrategy": "levelled",
"compactionThreshold": 4
"compactionThreshold": 1024
},
"levelNonZeroCompaction": {
"compactionStrategy": "tiered",
"compactionThreshold": 8
"compactionThreshold": 1024
}
},
"server": {
"transport": "grpc",
"host": "localhost",
"port": 9000
}
}
Loading

0 comments on commit 6dc1777

Please sign in to comment.