From 993ee56fa166aabaf963ae087c9cad2e54986f10 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Fri, 29 Sep 2017 08:45:55 -0700 Subject: [PATCH] [sql] disable compaction while merge results Summary: Not sure if useful but seems sensible. It disappears at the top of the stack when we do merging in SQL. Reviewed By: mbouaziz Differential Revision: D5824131 fbshipit-source-id: fd64752 --- INSTALL.md | 3 ++- infer/src/backend/InferPrint.ml | 12 ++---------- infer/src/base/MergeResults.ml | 3 ++- infer/src/base/Utils.ml | 8 ++++++++ infer/src/base/Utils.mli | 3 +++ 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index d14d6a57c..9fce15dfe 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -20,6 +20,7 @@ compile everything from source (see the end of this document). - opam 1.2.2 (instructions [here](https://opam.ocaml.org/doc/Install.html#OSX)) - Python 2.7 +- sqlite - pkg-config - Java (only needed for the Java analysis) - cmake (only needed for the C/Objective-C analysis) @@ -32,7 +33,7 @@ You can install some of these dependencies using [Homebrew](http://brew.sh/): ```sh -brew install autoconf automake cmake opam pkg-config +brew install autoconf automake cmake opam pkg-config sqlite brew cask install java ``` diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index 6658c5036..8735c5683 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -962,15 +962,6 @@ module AnalysisResults = struct if List.is_empty Config.anon_args then load_specfiles () else List.rev Config.anon_args ) else load_specfiles () - (** apply [f] to [arg] with the gc compaction disabled during the execution *) - let apply_without_gc f arg = - let stat = Gc.get () in - let space_oh = stat.space_overhead in - Gc.set {stat with space_overhead= 10000} ; - let res = f arg in - Gc.set {stat with space_overhead= space_oh} ; - res - (** Load .specs files in memory and return list of summaries *) let load_summaries_in_memory () : t = let summaries = ref [] in @@ -981,7 +972,8 @@ module AnalysisResults = struct | Some summary -> summaries := (fname, summary) :: !summaries in - apply_without_gc (List.iter ~f:load_file) (spec_files_from_cmdline ()) ; + let do_load () = spec_files_from_cmdline () |> List.iter ~f:load_file in + Utils.without_gc ~f:do_load ; let summ_cmp (_, summ1) (_, summ2) = let n = SourceFile.compare summ1.Specs.attributes.ProcAttributes.loc.Location.file diff --git a/infer/src/base/MergeResults.ml b/infer/src/base/MergeResults.ml index 93130d27f..0fe50c2f6 100644 --- a/infer/src/base/MergeResults.ml +++ b/infer/src/base/MergeResults.ml @@ -26,7 +26,8 @@ let merge ~into db = let db_name = "db" in SqliteUtils.check_sqlite_error ~fatal:true ~log:"attaching db" (Sqlite3.exec into (Printf.sprintf "ATTACH '%s' AS %s" db db_name)) ; - merge_attributes_table ~into ~db_name ; + let do_merge () = merge_attributes_table ~into ~db_name in + Utils.without_gc ~f:do_merge ; SqliteUtils.check_sqlite_error ~fatal:true ~log:"detaching db" (Sqlite3.exec into (Printf.sprintf "DETACH %s" db_name)) ; () diff --git a/infer/src/base/Utils.ml b/infer/src/base/Utils.ml index 5dc0a3fa2..fb7be309b 100644 --- a/infer/src/base/Utils.ml +++ b/infer/src/base/Utils.ml @@ -308,3 +308,11 @@ let rec rmtree name = -> Unix.unlink name | exception Unix.Unix_error (Unix.ENOENT, _, _) -> () + +let without_gc ~f = + let stat = Gc.get () in + let space_oh = stat.space_overhead in + Gc.set {stat with space_overhead= 10000} ; + let res = f () in + Gc.set {stat with space_overhead= space_oh} ; + res diff --git a/infer/src/base/Utils.mli b/infer/src/base/Utils.mli index ec175a07f..da92b9f64 100644 --- a/infer/src/base/Utils.mli +++ b/infer/src/base/Utils.mli @@ -98,3 +98,6 @@ val rmtree : string -> unit val try_finally_swallow_timeout : f:(unit -> 'a) -> finally:(unit -> unit) -> 'a (** Calls [f] then [finally] even if [f] raised an exception. The original exception is reraised afterwards. Where possible use [SymOp.try_finally] to avoid swallowing timeouts. *) + +val without_gc : f:(unit -> unit) -> unit +(** Call [f ()] with the gc compaction disabled during the execution *)