From 01dc06b05f1ffad0b7e69edd72cc70c7b21d43b2 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Thu, 5 Sep 2019 04:44:51 -0700 Subject: [PATCH] [sqlite] launch daemon only if jobs > 1 Summary: As per title. Reviewed By: jvillard Differential Revision: D17181866 fbshipit-source-id: 26674d721 --- infer/src/infer.ml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/infer/src/infer.ml b/infer/src/infer.ml index d1303c527..8ac990618 100644 --- a/infer/src/infer.ml +++ b/infer/src/infer.ml @@ -15,17 +15,12 @@ module L = Logging let run driver_mode = let open Driver in - if CLOpt.is_originator && Config.(sqlite_write_daemon && not (buck || genrule_mode)) then - DBWriter.start () ; - Utils.try_finally_swallow_timeout - ~f:(fun () -> - run_prologue driver_mode ; - let changed_files = read_config_changed_files () in - InferAnalyze.invalidate_changed_procedures changed_files ; - capture driver_mode ~changed_files ; - analyze_and_report driver_mode ~changed_files ; - run_epilogue () ) - ~finally:(fun () -> if CLOpt.is_originator && Config.sqlite_write_daemon then DBWriter.stop ()) + run_prologue driver_mode ; + let changed_files = read_config_changed_files () in + InferAnalyze.invalidate_changed_procedures changed_files ; + capture driver_mode ~changed_files ; + analyze_and_report driver_mode ~changed_files ; + run_epilogue () let run driver_mode = ScubaLogging.execute_with_time_logging "run" (fun () -> run driver_mode) @@ -62,7 +57,10 @@ let setup () = if CLOpt.is_originator then ( RunState.add_run_to_sequence () ; RunState.store () ; - if Config.memcached then Memcached.start () ) ; + if Config.memcached then Memcached.start () ; + if Config.(sqlite_write_daemon && (not (buck || genrule_mode)) && jobs > 1) then ( + DBWriter.start () ; + Epilogues.register ~f:DBWriter.stop ~description:"Stop Sqlite write daemon" ) ) ; ()