From 1dae8f4eb677578737117ad7f3d0de33bc611f28 Mon Sep 17 00:00:00 2001 From: Alexander Mols Date: Mon, 9 Mar 2020 01:52:47 -0700 Subject: [PATCH] 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 --- infer/src/base/EventLogger.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/infer/src/base/EventLogger.ml b/infer/src/base/EventLogger.ml index 20fa17219..255f62774 100644 --- a/infer/src/base/EventLogger.ml +++ b/infer/src/base/EventLogger.ml @@ -8,6 +8,8 @@ open! IStd module CLOpt = CommandLineOption +let hostname = Unix.gethostname () + module IO = struct let log_file_extension = ".log" @@ -353,7 +355,7 @@ module LoggerImpl : S = struct empty |> add_string ~key:"command" ~data:(InferCommand.to_string Config.command) |> 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_int ~key:"is_originator" ~data:(if CLOpt.is_originator then 1 else 0) |> add_string_opt ~key:"job_id" ~data:Config.job_id