Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass batch size as arg #517

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions iris-mpc-upgrade/src/bin/seed_v1_dbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ struct Args {
#[clap(long)]
side: String,

#[clap(long)]
batch_size: usize,

#[clap(long, value_delimiter = ',', num_args = 1..)]
deleted_identities: Option<Vec<i32>>,
}

const SEED_BATCH_SIZE: usize = 10;

async fn insert_masks(pool: sqlx::Pool<Postgres>, masks: &[(u64, Bits)]) -> Result<()> {
let mut builder = QueryBuilder::new("INSERT INTO masks (id, mask) VALUES ");

Expand Down Expand Up @@ -118,6 +119,8 @@ async fn main() -> eyre::Result<()> {
return Err(eyre::eyre!("Expect side to be either 'left' or 'right'"));
}

let batch_size = args.batch_size;

let participant_one_shares_db_name = format!("participant1_{}", args.side);
let participant_two_shares_db_name = format!("participant2_{}", args.side);
let participant_one_masks_db_name = format!("coordinator_{}", args.side);
Expand Down Expand Up @@ -202,17 +205,17 @@ async fn main() -> eyre::Result<()> {
masks.push((i, iris_code.mask));
}

if shares0.len() == SEED_BATCH_SIZE {
if shares0.len() == batch_size {
println!("Inserting {} shares", shares0.len());
insert_shares(shares_1_pool.clone(), &shares0).await?;
shares0.clear();
}
if shares1.len() == SEED_BATCH_SIZE {
if shares1.len() == batch_size {
println!("Inserting {} shares", shares1.len());
insert_shares(shares_2_pool.clone(), &shares1).await?;
shares1.clear();
}
if masks.len() == SEED_BATCH_SIZE {
if masks.len() == batch_size {
println!("Inserting {} masks", masks.len());
insert_masks(masks_pool.clone(), &masks).await?;
masks.clear();
Expand Down
Loading