@@ -85,7 +85,7 @@ void init_codegen_proxy(const bpo::variables_map& vm,
85
85
}
86
86
87
87
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 ) {
89
89
if (!std::filesystem::exists (workspace)) {
90
90
LOG (ERROR) << " Workspace directory not exists: " << workspace;
91
91
}
@@ -126,7 +126,12 @@ void openDefaultGraph(const std::string workspace, int32_t thread_num,
126
126
<< " , for graph: " << default_graph;
127
127
}
128
128
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 ()) {
130
135
LOG (FATAL) << " Fail to load graph from data directory: " << data_dir;
131
136
}
132
137
LOG (INFO) << " Successfully init graph db for default graph: "
@@ -164,7 +169,9 @@ int main(int argc, char** argv) {
164
169
" enable-trace" , bpo::value<bool >()->default_value (false ),
165
170
" whether to enable opentelemetry tracing" )(
166
171
" 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" );
168
175
169
176
setenv (" TZ" , " Asia/Shanghai" , 1 );
170
177
tzset ();
@@ -195,6 +202,7 @@ int main(int argc, char** argv) {
195
202
service_config.engine_config_path = engine_config_file;
196
203
service_config.start_admin_service = vm[" enable-admin-service" ].as <bool >();
197
204
service_config.start_compiler = vm[" start-compiler" ].as <bool >();
205
+ service_config.memory_level = vm[" memory-level" ].as <unsigned >();
198
206
199
207
auto & db = gs::GraphDB::get ();
200
208
@@ -218,7 +226,8 @@ int main(int argc, char** argv) {
218
226
}
219
227
220
228
gs::openDefaultGraph (workspace, service_config.shard_num ,
221
- service_config.default_graph );
229
+ service_config.default_graph ,
230
+ service_config.memory_level );
222
231
// Suppose the default_graph is already loaded.
223
232
LOG (INFO) << " Finish init workspace" ;
224
233
auto schema_file = server::WorkDirManipulator::GetGraphSchemaPath (
0 commit comments