From 41f51bacc528a9d5357eaf4716f2397ff1312eef Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 13 Sep 2022 08:32:22 +0800 Subject: [PATCH] Optimized: C++ Compilation, ~10x speedup --- .gitignore | 3 + Makefile | 47 ++++++++---- README.md | 3 +- aquery_config.py | 13 ---- build.py | 157 +++++++++++++++++++++++++++++++++++++++++ engine/utils.py | 6 +- prompt.py | 26 +++---- reconstruct/ast.py | 2 +- sdk/aquery.h | 4 +- sdk/aquery_mem.cpp | 5 +- sdk/example.cpp | 2 +- server/Makefile | 4 +- server/gc.cpp | 0 server/gc.hpp | 13 ++-- server/io.cpp | 87 ++++++++++++++++++++++- server/pch.hpp | 17 +++++ server/server.cpp | 13 ++-- server/server.vcxproj | 2 +- server/table.cpp | 32 --------- server/table.h | 1 + server/types.cpp | 20 ------ server/types.h | 1 - server/utils.cpp | 18 ----- server/vector_type.cpp | 15 ---- server/vector_type.hpp | 5 -- test.aquery | Bin 459 -> 459 bytes 26 files changed, 342 insertions(+), 154 deletions(-) create mode 100644 build.py delete mode 100644 server/gc.cpp create mode 100644 server/pch.hpp delete mode 100644 server/table.cpp delete mode 100644 server/types.cpp delete mode 100644 server/utils.cpp delete mode 100644 server/vector_type.cpp diff --git a/.gitignore b/.gitignore index 43c1c46..0c88897 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +libaquery.a +aq +.cached *.json !sample_ast.json *.o diff --git a/Makefile b/Makefile index 88d2a94..1cadff1 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,16 @@ OS_SUPPORT = MonetDB_LIB = +MonetDB_INC = Threading = CXXFLAGS = --std=c++1z -OPTFLAGS = -O3 -flto -march=native +OPTFLAGS = -O3 +LINKFLAGS = -flto SHAREDFLAGS = -shared -fPIC +LIBTOOL = $(shell $(CXX) --version | grep -q 'clang' && echo "libtool -static -o"|| echo "ar rcs") +USELIB_FLAG = $(shell $(CXX) --version | grep -q 'clang' && echo "-Wl,-force_load"|| echo "-Wl,--whole-archive") +LIBAQ_SRC = server/server.cpp server/monetdb_conn.cpp server/io.cpp ifeq ($(PCH), 1) - PCHFLAGS = -include server/aggregations.h + PCHFLAGS = -include server/pch.hpp else PCHFLAGS = endif @@ -13,43 +18,61 @@ endif ifeq ($(OS),Windows_NT) NULL_DEVICE = NUL OS_SUPPORT += server/winhelper.cpp - MonetDB_LIB += -Imonetdb/msvc msc-plugin/monetdbe.dll + MonetDB_LIB += msc-plugin/monetdbe.dll + MonetDB_INC += -Imonetdb/msvc else UNAME_S = $(shell uname -s) UNAME_M = $(shell uname -m) NULL_DEVICE = /dev/null MonetDB_LIB = ifeq ($(UNAME_S),Darwin) - MonetDB_LIB += -L`brew --prefix monetdb`/lib + MonetDB_LIB += -L$(shell brew --prefix monetdb)/lib + MonetDB_INC += -I$(shell brew --prefix monetdb)/include/monetdb ifneq ($(UNAME_M),arm64) OPTFLAGS += -march=native endif else OPTFLAGS += -march=native + MonetDB_INC += -I/usr/local/include/monetdb -I/usr/include/monetdb endif - MonetDB_LIB += -I/usr/local/include/monetdb -I/usr/include/monetdb -lmonetdbe + MonetDB_LIB += -lmonetdbe endif ifeq ($(THREADING),1) - Threading += server/threading.cpp -DTHREADING + LIBAQ_SRC += server/threading.cpp + Threading += -DTHREADING endif -pch: - $(CXX) -x c++-header server/aggregations.h -o server/aggregations.h.pch + info: $(info $(OS_SUPPORT)) $(info $(OS)) $(info $(Threading)) $(info "test") + $(info $(LIBTOOL)) + $(info $(MonetDB_INC)) $(info $(CXX)) +pch: + $(CXX) -x c++-header server/pch.hpp $(MonetDB_INC) $(OPTFLAGS) $(CXXFLAGS) $(Threading) libaquery.a: - $(CXX) -c server/server.cpp server/io.cpp server/table.cpp $(OS_SUPPORT) $(Threading) $(OPTFLAGS) $(CXXFLAGS) -o server.bin + $(CXX) -c $(PCHFLAGS) $(LIBAQ_SRC) $(MonetDB_INC) $(MonetDB_LIB) $(OS_SUPPORT) $(Threading) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) &&\ + $(LIBTOOL) libaquery.a *.o &&\ + ranlib libaquery.a + server.bin: - $(CXX) server/server.cpp server/io.cpp server/table.cpp $(OS_SUPPORT) $(Threading) $(OPTFLAGS) $(CXXFLAGS) -o server.bin + $(CXX) $(LIBAQ_SRC) $(LINKFLAGS) $(OS_SUPPORT) $(Threading) $(MonetDB_INC) $(MonetDB_LIB) $(OPTFLAGS) $(CXXFLAGS) -o server.bin +launcher: + $(CXX) -D__AQ_BUILD_LAUNCHER__ $(LIBAQ_SRC) $(LINKFLAGS) $(OS_SUPPORT) $(Threading) $(MonetDB_INC) $(MonetDB_LIB) $(OPTFLAGS) $(CXXFLAGS) -o aq server.so: # $(CXX) server/server.cpp server/monetdb_conn.cpp -fPIC -shared $(OS_SUPPORT) monetdb/msvc/monetdbe.dll --std=c++1z -O3 -march=native -o server.so -I./monetdb/msvc - $(CXX) $(SHAREDFLAGS) server/server.cpp server/io.cpp server/table.cpp $(OS_SUPPORT) server/monetdb_conn.cpp $(Threading) $(MonetDB_LIB) $(OPTFLAGS) $(CXXFLAGS) -o server.so + $(CXX) $(SHAREDFLAGS) $(PCHFLAGS) $(LIBAQ_SRC) $(OS_SUPPORT) $(Threading) $(MonetDB_INC) $(MonetDB_LIB) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) -o server.so +server_uselib: + $(CXX) $(SHAREDFLAGS) $(USELIB_FLAG),libaquery.a $(MonetDB_LIB) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) -o server.so + snippet: - $(CXX) $(SHAREDFLAGS) $(PCHFLAGS) out.cpp server/server.cpp server/monetdb_conn.cpp server/table.cpp server/io.cpp $(MonetDB_LIB) $(OPTFLAGS) $(CXXFLAGS) -o dll.so + $(CXX) $(SHAREDFLAGS) $(PCHFLAGS) out.cpp $(LIBAQ_SRC) $(MonetDB_INC) $(MonetDB_LIB) $(Threading) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) -o dll.so +snippet_uselib: + $(CXX) $(SHAREDFLAGS) $(PCHFLAGS) out.cpp libaquery.a $(MonetDB_INC) $(Threading) $(MonetDB_LIB) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) -o dll.so + docker: docker build -t aquery . diff --git a/README.md b/README.md index 7176e32..03630f8 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,8 @@ AQuery++ Database is a cross-platform, In-Memory Column-Store Database that inco - [x] Limitation: putting ColRefs back to monetdb. - [ ] Limitation: String operations and Date/Time data type. - [ ] C++ Meta-Programming: Eliminate template recursions as much as possible. - +- [ ] Limitation: Date and Time, String operations, Funcs in groupby agg. + # Installation ## Requirements 1. Recent version of Linux, Windows or MacOS, with recent C++ compiler that has C++17 (1z) support. diff --git a/aquery_config.py b/aquery_config.py index 1731540..81a67af 100644 --- a/aquery_config.py +++ b/aquery_config.py @@ -11,19 +11,6 @@ cygroot = 'c:/msys64/usr/bin' msbuildroot = 'd:/gg/vs22/MSBuild/Current/Bin' __config_initialized__ = False -class Build_Config: - def __init__(self) -> None: - self.OptimizationLv = '4' # [O0, O1, O2, O3, Ofast] - self.Platform = 'x64' - self.PCH = '' - self.StaticLib = '' - self.fLTO = True - self.fmarchnative = True - - def configure(self): - pass - - def init_config(): global __config_initialized__, os_platform ## SETUP ENVIRONMENT VARIABLES diff --git a/build.py b/build.py new file mode 100644 index 0000000..635e807 --- /dev/null +++ b/build.py @@ -0,0 +1,157 @@ +from dataclasses import dataclass +from enum import Enum, auto +from tabnanny import check +from aquery_config import * +import sys +import os +import subprocess +import hashlib +import pickle +from engine.utils import nullstream +from typing import Dict, Optional, Set, Union +@dataclass +class checksums: + libaquery_a : Optional[Union[bytes, bool]] = None + pch_hpp_gch : Optional[Union[bytes, bool]] = None + server : Optional[Union[bytes, bool]] = None + sources : Union[Dict[str, bytes], bool] = None + def calc(self, libaquery_a = 'libaquery.a', + pch_hpp_gch = 'server/pch.hpp.gch', + server = 'server.so' + ): + for key in self.__dict__.keys(): + try: + with open(eval(key), 'rb') as file: + self.__dict__[key] = hashlib.md5(file.read()).digest() + except (FileNotFoundError, NameError): + pass + sources = [*build_manager.headerfiles, *build_manager.sourcefiles] + self.sources = dict() + for key in sources: + try: + with open(key, 'rb') as file: + self.sources[key] = hashlib.md5(file.read()).digest() + except FileNotFoundError: + print('missing component: ' + key) + self.sources[key] = None + def __ne__(self, __o: 'checksums') -> 'checksums': + ret = checksums() + for key in self.__dict__.keys(): + try: + ret.__dict__[key] = self.__dict__[key] != __o.__dict__[key] + except KeyError: + ret.__dict__[key] = True + return ret + + def __eq__(self, __o: 'checksums') -> 'checksums': + ret = checksums() + for key in self.__dict__.keys(): + try: + ret.__dict__[key] = self.__dict__[key] == __o.__dict__[key] + except KeyError: + ret.__dict__[key] = False + return ret + + + +class build_manager: + sourcefiles = ['server/server.cpp', 'server/io.cpp', + 'server/monetdb_conn.cpp', 'server/threading.cpp', + 'server/winhelper.cpp' + ] + headerfiles = ['server/aggregations.h', 'server/hasher.h', 'server/io.h', + 'server/libaquery.h', 'server/monetdb_conn.h', 'server/pch.hpp', + 'server/table.h', 'server/threading.h', 'server/types.h', 'server/utils.h', + 'server/winhelper.h', 'server/gc.hpp', 'server/vector_type.hpp', + 'server/table_ext_monetdb.hpp' + ] + + class DriverBase: + def __init__(self, mgr : 'build_manager') -> None: + self.mgr = mgr + self.build_cmd = [''] + def libaquery_a(self) : + pass + def pch(self): + pass + def build(self, stdout = sys.stdout, stderr = sys.stderr): + for c in self.build_cmd: + subprocess.call(c, stdout = stdout, stderr = stderr) + + class MakefileDriver(DriverBase): + def __init__(self, mgr : 'build_manager') -> None: + super().__init__(mgr) + os.environ['PCH'] = f'{mgr.PCH}' + os.environ['CXX'] = mgr.cxx if mgr.cxx else 'c++' + + def libaquery_a(self): + self.build_cmd = [['rm', 'libaquery.a'],['make', 'libaquery.a']] + return self.build() + def pch(self): + self.build_cmd = [['rm', 'server/pch.hpp.gch'], ['make', 'pch']] + return self.build() + def server(self): + if self.mgr.StaticLib: + self.build_cmd = [['rm', 'server.so'], ['make', 'server_uselib']] + else: + self.build_cmd = [['rm', 'server.so'], ['make', 'server.so']] + return self.build() + + def snippet(self): + if self.mgr.StaticLib: + self.build_cmd = [['make', 'snippet_uselib']] + else: + self.build_cmd = [['rm', 'dll.so'], ['make', 'snippet']] + return self.build() + + class PythonDriver(DriverBase): + def __init__(self, mgr : 'build_manager') -> None: + super().__init__(mgr) + + class Driver(Enum): + Makefile = auto() + Python = auto() + CMake = auto() + MSBuild = auto() + + def __init__(self) -> None: + self.method = 'make' + self.cxx = '' + self.OptimizationLv = '4' # [O0, O1, O2, O3, Ofast] + self.Platform = 'x64' + self.PCH = 1 + self.StaticLib = 1 + self.fLTO = 1 + self.fmarchnative = 1 + self.driver = build_manager.MakefileDriver(self) + self.cache_status = checksums() + + def build_dll(self): + return self.driver.snippet() + + def build_caches(self, force = False): + cached = checksums() + current = checksums() + current.calc() + try: + with open('.cached', 'rb') as cache_sig: + cached = pickle.loads(cache_sig.read()) + except FileNotFoundError: + pass + self.cache_status = current != cached + + if force or self.cache_status.sources: + self.driver.pch() + self.driver.libaquery_a() + self.driver.server() + else: + if self.cache_status.libaquery_a: + self.driver.libaquery_a() + if self.cache_status.pch_hpp_gch: + self.driver.pch() + if self.cache_status.server: + self.driver.server() + current.calc() + with open('.cached', 'wb') as cache_sig: + cache_sig.write(pickle.dumps(current)) + \ No newline at end of file diff --git a/engine/utils.py b/engine/utils.py index 2337765..ac1ce24 100644 --- a/engine/utils.py +++ b/engine/utils.py @@ -81,11 +81,13 @@ class _Counter: import re ws = re.compile(r'\s+') +import os def add_dll_dir(dll: str): - import sys, os + import sys if sys.version_info.major >= 3 and sys.version_info.minor >7 and os.name == 'nt': os.add_dll_directory(dll) else: os.environ['PATH'] = os.path.abspath(dll) + os.pathsep + os.environ['PATH'] - \ No newline at end of file + +nullstream = open(os.devnull, 'w') diff --git a/prompt.py b/prompt.py index 46a2e69..71d9201 100644 --- a/prompt.py +++ b/prompt.py @@ -105,8 +105,8 @@ import ctypes import numpy as np from engine.utils import ws from engine.utils import add_dll_dir - -nullstream = open(os.devnull, 'w') +from engine.utils import nullstream +from build import build_manager ## CLASSES BEGIN class RunType(enum.Enum): @@ -179,6 +179,7 @@ class PromptState(): init : Callable[['PromptState'], None] = lambda _:None stmts = [''] payloads = {} + buildmgr : Optional[build_manager]= None ## CLASSES END ## FUNCTIONS BEGIN @@ -263,14 +264,15 @@ def init_prompt() -> PromptState: aquery_config.init_config() state = PromptState() - if aquery_config.rebuild_backend: - try: - os.remove(state.server_bin) - except Exception as e: - print(type(e), e) - subprocess.call(['make', "info"]) - subprocess.call(['make', state.server_bin], stdout=nullstream) - + # if aquery_config.rebuild_backend: + # try: + # os.remove(state.server_bin) + # except Exception as e: + # print(type(e), e) + # subprocess.call(['make', "info"]) + # subprocess.call(['make', state.server_bin], stdout=nullstream) + state.buildmgr = build_manager() + state.buildmgr.build_caches() state.cfg = Config(state.server_mode) if state.server_mode == RunType.IPC: @@ -337,7 +339,7 @@ def prompt(running = lambda:True, next = input, state = None): if q == 'exec': # generate build and run (AQuery Engine) state.cfg.backend_type = Backend_Type.BACKEND_AQuery.value cxt = engine.exec(state.stmts, cxt, keep) - if subprocess.call(['make', 'snippet'], stdout = nullstream) == 0: + if state.buildmgr.build_dll() == 0: state.set_ready() continue elif q.startswith('echo '): @@ -377,7 +379,7 @@ def prompt(running = lambda:True, next = input, state = None): with open('out.cpp', 'wb') as outfile: outfile.write((cxt.finalize()).encode('utf-8')) if build_this: - subprocess.call(['make', 'snippet'], stdout = nullstream) + state.buildmgr.build_dll() state.cfg.has_dll = 1 else: state.cfg.has_dll = 0 diff --git a/reconstruct/ast.py b/reconstruct/ast.py index cfefac6..9442ce8 100644 --- a/reconstruct/ast.py +++ b/reconstruct/ast.py @@ -296,7 +296,7 @@ class select_into(ast_node): raise Exception('No out_table found.') else: self.context.headers.add('"./server/table_ext_monetdb.hpp"') - self.ccode = f'{self.parent.out_table.table_name}->monetdb_append_table(cxt->alt_server, \"{node}\");' + self.ccode = f'{self.parent.out_table.contextname_cpp}->monetdb_append_table(cxt->alt_server, \"{node}\");' def produce_sql(self, node): self.sql = f' INTO {node}' diff --git a/sdk/aquery.h b/sdk/aquery.h index 8e50517..e5da083 100644 --- a/sdk/aquery.h +++ b/sdk/aquery.h @@ -1,5 +1,6 @@ #ifndef _AQUERY_H #define _AQUERY_H + enum Log_level { LOG_INFO, LOG_ERROR, @@ -11,6 +12,7 @@ enum Backend_Type { BACKEND_MonetDB, BACKEND_MariaDB }; + struct Config{ int running, new_query, server_mode, backend_type, has_dll, n_buffers; @@ -71,5 +73,5 @@ extern void Afree(void * mem); extern void register_memory(void* ptr, deallocator_t deallocator); extern void init_session(Context* cxt); -#define __AQ_NO_SESSION__ void init_session(Context*) {} +#define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {} #endif \ No newline at end of file diff --git a/sdk/aquery_mem.cpp b/sdk/aquery_mem.cpp index 60c969e..43e1afa 100644 --- a/sdk/aquery_mem.cpp +++ b/sdk/aquery_mem.cpp @@ -25,7 +25,6 @@ void register_memory(void* ptr, deallocator_t deallocator){ memmap->operator[](ptr) = deallocator; } -void init_session(Context* cxt){ +__AQEXPORT__(void) init_session(Context* cxt){ session = &cxt->current; - // session->memory_map = new std::unordered_map(); -} \ No newline at end of file +} diff --git a/sdk/example.cpp b/sdk/example.cpp index 4ce9715..36c2b8d 100644 --- a/sdk/example.cpp +++ b/sdk/example.cpp @@ -1,5 +1,5 @@ #include "aquery.h" -__AQ_NO_SESSION__ +// __AQ_NO_SESSION__ #include "../server/table.h" __AQEXPORT__(ColRef) mulvec(int a, ColRef b){ diff --git a/server/Makefile b/server/Makefile index 7acb78e..cb082c8 100644 --- a/server/Makefile +++ b/server/Makefile @@ -1,6 +1,6 @@ debug: - g++ -g3 -O0 server/server.cpp server/table.cpp -o a.out -Wall -Wextra -Wpedantic -lpthread + g++ -g3 -O0 server/server.cpp server/io.cpp -o a.out -Wall -Wextra -Wpedantic -lpthread test: - g++ --std=c++1z -g3 -O0 server.cpp table.cpp -o a.out -Wall -Wextra -Wpedantic -lpthread + g++ --std=c++1z -g3 -O0 server.cpp io.cpp -o a.out -Wall -Wextra -Wpedantic -lpthread diff --git a/server/gc.cpp b/server/gc.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/server/gc.hpp b/server/gc.hpp index dfdccb9..4c66060 100644 --- a/server/gc.hpp +++ b/server/gc.hpp @@ -1,29 +1,28 @@ #pragma once -#include +#include #include #include #include class GC { template - using vector = std::vector; + using vector = vector_type; template using tuple = std::tuple; size_t current_size, max_size, interval, forced_clean; bool running, alive; // ptr, dealloc, ref, sz - vector> q; + vector> q; std::thread handle; void gc() { } - template - void reg(T* v, uint32_t ref, uint32_t sz, - void(*f)(void*) = [](void* v) {delete[] ((T*)v); }) { + void reg(void* v, uint32_t ref, uint32_t sz, + void(*f)(void*) = [](void* v) {free (v); }) { current_size += sz; if (current_size > max_size) gc(); - q.push_back({ v, f, ref, sz }); + q.push_back({ v, f }); } void daemon() { using namespace std::chrono; diff --git a/server/io.cpp b/server/io.cpp index b05907f..c4b7c69 100644 --- a/server/io.cpp +++ b/server/io.cpp @@ -8,4 +8,89 @@ void setgbuf(char* buf){ gbuf = b; else gbuf = buf; -} \ No newline at end of file +} + +#include "table.h" + + +#ifdef __SIZEOF_INT128__ +template <> +void print<__int128_t>(const __int128_t& v, const char* delimiter){ + char s[41]; + s[40] = 0; + std::cout<< get_int128str(v, s+40)<< delimiter; +} +template <> +void print<__uint128_t>(const __uint128_t&v, const char* delimiter){ + char s[41]; + s[40] = 0; + std::cout<< get_uint128str(v, s+40) << delimiter; +} +std::ostream& operator<<(std::ostream& os, __int128 & v) +{ + print(v); + return os; +} +std::ostream& operator<<(std::ostream& os, __uint128_t & v) +{ + print(v); + return os; +} +#endif + +template <> +void print(const bool&v, const char* delimiter){ + std::cout<< (v?"true":"false") << delimiter; +} + + +#include +#include +namespace types { + using namespace std; + using namespace chrono; + string date_t::toString() const { + uint32_t curr_v = val; + tm; + time_t; + return string() + string("/") + string() + string("/") + string(); + } + string time_t::toString() const { + uint32_t curr_v = val; + + return string() + string("/") + string() + string("/") + string(); + } +} + +#include "utils.h" +#include +using std::string; +string base62uuid(int l = 8) { + using namespace std; + constexpr static const char* base62alp = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + static mt19937_64 engine(chrono::system_clock::now().time_since_epoch().count()); + static uniform_int_distribution u(0x10000, 0xfffff); + uint64_t uuid = (u(engine) << 32ull) + (chrono::system_clock::now().time_since_epoch().count() & 0xffffffff); + printf("%p\n", uuid); + string ret; + while (uuid && l-- >= 0) { + ret = string("") + base62alp[uuid % 62] + ret; + uuid /= 62; + } + return ret; +} + + +template +inline void vector_type<_Ty>::out(uint32_t n, const char* sep) const +{ + n = n > size ? size : n; + std::cout << '('; + { + uint32_t i = 0; + for (; i < n - 1; ++i) + std::cout << this->operator[](i) << sep; + std::cout << this->operator[](i); + } + std::cout << ')'; +} diff --git a/server/pch.hpp b/server/pch.hpp new file mode 100644 index 0000000..c285204 --- /dev/null +++ b/server/pch.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "libaquery.h" +#include "aggregations.h" +#include +#include +#include "monetdb_conn.h" +#include "monetdbe.h" +#include "threading.h" +#include "../csv.h" +#ifdef _WIN32 +#include "winhelper.h" +#else +#include +#include +#include +#endif diff --git a/server/server.cpp b/server/server.cpp index 9436ed0..87b0f87 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -1,7 +1,6 @@ #include "../csv.h" #include #include -//#include #include #include "libaquery.h" @@ -69,14 +68,17 @@ __AQEXPORT__(bool) have_hge(){ return false; #endif } + Context::Context() { current.memory_map = new std::unordered_map; init_session(); } + Context::~Context() { auto memmap = (std::unordered_map*) this->current.memory_map; delete memmap; } + void Context::init_session(){ if (log_level == LOG_INFO){ memset(&(this->current.stats), 0, sizeof(Session::Statistic)); @@ -226,7 +228,7 @@ int dll_main(int argc, char** argv, Context* cxt){ int launcher(int argc, char** argv){ std::string str = " "; - for (int i = 0; i < argc; i++){ + for (int i = 1; i < argc; i++){ str += argv[i]; str += " "; } @@ -235,6 +237,9 @@ int launcher(int argc, char** argv){ } extern "C" int __DLLEXPORT__ main(int argc, char** argv) { +#ifdef __AQ_BUILD_LAUNCHER__ + return launcher(argc, argv); +#endif puts("running"); Context* cxt = new Context(); cxt->log("%d %s\n", argc, argv[1]); @@ -248,11 +253,7 @@ extern "C" int __DLLEXPORT__ main(int argc, char** argv) { if (argc < 0) return dll_main(argc, argv, cxt); else if (argc <= 1) -#ifdef __AQ__TESTING__ return test_main(); -#else - return launcher(argc, argv); -#endif else shmname = argv[1]; SharedMemory shm = SharedMemory(shmname); diff --git a/server/server.vcxproj b/server/server.vcxproj index bc613e7..638cc00 100644 --- a/server/server.vcxproj +++ b/server/server.vcxproj @@ -255,7 +255,7 @@ - + diff --git a/server/table.cpp b/server/table.cpp deleted file mode 100644 index 5e5d194..0000000 --- a/server/table.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "table.h" - - -#ifdef __SIZEOF_INT128__ -template <> -void print<__int128_t>(const __int128_t& v, const char* delimiter){ - char s[41]; - s[40] = 0; - std::cout<< get_int128str(v, s+40)<< delimiter; -} -template <> -void print<__uint128_t>(const __uint128_t&v, const char* delimiter){ - char s[41]; - s[40] = 0; - std::cout<< get_uint128str(v, s+40) << delimiter; -} -std::ostream& operator<<(std::ostream& os, __int128 & v) -{ - print(v); - return os; -} -std::ostream& operator<<(std::ostream& os, __uint128_t & v) -{ - print(v); - return os; -} -#endif - -template <> -void print(const bool&v, const char* delimiter){ - std::cout<< (v?"true":"false") << delimiter; -} diff --git a/server/table.h b/server/table.h index d2bbf88..b52b494 100644 --- a/server/table.h +++ b/server/table.h @@ -7,6 +7,7 @@ #include "vector_type.hpp" #include #include +#include #include "io.h" #undef ERROR template diff --git a/server/types.cpp b/server/types.cpp deleted file mode 100644 index e30164b..0000000 --- a/server/types.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "types.h" -#include -#include -#include -#include -namespace types { - using namespace std; - using namespace chrono; - string date_t::toString() const { - uint32_t curr_v = val; - tm; - time_t; - return string() + string("/") + string() + string("/") + string(); - } - string time_t::toString() const { - uint32_t curr_v = val; - - return string() + string("/") + string() + string("/") + string(); - } -} \ No newline at end of file diff --git a/server/types.h b/server/types.h index 16d824b..0934bb1 100644 --- a/server/types.h +++ b/server/types.h @@ -1,6 +1,5 @@ #ifndef _TYPES_H #define _TYPES_H -#include #include #include #include diff --git a/server/utils.cpp b/server/utils.cpp deleted file mode 100644 index 1766c10..0000000 --- a/server/utils.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "utils.h" -#include -#include -using std::string; -string base62uuid(int l = 8) { - using namespace std; - constexpr static const char* base62alp = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - static mt19937_64 engine(chrono::system_clock::now().time_since_epoch().count()); - static uniform_int_distribution u(0x10000, 0xfffff); - uint64_t uuid = (u(engine) << 32ull) + (chrono::system_clock::now().time_since_epoch().count() & 0xffffffff); - printf("%p\n", uuid); - string ret; - while (uuid && l-- >= 0) { - ret = string("") + base62alp[uuid % 62] + ret; - uuid /= 62; - } - return ret; -} \ No newline at end of file diff --git a/server/vector_type.cpp b/server/vector_type.cpp deleted file mode 100644 index 3cb23c1..0000000 --- a/server/vector_type.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "vector_type.hpp" -#include -template -inline void vector_type<_Ty>::out(uint32_t n, const char* sep) const -{ - n = n > size ? size : n; - std::cout << '('; - { - uint32_t i = 0; - for (; i < n - 1; ++i) - std::cout << this->operator[](i) << sep; - std::cout << this->operator[](i); - } - std::cout << ')'; -} \ No newline at end of file diff --git a/server/vector_type.hpp b/server/vector_type.hpp index 54b9bcb..4f64c82 100644 --- a/server/vector_type.hpp +++ b/server/vector_type.hpp @@ -10,12 +10,7 @@ #include #include -#include #include -#include -#include -#include -#include #include "types.h" #pragma pack(push, 1) diff --git a/test.aquery b/test.aquery index 71f5b9723ec3fb015410b9dec3f4584d9232f636..84e4beaa465305d9eb1b2b9d6695c487a2ca289d 100644 GIT binary patch delta 20 bcmX@je43d