Skip to content

Commit

Permalink
[gc] CLI arg for minor heap size and domain support
Browse files Browse the repository at this point in the history
Summary:
Surprisingly, setting the GC parameters like the minor heap size does not affect the minor heap size of domains spawned later (they start with the default size). This diff
- makes available a command line argument for choosing the minor heap size
- uses that whenever a domain is spawned in multicore mode to set up the correct minor heap size

Reviewed By: geralt-encore

Differential Revision:
D69526842

Privacy Context Container: L1208441

fbshipit-source-id: 05afb38adbba1501f56ab26908ed451c46acc9ff
  • Loading branch information
ngorogiannis authored and facebook-github-bot committed Feb 13, 2025
1 parent 7cb21b5 commit 627adf2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
3 changes: 3 additions & 0 deletions infer/man/man1/infer-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3029,6 +3029,9 @@ INTERNAL OPTIONS
--merge-summaries-reset
Set --merge-summaries to the empty list.

--minor-heap-size-mb int
Set minor heap size (in Mb) for each process/domain. Defaults to 8

--noescaping-function-list-reset
Set --noescaping-function-list to the empty list.

Expand Down
6 changes: 4 additions & 2 deletions infer/src/backend/InferAnalyze.ml
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ let analyze replay_call_graph source_files_to_analyze =
Summary.OnDisk.set_lru_limit ~lru_limit:(Some Config.summaries_lru_max_size) ;
Exe_env.set_lru_limit ~lru_limit:(Some Config.tenvs_lru_max_size) ;
RestartScheduler.setup () ;
DomainPool.create ~jobs:Config.jobs ~f:analyze_target ~child_prologue:ignore
~child_epilogue:ignore ~tasks:(fun () ->
DomainPool.create ~jobs:Config.jobs ~f:analyze_target
~child_prologue:(fun _ -> Config.set_gc_params ())
~child_epilogue:ignore
~tasks:(fun () ->
tasks_generator_builder_for replay_call_graph (Lazy.force source_files_to_analyze) )
|> DomainPool.run |> ignore ;
( [Stats.get ()]
Expand Down
22 changes: 14 additions & 8 deletions infer/src/base/Config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,11 @@ and merge_summaries =
be merged together and deduplicated before reporting is done."


and minor_heap_size_mb =
CLOpt.mk_int ~long:"minor-heap-size-mb" ~default:8
"Set minor heap size (in Mb) for each process/domain. Defaults to 8"


and _method_decls_info =
CLOpt.mk_path_opt ~long:"" ~deprecated:["-method-decls-info"] ~meta:"method_decls_info.json"
"[DOES NOTHING, test determinator has been removed] Specifies the file containing the method \
Expand Down Expand Up @@ -3749,6 +3754,15 @@ let inferconfig_file =
Option.map inferconfig_dir ~f:(fun dir -> dir ^/ CommandDoc.inferconfig_file) )


let set_gc_params () =
let ctrl = Gc.get () in
let words_of_Mb nMb = nMb * 1024 * 1024 * 8 / Sys.word_size_in_bits in
let new_size nMb = max ctrl.minor_heap_size (words_of_Mb nMb) in
(* increase the minor heap size *)
let minor_heap_size = new_size !minor_heap_size_mb in
Gc.set {ctrl with minor_heap_size}


let post_parsing_initialization command_opt =
if CLOpt.is_originator [@warning "-3"] then
(* make sure subprocesses read from the same .inferconfig as the toplevel process *)
Expand Down Expand Up @@ -3845,14 +3859,6 @@ let post_parsing_initialization command_opt =
in
Stdlib.Printexc.set_uncaught_exception_handler uncaught_exception_handler ;
F.set_margin !margin ;
let set_gc_params () =
let ctrl = Gc.get () in
let words_of_Mb nMb = nMb * 1024 * 1024 * 8 / Sys.word_size_in_bits in
let new_size nMb = max ctrl.minor_heap_size (words_of_Mb nMb) in
(* increase the minor heap size *)
let minor_heap_size = new_size 8 in
Gc.set {ctrl with minor_heap_size}
in
set_gc_params () ;
let biabd_symops_timeout, biabd_seconds_timeout =
let default_symops_timeout = 1100 in
Expand Down
5 changes: 4 additions & 1 deletion infer/src/base/Config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ val merge_summaries : string list

val modeled_expensive : string * Yojson.Safe.t

val multicore : bool [@@warning "-unused-value-declaration"]
val multicore : bool

val never_returning_null : string * Yojson.Safe.t

Expand Down Expand Up @@ -972,3 +972,6 @@ val is_originator : bool
(** {2 Global variables with initial values specified by command-line options} *)

val clang_compilation_dbs : [`Escaped of string | `Raw of string] list

val set_gc_params : unit -> unit
(** set GC paramemters according to command line arguments and defaults *)
1 change: 1 addition & 0 deletions infer/src/base/DBWriterDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ let rec server_loop () =


let domain_server () =
Config.set_gc_params () ;
Database.new_database_connections Primary ;
server_loop ()

Expand Down

0 comments on commit 627adf2

Please sign in to comment.