Summary: - Instead of merging one target DB into the main DB at a time, merge all target DBs into an in-memory DB (thus, no writing) and then dump it into the main DB at the end. This makes merging faster. - When using the sqlite write daemon, there is no reason to drive the merge process from the master, sending each individual target to merge down the socket and doing one DB merge at a time. Here we move all the DB merging logic in the daemon, and expose a single function that does it all. - Refactor some common functionality (notably the `iter_infer_deps` function is now in `Utils`) and remove dead files. This can be also done using a temporary DB (which is not limited to memory) but this showed worse perf in tests than the in-memory solution as well as the current state of things (! possibly Sqlite-version related?). Reviewed By: skcho Differential Revision: D17182862 fbshipit-source-id: a6f81937dmaster
parent
c131e2e669
commit
16819fa1a4
@ -1,52 +0,0 @@
|
||||
(*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
open! IStd
|
||||
module L = Logging
|
||||
module YB = Yojson.Basic
|
||||
module YBU = Yojson.Basic.Util
|
||||
|
||||
let merge_changed_functions_json ~infer_out_src =
|
||||
let main_changed_fs_file = Config.results_dir ^/ Config.export_changed_functions_output in
|
||||
let changed_fs_file = infer_out_src ^/ Config.export_changed_functions_output in
|
||||
let main_json = try YB.from_file main_changed_fs_file |> YBU.to_list with Sys_error _ -> [] in
|
||||
let changed_json = try YB.from_file changed_fs_file |> YBU.to_list with Sys_error _ -> [] in
|
||||
let all_fs =
|
||||
`List
|
||||
(List.dedup_and_sort
|
||||
~compare:(fun s1 s2 ->
|
||||
match (s1, s2) with `String s1, `String s2 -> String.compare s1 s2 | _ -> 0 )
|
||||
(List.append main_json changed_json))
|
||||
in
|
||||
YB.to_file main_changed_fs_file all_fs
|
||||
|
||||
|
||||
let iter_infer_deps infer_deps_file ~f =
|
||||
let one_line line =
|
||||
match String.split ~on:'\t' line with
|
||||
| [_; _; target_results_dir] ->
|
||||
let infer_out_src =
|
||||
if Filename.is_relative target_results_dir then
|
||||
Filename.dirname (Config.project_root ^/ "buck-out") ^/ target_results_dir
|
||||
else target_results_dir
|
||||
in
|
||||
f ~infer_out_src
|
||||
| _ ->
|
||||
assert false
|
||||
in
|
||||
match Utils.read_file infer_deps_file with
|
||||
| Ok lines ->
|
||||
List.iter ~f:one_line lines
|
||||
| Error error ->
|
||||
L.internal_error "Couldn't read deps file '%s': %s" infer_deps_file error
|
||||
|
||||
|
||||
let merge_buck_flavors_results infer_deps_file =
|
||||
iter_infer_deps infer_deps_file ~f:DBWriter.merge_dbs
|
||||
|
||||
|
||||
let merge_buck_changed_functions infer_deps_file =
|
||||
iter_infer_deps infer_deps_file ~f:merge_changed_functions_json
|
@ -1,18 +0,0 @@
|
||||
(*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
val merge_buck_flavors_results : string -> unit
|
||||
(** Merge the results from sub-invocations of infer inside buck-out/. Takes as argument the
|
||||
infer_deps file. *)
|
||||
|
||||
val merge_buck_changed_functions : string -> unit
|
||||
(** Merge the changed functions from sub-invocations of infer inside buck-out/. Takes as argument the
|
||||
infer_deps file. *)
|
||||
|
||||
val iter_infer_deps : string -> f:(infer_out_src:string -> unit) -> unit
|
Loading…
Reference in new issue