Skip to content

Commit

Permalink
Add benchmark for schedulers (#164)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #164

Looking for some feedback on this approach.

The scheduler API has 40 methods, and trying to test each one individually would be overkill I think. Plus, the implementation for a lot of the gates is very similar.

I figured the best thing to do would be to just create a bunch of dependent gates, that way we can test that the lazy scheduler properly batches things together more efficiently than the eager scheduler.

If anyone has suggestions for more thorough things to test, LMK.

Reviewed By: RuiyuZhu

Differential Revision: D35162133

fbshipit-source-id: 3d2cdfa5b01a2cd2a321c471eacc0377a8650ba4
  • Loading branch information
Elliott Lawrence authored and facebook-github-bot committed Mar 30, 2022
1 parent 192d4b9 commit c7711fd
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions fbpcf/scheduler/test/benchmarks/SchedulerBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,76 @@ class EagerSchedulerBenchmark : virtual public SchedulerBenchmark {
myId, communicationAgentFactory);
}
};

class NonFreeGatesBenchmark : virtual public SchedulerBenchmark {
protected:
void runMethod(std::unique_ptr<IScheduler>& scheduler) override {
auto wire1 = scheduler->privateBooleanInput(input0_, randomParty_);
auto wire2 = scheduler->privateBooleanInput(input1_, 1 - randomParty_);
IScheduler::WireId<IScheduler::Boolean> wire3;
for (auto level = 0; level < 10; level++) {
for (auto i = 0; i < 200; i++) {
wire3 = scheduler->privateAndPrivate(wire1, wire2);
}
wire2 = wire3;
}
scheduler->getBooleanValue(
scheduler->openBooleanValueToParty(wire3, randomParty_));
}
};

class NonFreeGatesBatchBenchmark : virtual public SchedulerBenchmark {
protected:
void runMethod(std::unique_ptr<IScheduler>& scheduler) override {
auto wire1 =
scheduler->privateBooleanInputBatch(batchInput0_, randomParty_);
auto wire2 =
scheduler->privateBooleanInputBatch(batchInput1_, 1 - randomParty_);
IScheduler::WireId<IScheduler::Boolean> wire3;
for (auto level = 0; level < 10; level++) {
for (auto i = 0; i < 200; i++) {
wire3 = scheduler->privateAndPrivateBatch(wire1, wire2);
}
wire2 = wire3;
}
scheduler->getBooleanValueBatch(
scheduler->openBooleanValueToPartyBatch(wire3, randomParty_));
}
};

class LazyScheduler_NonFreeGates_Benchmark : public LazySchedulerBenchmark,
public NonFreeGatesBenchmark {};

BENCHMARK_COUNTERS(LazyScheduler_NonFreeGates, counters) {
LazyScheduler_NonFreeGates_Benchmark benchmark;
benchmark.runBenchmark(counters);
}

class EagerScheduler_NonFreeGates_Benchmark : public EagerSchedulerBenchmark,
public NonFreeGatesBenchmark {};

BENCHMARK_COUNTERS(EagerScheduler_NonFreeGates, counters) {
EagerScheduler_NonFreeGates_Benchmark benchmark;
benchmark.runBenchmark(counters);
}

class LazyScheduler_NonFreeGatesBatch_Benchmark
: public LazySchedulerBenchmark,
public NonFreeGatesBatchBenchmark {};

BENCHMARK_COUNTERS(LazyScheduler_NonFreeGatesBatch, counters) {
LazyScheduler_NonFreeGatesBatch_Benchmark benchmark;
benchmark.runBenchmark(counters);
}

class EagerScheduler_NonFreeGatesBatch_Benchmark
: public EagerSchedulerBenchmark,
public NonFreeGatesBatchBenchmark {};

BENCHMARK_COUNTERS(EagerScheduler_NonFreeGatesBatch, counters) {
EagerScheduler_NonFreeGatesBatch_Benchmark benchmark;
benchmark.runBenchmark(counters);
}
} // namespace fbpcf::scheduler

int main(int argc, char* argv[]) {
Expand Down

0 comments on commit c7711fd

Please sign in to comment.