diff --git a/benchmark/remote_infinity/remote_query_benchmark.cpp b/benchmark/remote_infinity/remote_query_benchmark.cpp index 770bb03af3..9d83964586 100644 --- a/benchmark/remote_infinity/remote_query_benchmark.cpp +++ b/benchmark/remote_infinity/remote_query_benchmark.cpp @@ -42,7 +42,7 @@ struct InfinityClient { std::unique_ptr client; int64_t session_id; InfinityClient() { - socket.reset(new TSocket("127.0.0.1", 9080)); + socket.reset(new TSocket("127.0.0.1", 23817)); transport.reset(new TBufferedTransport(socket)); protocol.reset(new TBinaryProtocol(transport)); client = std::make_unique(protocol); diff --git a/conf/infinity_conf.toml.template b/conf/infinity_conf.toml.template index 7592c802d6..8a556bd802 100644 --- a/conf/infinity_conf.toml.template +++ b/conf/infinity_conf.toml.template @@ -8,7 +8,7 @@ sdk_port = 23817 [system] # 0 means use all cpus -worker_cpu_limit = 4 +worker_cpu_limit = 0 # 0 means use all memory total_memory_size = "8GB" # memory limit per query @@ -28,7 +28,7 @@ log_max_size = "10GB" log_file_rotate_count = 10 # trace/info/warning/error/critical 5 log levels, default: info -log_level = "trace" +log_level = "warning" [storage] data_dir = "/tmp/infinity/data" diff --git a/python/README.md b/python/README.md index 458fac0046..5a90a25f69 100644 --- a/python/README.md +++ b/python/README.md @@ -30,7 +30,7 @@ pip install dist/infinity-0.0.1-py3-none-any.whl import infinity from infinity import NetworkAddress -infinity_obj = infinity.connect(NetworkAddress('127.0.0.1', 9080)) +infinity_obj = infinity.connect(NetworkAddress('127.0.0.1', 23817)) # infinity res = infinity_obj.create_database("my_db") diff --git a/python/benchmark/remote_benchmark.py b/python/benchmark/remote_benchmark.py index ccb939cd8d..ec79ca4ce4 100644 --- a/python/benchmark/remote_benchmark.py +++ b/python/benchmark/remote_benchmark.py @@ -143,13 +143,12 @@ def process_pool(threads, rounds, query_path, tabel_name): queries = fvecs_read_all(query_path) for i in range(rounds): - start = time.time() p = multiprocessing.Pool(threads) - for idx, query_vec in enumerate(queries): + start = time.time() + for idx, query_vec in enumerate(fvecs_read(query_path)): p.apply_async(work, args=(query_vec, 100, "l2", "col1", "float", tabel_name)) p.close() p.join() - end = time.time() dur = end - start results.append(f"Round {i + 1}:") diff --git a/python/benchmark/test_benchmark.py b/python/benchmark/test_benchmark.py index 36cc39fcaf..a45aaa1202 100644 --- a/python/benchmark/test_benchmark.py +++ b/python/benchmark/test_benchmark.py @@ -218,7 +218,7 @@ def drop_index(infinity_obj, port, process_id, thread_id, num_iteration): ip: str = '0.0.0.0' thrift = ("Thrift", ip, 9090) - thread_pool_thrift = ("Thread Pool Thrift", ip, 9080) + thread_pool_thrift = ("Thread Pool Thrift", ip, 23817) async_thrift = ("AsyncThrift", ip, 9070) num_processes = 16 num_threads = 16 diff --git a/python/infinity/__init__.py b/python/infinity/__init__.py index 175d5cb440..9a7b2e2238 100644 --- a/python/infinity/__init__.py +++ b/python/infinity/__init__.py @@ -24,7 +24,7 @@ def connect( uri: URI = LOCAL_HOST ) -> InfinityConnection: - if isinstance(uri, NetworkAddress) and (uri.port == 9090 or uri.port == 9080 or uri.port == 9070): + if isinstance(uri, NetworkAddress) and (uri.port == 9090 or uri.port == 23817 or uri.port == 9070): return RemoteThriftInfinityConnection(uri) else: raise Exception(f"unknown uri: {uri}") diff --git a/python/infinity/common.py b/python/infinity/common.py index 42eecec25f..6734f0b2fc 100644 --- a/python/infinity/common.py +++ b/python/infinity/common.py @@ -29,5 +29,5 @@ def __str__(self): URI = Union[NetworkAddress, Path] VEC = Union[list, np.ndarray] -REMOTE_HOST = NetworkAddress("127.0.0.1", 9080) -LOCAL_HOST = NetworkAddress("0.0.0.0", 9080) +REMOTE_HOST = NetworkAddress("127.0.0.1", 23817) +LOCAL_HOST = NetworkAddress("0.0.0.0", 23817) diff --git a/python/test/test.py b/python/test/test.py index 36d3670093..e7e6b6253f 100644 --- a/python/test/test.py +++ b/python/test/test.py @@ -34,7 +34,7 @@ def test_connection(self): method: connect server expect: connect and disconnect successfully """ - ports = [9090, 9080, 9070] + ports = [9090, 23817, 9070] for port in ports: infinity_obj = infinity.connect(REMOTE_HOST) assert infinity_obj @@ -73,7 +73,7 @@ def test_infinity_thrift(self): 12. expect: all operations successfully """ - ports = [9080] + ports = [23817] for port in ports: infinity_obj = infinity.connect(REMOTE_HOST) assert infinity_obj diff --git a/python/test/test_import.py b/python/test/test_import.py index bdef9af9ad..0502364023 100644 --- a/python/test/test_import.py +++ b/python/test/test_import.py @@ -29,7 +29,7 @@ def test_import(self): method: connect server, create table, import data, search, drop table, disconnect expect: all operations successfully """ - ports = [9080] + ports = [23817] for port in ports: infinity_obj = infinity.connect(REMOTE_HOST) assert infinity_obj diff --git a/src/bin/infinity_main.cpp b/src/bin/infinity_main.cpp index f0aa398b0e..dacdffbe7d 100644 --- a/src/bin/infinity_main.cpp +++ b/src/bin/infinity_main.cpp @@ -21,6 +21,7 @@ import stl; import third_party; import db_server; import infinity_exception; +import infinity_context; namespace { @@ -145,13 +146,17 @@ auto main(int argc, char **argv) -> int { StartupParameter parameters; ParseArguments(argc, argv, parameters); - db_server.Init(parameters); + InfinityContext::instance().Init(parameters.config_path); + RegisterSignal(); + InfinityContext::instance().config()->PrintAll(); + // threaded_thrift_server.Init(9090); // threaded_thrift_thread = infinity::Thread([&]() { threaded_thrift_server.Start(); }); + u32 thrift_server_port = InfinityContext::instance().config()->sdk_port(); - pool_thrift_server.Init(9080, 128); + pool_thrift_server.Init(thrift_server_port, 128); pool_thrift_thread = infinity::Thread([&]() { pool_thrift_server.Start(); }); // non_block_pool_thrift_server.Init(9070, 64); diff --git a/src/main/config.cpp b/src/main/config.cpp index 61504fbff2..2bee8cb30f 100644 --- a/src/main/config.cpp +++ b/src/main/config.cpp @@ -191,7 +191,7 @@ SharedPtr Config::Init(const SharedPtr &config_path) { // Resource { system_option_.resource_dict_path_ = default_resource_dict_path; } } else { - Printf("Read config from: {}", *config_path); + Printf("Read config from: {}\n", *config_path); TomlTable config = TomlParseFile(*config_path); // General { diff --git a/src/network/db_server.cpp b/src/network/db_server.cpp index bd490995e7..b055985c58 100644 --- a/src/network/db_server.cpp +++ b/src/network/db_server.cpp @@ -29,8 +29,6 @@ import connection; namespace infinity { -void DBServer::Init(const StartupParameter ¶meter) { config_path_ = Move(parameter.config_path); } - void DBServer::Run() { if (initialized) { return; @@ -38,15 +36,13 @@ void DBServer::Run() { initialized = true; - InfinityContext::instance().Init(config_path_); - u16 pg_port = InfinityContext::instance().config()->pg_port(); - const String &listen_address_ref = InfinityContext::instance().config()->listen_address(); + const String &pg_listen_addr = InfinityContext::instance().config()->listen_address(); BoostErrorCode error; - AsioIpAddr address = asio_make_address(listen_address_ref, error); + AsioIpAddr address = asio_make_address(pg_listen_addr, error); if (error) { - Printf("{} isn't a valid IPv4 address.\n", listen_address_ref); + Printf("{} isn't a valid IPv4 address.\n", pg_listen_addr); infinity::InfinityContext::instance().UnInit(); return ; } @@ -54,15 +50,7 @@ void DBServer::Run() { acceptor_ptr_ = MakeUnique(io_service_, AsioEndPoint(address, pg_port)); CreateConnection(); - if (config_path_) { - Printf("Start up database server, at: {} and port: {}, config: {}\n", listen_address_ref, pg_port, *config_path_); - } else { - Printf("Start up database server, at: {} and port: {}\n", listen_address_ref, pg_port); - } - - InfinityContext::instance().config()->PrintAll(); - - Printf("Run 'psql -h {} -p {}' to connect to the server.\n", listen_address_ref, pg_port); + Printf("Run 'psql -h {} -p {}' to connect to the server.\n", pg_listen_addr, pg_port); io_service_.run(); } diff --git a/src/network/db_server.cppm b/src/network/db_server.cppm index ed699655b6..1149129645 100644 --- a/src/network/db_server.cppm +++ b/src/network/db_server.cppm @@ -31,8 +31,6 @@ class ThriftServer; export class DBServer { public: - void Init(const StartupParameter& parameter); - void Run(); void Shutdown(); @@ -46,7 +44,6 @@ private: atomic_u64 running_connection_count_{0}; AsioIOService io_service_{}; UniquePtr acceptor_ptr_{}; - SharedPtr config_path_{}; }; } diff --git a/src/network/thrift_server.cpp b/src/network/thrift_server.cpp index 24ea862832..9fda92148f 100644 --- a/src/network/thrift_server.cpp +++ b/src/network/thrift_server.cpp @@ -1096,7 +1096,7 @@ void PoolThriftServer::Init(i32 port_no, i32 pool_size) { threadManager->threadFactory(threadFactory); threadManager->start(); - std::cout << "Thrift server listen on: 0.0.0.0:" << port_no << ", thread pool: " << pool_size << std::endl; + std::cout << "API server listen on: 0.0.0.0:" << port_no << ", thread pool: " << pool_size << std::endl; server = MakeUnique(MakeShared(MakeShared()),