Cache hostname lookup in event logger module

Summary:
Found a high number of `uname` syscalls while tracing infer. Figured it
must be the `Unix.gethostname` call. Stop continuously asking for the
hostname.

Reviewed By: jberdine

Differential Revision: D20309048

fbshipit-source-id: b8be1f2dc
master
Alexander Mols 5 years ago committed by Facebook Github Bot
parent 59e17f59b8
commit 1dae8f4eb6

@ -8,6 +8,8 @@
open! IStd open! IStd
module CLOpt = CommandLineOption module CLOpt = CommandLineOption
let hostname = Unix.gethostname ()
module IO = struct module IO = struct
let log_file_extension = ".log" let log_file_extension = ".log"
@ -353,7 +355,7 @@ module LoggerImpl : S = struct
empty empty
|> add_string ~key:"command" ~data:(InferCommand.to_string Config.command) |> add_string ~key:"command" ~data:(InferCommand.to_string Config.command)
|> add_string ~key:"event_tag" ~data:(string_of_event event) |> add_string ~key:"event_tag" ~data:(string_of_event event)
|> add_string ~key:"hostname" ~data:(Unix.gethostname ()) |> add_string ~key:"hostname" ~data:hostname
|> add_string ~key:"infer_commit" ~data:Version.commit |> add_string ~key:"infer_commit" ~data:Version.commit
|> add_int ~key:"is_originator" ~data:(if CLOpt.is_originator then 1 else 0) |> add_int ~key:"is_originator" ~data:(if CLOpt.is_originator then 1 else 0)
|> add_string_opt ~key:"job_id" ~data:Config.job_id |> add_string_opt ~key:"job_id" ~data:Config.job_id

Loading…
Cancel
Save