From 7168ba5710e2bb9210629b3f8e34f7d643686bb7 Mon Sep 17 00:00:00 2001 From: sinu <65924192+sinui0@users.noreply.github.com> Date: Thu, 19 Oct 2023 08:48:36 -0700 Subject: [PATCH] remove batching from evaluator --- garble/mpz-garble/src/evaluator/config.rs | 3 --- garble/mpz-garble/src/evaluator/mod.rs | 28 ++++++++--------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/garble/mpz-garble/src/evaluator/config.rs b/garble/mpz-garble/src/evaluator/config.rs index f84161ef..b0fdfd43 100644 --- a/garble/mpz-garble/src/evaluator/config.rs +++ b/garble/mpz-garble/src/evaluator/config.rs @@ -12,9 +12,6 @@ pub struct EvaluatorConfig { /// Whether to log decodings. #[builder(default = "false", setter(custom))] pub(crate) log_decodings: bool, - /// The number of encrypted gates to evaluate per batch. - #[builder(default = "1024")] - pub(crate) batch_size: usize, } impl EvaluatorConfig { diff --git a/garble/mpz-garble/src/evaluator/mod.rs b/garble/mpz-garble/src/evaluator/mod.rs index 30aa67ce..0d5fc102 100644 --- a/garble/mpz-garble/src/evaluator/mod.rs +++ b/garble/mpz-garble/src/evaluator/mod.rs @@ -372,15 +372,11 @@ impl Evaluator { let encoded_outputs = if let Some(GarbledCircuit { gates, commitments }) = existing_garbled_circuit { - for batch in gates.chunks(self.config.batch_size) { - let batch = batch.to_vec(); - // Move the evaluator to a new thread to process the batch then send it back - ev = Backend::spawn(move || { - ev.evaluate(batch.iter()); - ev - }) - .await; - } + ev = Backend::spawn(move || { + ev.evaluate(gates.iter()); + ev + }) + .await; let encoded_outputs = ev.outputs()?; if self.config.encoding_commitments { @@ -396,15 +392,11 @@ impl Evaluator { } else { while !ev.is_complete() { let gates = expect_msg_or_err!(stream, GarbleMessage::EncryptedGates)?; - for batch in gates.chunks(self.config.batch_size) { - let batch = batch.to_vec(); - // Move the evaluator to a new thread to process the batch then send it back - ev = Backend::spawn(move || { - ev.evaluate(batch.iter()); - ev - }) - .await; - } + ev = Backend::spawn(move || { + ev.evaluate(gates.iter()); + ev + }) + .await; } let encoded_outputs = ev.outputs()?;