Skip to content

Commit c6910d5

Browse files
committed
perf(pegboard): parallelize writing configs under setup_oci_bundle
1 parent 79ca91f commit c6910d5

File tree

1 file changed

+31
-31
lines changed
  • packages/edge/infra/client/manager/src/actor

1 file changed

+31
-31
lines changed

packages/edge/infra/client/manager/src/actor/setup.rs

+31-31
Original file line numberDiff line numberDiff line change
@@ -369,38 +369,38 @@ impl Actor {
369369
memory: self.config.resources.memory,
370370
memory_max: self.config.resources.memory_max,
371371
})?;
372-
fs::write(oci_bundle_config_path, serde_json::to_vec(&config)?).await?;
373-
374-
// resolv.conf
375-
//
372+
// Parallelize file writes for better performance
373+
// Prepare content for all files before writing
374+
let config_json = serde_json::to_vec(&config)?;
375+
376+
// resolv.conf content
376377
// See also rivet-actor.conflist in packages/services/cluster/src/workflows/server/install/install_scripts/files/pegboard_configure.sh
377-
fs::write(
378-
actor_path.join("resolv.conf"),
379-
indoc!(
380-
"
381-
nameserver 8.8.8.8
382-
nameserver 8.8.4.4
383-
nameserver 2001:4860:4860::8888
384-
nameserver 2001:4860:4860::8844
385-
options rotate
386-
options edns0
387-
options attempts:2
388-
"
389-
),
390-
)
391-
.await?;
392-
393-
// hosts
394-
fs::write(
395-
fs_path.join("hosts"),
396-
indoc!(
397-
"
398-
127.0.0.1 localhost
399-
::1 localhost ip6-localhost ip6-loopback
400-
"
401-
),
402-
)
403-
.await?;
378+
let resolv_conf = indoc!(
379+
"
380+
nameserver 8.8.8.8
381+
nameserver 8.8.4.4
382+
nameserver 2001:4860:4860::8888
383+
nameserver 2001:4860:4860::8844
384+
options rotate
385+
options edns0
386+
options attempts:2
387+
"
388+
);
389+
390+
// hosts file content
391+
let hosts_content = indoc!(
392+
"
393+
127.0.0.1 localhost
394+
::1 localhost ip6-localhost ip6-loopback
395+
"
396+
);
397+
398+
// Write all files in parallel
399+
tokio::try_join!(
400+
fs::write(oci_bundle_config_path, config_json),
401+
fs::write(actor_path.join("resolv.conf"), resolv_conf),
402+
fs::write(fs_path.join("hosts"), hosts_content)
403+
)?;
404404

405405
Ok(())
406406
}

0 commit comments

Comments
 (0)