Skip to content

Commit

Permalink
remove batching from evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
sinui0 committed Oct 19, 2023
1 parent f8b4850 commit 7168ba5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
3 changes: 0 additions & 3 deletions garble/mpz-garble/src/evaluator/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
28 changes: 10 additions & 18 deletions garble/mpz-garble/src/evaluator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()?;
Expand Down

0 comments on commit 7168ba5

Please sign in to comment.