Skip to content

Commit f17a320

Browse files
committed
add mem-level option for interactive server
1 parent cbc2691 commit f17a320

File tree

2 files changed

+245
-212
lines changed

2 files changed

+245
-212
lines changed

flex/bin/interactive_server.cc

+13-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void init_codegen_proxy(const bpo::variables_map& vm,
8585
}
8686

8787
void openDefaultGraph(const std::string workspace, int32_t thread_num,
88-
const std::string& default_graph) {
88+
const std::string& default_graph, uint32_t memory_level) {
8989
if (!std::filesystem::exists(workspace)) {
9090
LOG(ERROR) << "Workspace directory not exists: " << workspace;
9191
}
@@ -126,7 +126,12 @@ void openDefaultGraph(const std::string workspace, int32_t thread_num,
126126
<< ", for graph: " << default_graph;
127127
}
128128
db.Close();
129-
if (!db.Open(schema_res.value(), data_dir, thread_num).ok()) {
129+
gs::GraphDBConfig config(schema_res.value(), data_dir, thread_num);
130+
config.memory_level = memory_level;
131+
if (config.memory_level >= 2) {
132+
config.enable_auto_compaction = true;
133+
}
134+
if (!db.Open(config).ok()) {
130135
LOG(FATAL) << "Fail to load graph from data directory: " << data_dir;
131136
}
132137
LOG(INFO) << "Successfully init graph db for default graph: "
@@ -164,7 +169,9 @@ int main(int argc, char** argv) {
164169
"enable-trace", bpo::value<bool>()->default_value(false),
165170
"whether to enable opentelemetry tracing")(
166171
"start-compiler", bpo::value<bool>()->default_value(false),
167-
"whether or not to start compiler");
172+
"whether or not to start compiler")(
173+
"memory-level,m", bpo::value<unsigned>()->default_value(1),
174+
"memory allocation strategy");
168175

169176
setenv("TZ", "Asia/Shanghai", 1);
170177
tzset();
@@ -195,6 +202,7 @@ int main(int argc, char** argv) {
195202
service_config.engine_config_path = engine_config_file;
196203
service_config.start_admin_service = vm["enable-admin-service"].as<bool>();
197204
service_config.start_compiler = vm["start-compiler"].as<bool>();
205+
service_config.memory_level = vm["memory-level"].as<unsigned>();
198206

199207
auto& db = gs::GraphDB::get();
200208

@@ -218,7 +226,8 @@ int main(int argc, char** argv) {
218226
}
219227

220228
gs::openDefaultGraph(workspace, service_config.shard_num,
221-
service_config.default_graph);
229+
service_config.default_graph,
230+
service_config.memory_level);
222231
// Suppose the default_graph is already loaded.
223232
LOG(INFO) << "Finish init workspace";
224233
auto schema_file = server::WorkDirManipulator::GetGraphSchemaPath(

0 commit comments

Comments
 (0)