@@ -101,145 +101,15 @@ let get_hot_classes (filename : string) : SSet.t =
101101 |> List. map ~f: Hh_json. get_string_exn
102102 |> SSet. of_list
103103
104- (* * Dumps the naming-table (a saveable form of FileInfo), and errors if any,
105- and hot class decls. *)
106- let dump_naming_and_errors
107- (output_filename : string )
108- (naming_table : Naming_table.t )
109- (errors : Errors.t ) : unit =
110- let naming_sql_filename = output_filename ^ " _naming.sql" in
111- let (save_result : Naming_sqlite.save_result ) =
112- Naming_table. save naming_table naming_sql_filename
113- in
114- Hh_logger. log
115- " Inserted symbols into the naming table:\n %s"
116- (Naming_sqlite. show_save_result save_result);
117- Hh_logger. log
118- " Finished saving naming table with %d errors."
119- (List. length save_result.Naming_sqlite. errors);
120-
121- if List. length save_result.Naming_sqlite. errors > 0 then
122- Exit. exit Exit_status. Sql_assertion_failure ;
123-
124- assert (Sys. file_exists naming_sql_filename);
125- Hh_logger. log " Saved naming table sqlite to '%s'" naming_sql_filename;
126- (* Let's not write empty error files. *)
127- (if Errors. is_empty errors then
128- ()
129- else
130- let error_files : saved_state_errors = Errors. get_failed_files errors in
131- save_contents (get_errors_filename output_filename) error_files);
132- ()
133-
134- (* * Sorts and dumps the error relative paths in JSON format.
135- * An empty JSON list will be dumped if there are no errors.*)
136- let dump_errors_json (output_filename : string ) (errors : Errors.t ) : unit =
137- let error_files = Errors. get_failed_files errors in
138- let errors_json =
139- Hh_json. (
140- JSON_Array
141- (List. rev
142- (Relative_path.Set. fold
143- ~init: []
144- ~f: (fun relative_path acc ->
145- JSON_String (Relative_path. suffix relative_path) :: acc)
146- error_files)))
147- in
148- let chan = Stdlib. open_out (get_errors_filename_json output_filename) in
149- Hh_json. json_to_output chan errors_json;
150- Stdlib. close_out chan
151-
152104let saved_state_info_file_name ~base_file_name = base_file_name ^ " _info.json"
153105
154- let saved_state_build_revision_write ~(base_file_name : string ) : unit =
155- let info_file = saved_state_info_file_name ~base_file_name in
156- let open Hh_json in
157- Out_channel. with_file info_file ~f: (fun fh ->
158- json_to_output fh
159- @@ JSON_Object [(" build_revision" , string_ Build_id. build_revision)])
160-
161106let saved_state_build_revision_read ~(base_file_name : string ) : string =
162107 let info_file = saved_state_info_file_name ~base_file_name in
163108 let contents = RealDisk. cat info_file in
164109 let json = Some (Hh_json. json_of_string contents) in
165110 let build_revision = Hh_json_helpers.Jget. string_exn json " build_revision" in
166111 build_revision
167112
168- let dump_dep_graph_64bit ~mode ~db_name ~incremental_info_file =
169- let t = Unix. gettimeofday () in
170- let base_dep_graph =
171- match mode with
172- | Typing_deps_mode. InMemoryMode base_dep_graph -> base_dep_graph
173- | Typing_deps_mode. SaveToDiskMode { graph; _ } -> graph
174- in
175- let () =
176- let open Hh_json in
177- Out_channel. with_file incremental_info_file ~f: (fun fh ->
178- json_to_output fh
179- @@ JSON_Object [(" base_dep_graph" , string_opt base_dep_graph)])
180- in
181- let dep_table_edges_added =
182- Typing_deps. save_discovered_edges
183- mode
184- ~dest: db_name
185- ~reset_state_after_saving: false
186- in
187- let (_ : float ) = Hh_logger. log_duration " Writing discovered edges took" t in
188- { dep_table_edges_added }
189-
190- (* * Saves the saved state to the given path. Returns number of dependency
191- * edges dumped into the database. *)
192- let save_state (env : ServerEnv.env ) (output_filename : string ) :
193- save_state_result =
194- let () = Sys_utils. mkdir_p (Filename. dirname output_filename) in
195- let db_name =
196- match env.ServerEnv. deps_mode with
197- | Typing_deps_mode. InMemoryMode _
198- | Typing_deps_mode. SaveToDiskMode _ ->
199- output_filename ^ " _64bit_dep_graph.delta"
200- in
201- let () =
202- if Sys. file_exists output_filename then
203- failwith
204- (Printf. sprintf " Cowardly refusing to overwrite '%s'." output_filename)
205- else
206- ()
207- in
208- let () =
209- if Sys. file_exists db_name then
210- failwith (Printf. sprintf " Cowardly refusing to overwrite '%s'." db_name)
211- else
212- ()
213- in
214- let (_ : float ) =
215- let naming_table = env.ServerEnv. naming_table in
216- let errors = env.ServerEnv. errorl in
217- let t = Unix. gettimeofday () in
218- dump_naming_and_errors output_filename naming_table errors;
219- Hh_logger. log_duration " Saving saved-state naming+errors took" t
220- in
221- match env.ServerEnv. deps_mode with
222- | Typing_deps_mode. InMemoryMode _ ->
223- let incremental_info_file = output_filename ^ " _incremental_info.json" in
224- dump_errors_json output_filename env.ServerEnv. errorl;
225- saved_state_build_revision_write ~base_file_name: output_filename;
226- dump_dep_graph_64bit
227- ~mode: env.ServerEnv. deps_mode
228- ~db_name
229- ~incremental_info_file
230- | Typing_deps_mode. SaveToDiskMode
231- { graph = _; new_edges_dir; human_readable_dep_map_dir } ->
232- dump_errors_json output_filename env.ServerEnv. errorl;
233- saved_state_build_revision_write ~base_file_name: output_filename;
234- Hh_logger. warn
235- " saveStateService: not saving 64-bit dep graph edges to disk, because they are already in %s"
236- new_edges_dir;
237- (match human_readable_dep_map_dir with
238- | None -> ()
239- | Some dir ->
240- Hh_logger. warn " saveStateService: human readable dep map dir: %s" dir);
241- { dep_table_edges_added = 0 }
242-
243113let go_naming (naming_table : Naming_table.t ) (output_filename : string ) :
244114 (save_naming_result , string ) result =
245115 Utils. try_with_stack (fun () ->
@@ -257,10 +127,3 @@ let go_naming (naming_table : Naming_table.t) (output_filename : string) :
257127 nt_symbols_added = save_result.Naming_sqlite. symbols_added;
258128 })
259129 |> Result. map_error ~f: (fun e -> Exception. get_ctor_string e)
260-
261- (* If successful, returns the # of edges from the dependency table that were written. *)
262- (* TODO: write some other stats, e.g., the number of names, the number of errors, etc. *)
263- let go (env : ServerEnv.env ) (output_filename : string ) :
264- (save_state_result , string ) result =
265- Utils. try_with_stack (fun () -> save_state env output_filename)
266- |> Result. map_error ~f: (fun e -> Exception. get_ctor_string e)
0 commit comments