Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Don't retrieve actor hostname again if it's already there.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 30 Mar 2021 19:57:49 +0000 (21:57 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 30 Mar 2021 19:59:05 +0000 (21:59 +0200)
src/mc/api.cpp

index 8b0c516..fe28ad3 100644 (file)
@@ -367,14 +367,16 @@ xbt::string const& Api::get_actor_host_name(smx_actor_t actor) const
   // Read the simgrid::xbt::string in the MCed process:
   simgrid::mc::ActorInformation* info = actor_info_cast(actor);
 
-  Remote<s4u::Host> temp_host = process->read(remote(actor->get_host()));
-  auto temp_host_name_address = &temp_host.get_buffer()->get_impl()->get_name();
-  auto remote_string_address  = remote(reinterpret_cast<const simgrid::xbt::string_data*>(temp_host_name_address));
-  simgrid::xbt::string_data remote_string = process->read(remote_string_address);
-  std::vector<char> hostname(remote_string.len + 1);
-  // no need to read the terminating null byte, and thus hostname[remote_string.len] is guaranteed to be '\0'
-  process->read_bytes(hostname.data(), remote_string.len, remote(remote_string.data));
-  info->hostname = &mc_model_checker->get_host_name(hostname.data());
+  if (not info->hostname) {
+    Remote<s4u::Host> temp_host = process->read(remote(actor->get_host()));
+    auto temp_host_name_address = &temp_host.get_buffer()->get_impl()->get_name();
+    auto remote_string_address  = remote(reinterpret_cast<const simgrid::xbt::string_data*>(temp_host_name_address));
+    simgrid::xbt::string_data remote_string = process->read(remote_string_address);
+    std::vector<char> hostname(remote_string.len + 1);
+    // no need to read the terminating null byte, and thus hostname[remote_string.len] is guaranteed to be '\0'
+    process->read_bytes(hostname.data(), remote_string.len, remote(remote_string.data));
+    info->hostname = &mc_model_checker->get_host_name(hostname.data());
+  }
   return *info->hostname;
 }