Skip to content

Commit

Permalink
Comment out child process spawning logic in main.rs and key shuffling…
Browse files Browse the repository at this point in the history
… in database.rs
  • Loading branch information
nullchinchilla committed Jan 4, 2025
1 parent e310615 commit 92ee983
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
54 changes: 27 additions & 27 deletions binaries/geph5-bridge/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,33 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilte
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

fn main() {
smolscale::permanently_single_threaded();
if std::env::var("GEPH5_BRIDGE_CHILD").is_err() {
for _ in 0..available_parallelism().unwrap().get() {
std::thread::spawn(|| {
std::env::set_var("GEPH5_BRIDGE_CHILD", "1");
let current_exe = std::env::current_exe().unwrap();

// Collect the current command-line arguments
let args: Vec<String> = std::env::args().collect();

// Trim the first argument which is the current binary's path
let args_to_pass = &args[1..];

// Spawn a new process with the same command
let mut child = std::process::Command::new(current_exe)
.args(args_to_pass)
.spawn()
.unwrap();

// Wait for the spawned process to finish
child.wait().unwrap();
});
}
loop {
std::thread::park();
}
}
// smolscale::permanently_single_threaded();
// if std::env::var("GEPH5_BRIDGE_CHILD").is_err() {
// for _ in 0..available_parallelism().unwrap().get() {
// std::thread::spawn(|| {
// std::env::set_var("GEPH5_BRIDGE_CHILD", "1");
// let current_exe = std::env::current_exe().unwrap();

// // Collect the current command-line arguments
// let args: Vec<String> = std::env::args().collect();

// // Trim the first argument which is the current binary's path
// let args_to_pass = &args[1..];

// // Spawn a new process with the same command
// let mut child = std::process::Command::new(current_exe)
// .args(args_to_pass)
// .spawn()
// .unwrap();

// // Wait for the spawned process to finish
// child.wait().unwrap();
// });
// }
// loop {
// std::thread::park();
// }
// }

tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer().compact())
Expand Down
12 changes: 6 additions & 6 deletions binaries/geph5-broker/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ pub async fn query_bridges(key: &str) -> anyhow::Result<Vec<(BridgeDescriptor, u
.build()
});

// shuffle
let key = format!(
"{key}-{}",
SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() / 3600
);
// // shuffle
// let key = format!(
// "{key}-{}",
// SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() / 3600
// );

CACHE
.try_get_with(key.clone(), async {
.try_get_with(key.to_string(), async {
let raw: Vec<(String, String, String, i64, i32, bool)> = sqlx::query_as(
r"
WITH selected_bridges AS (
Expand Down

0 comments on commit 92ee983

Please sign in to comment.