Skip to content

Commit

Permalink
Save / Load type environment without saving / loading dependency keys
Browse files Browse the repository at this point in the history
Summary:
The dependency keys (which are used for pyre incremental) are too large to be
saved in the shared memory -- each value in a shared memory entry must not
exceed 2 GB.

Since Pysa does not use the dependency keys in any way, we can skip saving them
into the shared memory.

Reviewed By: alexkassil

Differential Revision: D49068488

fbshipit-source-id: 0056099ee969decf2bcae3019b246c5a130d50ea
  • Loading branch information
Tianhan Lu authored and facebook-github-bot committed Sep 8, 2023
1 parent 61ea349 commit 19e6a40
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions source/analysis/typeEnvironment.ml
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,8 @@ let load configuration =
CheckResultsTable.load configuration


let store_without_dependency_keys = CheckResultsTable.store

let load_without_dependency_keys = CheckResultsTable.load

module TypeEnvironmentReadOnly = ReadOnly
4 changes: 4 additions & 0 deletions source/analysis/typeEnvironment.mli
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ val ast_environment : t -> AstEnvironment.t
val module_tracker : t -> ModuleTracker.t

val populate_for_modules : scheduler:Scheduler.t -> t -> Ast.Reference.t list -> unit

val store_without_dependency_keys : t -> unit

val load_without_dependency_keys : EnvironmentControls.t -> t
4 changes: 2 additions & 2 deletions source/interprocedural_analyses/taint/cache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ let load_type_environment ~scheduler ~configuration =
SaveLoadSharedMemory.exception_to_error
~error:SharedMemoryStatus.TypeEnvironmentLoadError
~message:"Loading type environment"
~f:(fun () -> Ok (TypeEnvironment.load controls))
~f:(fun () -> Ok (TypeEnvironment.load_without_dependency_keys controls))
>>= fun type_environment ->
let old_module_tracker =
TypeEnvironment.ast_environment type_environment |> AstEnvironment.module_tracker
Expand Down Expand Up @@ -255,7 +255,7 @@ let save_type_environment ~scheduler ~configuration ~environment =
Memory.SharedMemory.collect `aggressive;
let module_tracker = TypeEnvironment.module_tracker environment in
Interprocedural.ChangedPaths.save_current_paths ~scheduler ~configuration ~module_tracker;
TypeEnvironment.store environment;
TypeEnvironment.store_without_dependency_keys environment;
Log.info "Saved type environment to cache shared memory.";
Ok ())

Expand Down

0 comments on commit 19e6a40

Please sign in to comment.