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

Delete getTrafficStatistics() from IScheduler, implementations, and benchmarks #456

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions fbpcf/engine/test/benchmarks/SecretShareEngineBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ class BaseSecretShareEngineBenchmark : public util::NetworkedBenchmark {
runMethod(receiver_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}

virtual void runMethod(std::unique_ptr<ISecretShareEngine>& engine) = 0;

size_t batchSize_ = 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ class SinglePointCotBenchmark final : public util::NetworkedBenchmark {
receiver_->receiverExtend(std::move(baseOTReceive_));
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return agent0_->getTrafficStatistics();
}

private:
std::unique_ptr<communication::IPartyCommunicationAgent> agent0_;
std::unique_ptr<communication::IPartyCommunicationAgent> agent1_;
Expand Down Expand Up @@ -136,10 +132,6 @@ class RegularErrorMultiPointCotBenchmark final
receiver_->receiverExtend(std::move(baseOTReceive_));
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return agent0_->getTrafficStatistics();
}

private:
std::unique_ptr<RegularErrorMultiPointCotFactory> factory_;

Expand Down Expand Up @@ -194,10 +186,6 @@ class RcotExtenderBenchmark final : public util::NetworkedBenchmark {
receiver_->receiverExtendRcot(std::move(baseOTReceive_));
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}

private:
std::unique_ptr<communication::IPartyCommunicationAgent> agent0_;
std::unique_ptr<communication::IPartyCommunicationAgent> agent1_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ class NpBaseObliviousTransferBenchmark : public util::NetworkedBenchmark {
receiver_->receive(choice_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}

private:
size_t size_ = 1024;

Expand Down Expand Up @@ -110,10 +106,6 @@ class RandomCorrelatedObliviousTransferBenchmark
receiver_->rcot(size_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}

std::unique_ptr<IRandomCorrelatedObliviousTransferFactory> factory_;

private:
Expand Down Expand Up @@ -249,10 +241,6 @@ class BidirectionObliviousTransferBenchmark : public util::NetworkedBenchmark {
receiver_->biDirectionOT(receiverInput0_, receiverInput1_, receiverChoice_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}

virtual std::unique_ptr<IRandomCorrelatedObliviousTransferFactory>
getRcotFactory() = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ class ProductShareGeneratorBenchmark : public util::NetworkedBenchmark {
receiver_->generateBooleanProductShares(receiverLeft_, receiverRight_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}

private:
size_t size_ = 10000000;

Expand Down Expand Up @@ -125,10 +121,6 @@ class BaseTupleGeneratorBenchmark : public util::NetworkedBenchmark {
receiver_->getBooleanTuple(size_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}

virtual std::unique_ptr<ITupleGeneratorFactory> getTupleGeneratorFactory(
int myId,
communication::IPartyCommunicationAgentFactory& agentFactory) = 0;
Expand Down
11 changes: 0 additions & 11 deletions fbpcf/engine/util/test/benchmarks/NetworkedBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,13 @@ class NetworkedBenchmark {
counters["init_time_usec"] =
std::chrono::duration_cast<std::chrono::microseconds>(end - start)
.count();

auto [sent, received] = getTrafficStatistics();
initTransmittedBytes = sent + received;
counters["init_transmitted_bytes"] = initTransmittedBytes;
}

auto senderTask = std::async([this]() { runSender(); });
auto receiverTask = std::async([this]() { runReceiver(); });

senderTask.get();
receiverTask.get();

BENCHMARK_SUSPEND {
auto [sent, received] = getTrafficStatistics();
counters["transmitted_bytes"] = sent + received - initTransmittedBytes;
}
}

protected:
Expand All @@ -65,8 +56,6 @@ class NetworkedBenchmark {

virtual void runSender() = 0;
virtual void runReceiver() = 0;

virtual std::pair<uint64_t, uint64_t> getTrafficStatistics() = 0;
};

} // namespace fbpcf::engine::util
4 changes: 0 additions & 4 deletions fbpcf/frontend/test/benchmarks/FrontendBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ class FrontendBenchmark : public engine::util::NetworkedBenchmark {
receiver_->play();
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}

private:
std::unique_ptr<engine::communication::IPartyCommunicationAgentFactory>
agentFactory0_;
Expand Down
4 changes: 0 additions & 4 deletions fbpcf/frontend/test/schedulerMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,6 @@ class schedulerMock final : public scheduler::IScheduler {

MOCK_METHOD0(deleteEngine, void());

std::pair<uint64_t, uint64_t> getTrafficStatistics() const override {
return {0, 0};
}

std::pair<uint64_t, uint64_t> getWireStatistics() const override {
return {0, 0};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ class ShuffleBasedCompactorBenchmark : public engine::util::NetworkedBenchmark {
util::MpcAdapters<uint32_t, 1>::openToParty(compactifiedValue, 0);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
auto schedulerTraffic =
scheduler::SchedulerKeeper<0>::getTrafficStatistics();
return schedulerTraffic;
}

std::unique_ptr<engine::communication::IPartyCommunicationAgentFactory>
agentFactory0_;
std::unique_ptr<engine::communication::IPartyCommunicationAgentFactory>
Expand Down
21 changes: 0 additions & 21 deletions fbpcf/mpc_std_lib/oram/test/benchmarks/OramBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ class DifferenceCalculatorBenchmark : public engine::util::NetworkedBenchmark {
input1_.subtrahendShares);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return scheduler::SchedulerKeeper<0>::getTrafficStatistics();
}

private:
size_t batchSize_ = 16384;

Expand Down Expand Up @@ -140,10 +136,6 @@ class ObliviousDeltaCalculatorBenchmark
input1_.delta0Shares, input1_.delta1Shares, input1_.alphaShares);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return scheduler::SchedulerKeeper<0>::getTrafficStatistics();
}

private:
size_t batchSize_ = 16384;

Expand Down Expand Up @@ -219,10 +211,6 @@ class SinglePointArrayGeneratorBenchmark
receiver_->generateSinglePointArrays(party1Input_, length_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return scheduler::SchedulerKeeper<0>::getTrafficStatistics();
}

private:
size_t length_ = 16384;

Expand Down Expand Up @@ -283,15 +271,6 @@ class BaseWriteOnlyOramBenchmark : public engine::util::NetworkedBenchmark {
runMethod(receiver_, input1_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
auto schedulerTraffic =
scheduler::SchedulerKeeper<0>::getTrafficStatistics();
auto oramTraffic = sender_->getTrafficStatistics();
return {
schedulerTraffic.first + oramTraffic.first,
schedulerTraffic.second + oramTraffic.second};
}

virtual std::unique_ptr<IWriteOnlyOramFactory<uint32_t>> getOramFactory(
bool amIParty0) = 0;

Expand Down
23 changes: 0 additions & 23 deletions fbpcf/mpc_std_lib/walr_multiplication/IWalrMatrixMultiplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,7 @@ class IWalrMatrixMultiplication {
std::vector<double> matrixVectorMultiplication(
const std::vector<std::vector<double>>& features,
const frontend::Bit<true, schedulerId, true>& labels) {
// Initialize engine traffic recording
auto initEngineTraffic =
scheduler::SchedulerKeeper<schedulerId>::getTrafficStatistics();

auto rst = matrixVectorMultiplicationImpl(features, labels);

// Calculate engine traffic
auto finalEngineTraffic =
scheduler::SchedulerKeeper<schedulerId>::getTrafficStatistics();
engineTraffic_.first += finalEngineTraffic.first - initEngineTraffic.first;
engineTraffic_.second +=
finalEngineTraffic.second - initEngineTraffic.second;

return rst;
}

Expand All @@ -85,18 +73,7 @@ class IWalrMatrixMultiplication {
void matrixVectorMultiplication(
const frontend::Bit<true, schedulerId, true>& labels,
const std::vector<double>& dpNoise) {
// Initialize engine traffic recording
auto initEngineTraffic =
scheduler::SchedulerKeeper<schedulerId>::getTrafficStatistics();

matrixVectorMultiplicationImpl(labels, dpNoise);

// Calculate engine traffic
auto finalEngineTraffic =
scheduler::SchedulerKeeper<schedulerId>::getTrafficStatistics();
engineTraffic_.first += finalEngineTraffic.first - initEngineTraffic.first;
engineTraffic_.second +=
finalEngineTraffic.second - initEngineTraffic.second;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ class WalrMatrixMultiplicationBenchmark
labelOwner_->matrixVectorMultiplication(secLabel1, dpNoise_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return featureOwner_->getTrafficStatistics();
}

std::unique_ptr<engine::communication::IPartyCommunicationAgentFactory>
agentFactory0_;
std::unique_ptr<engine::communication::IPartyCommunicationAgentFactory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ class COTWithRandomMessageBenchmark : public engine::util::NetworkedBenchmark {
receiver_->receive(choice_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}

virtual std::unique_ptr<engine::tuple_generator::oblivious_transfer::
IRandomCorrelatedObliviousTransferFactory>
getRcotFactory() = 0;
Expand Down
8 changes: 0 additions & 8 deletions fbpcf/scheduler/EagerScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,14 +664,6 @@ std::vector<IScheduler::WireId<IScheduler::Boolean>> EagerScheduler::unbatching(
return rst;
}

std::pair<uint64_t, uint64_t> EagerScheduler::getTrafficStatistics() const {
if (engine_) {
return engine_->getTrafficStatistics();
} else {
return engineTrafficStatisticsBuffer_;
}
}

size_t EagerScheduler::getBatchSize(
IScheduler::WireId<IScheduler::Boolean> id) const {
return wireKeeper_->getBatchSize(id);
Expand Down
5 changes: 0 additions & 5 deletions fbpcf/scheduler/EagerScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,6 @@ class EagerScheduler final : public IArithmeticScheduler {

//======== Below are miscellaneous APIs: ========

/**
* @inherit doc
*/
std::pair<uint64_t, uint64_t> getTrafficStatistics() const override;

/**
* @inherit doc
*/
Expand Down
7 changes: 1 addition & 6 deletions fbpcf/scheduler/IScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,6 @@ class IScheduler {
std::shared_ptr<std::vector<uint32_t>> unbatchingStrategy) = 0;

//======== Below are miscellaneous APIs: ========
/**
* Get the total amount of traffic transmitted.
* @return a pair of (sent, received) data in bytes.
*/
virtual std::pair<uint64_t, uint64_t> getTrafficStatistics() const = 0;

/**
* Get amount of boolean gates executed. non-free gate count is the single
Expand Down Expand Up @@ -439,7 +434,7 @@ class SchedulerKeeper {
}

static std::pair<uint64_t, uint64_t> getTrafficStatistics() {
return scheduler_->getTrafficStatistics();
return {0, 0};
}

static std::pair<uint64_t, uint64_t> getGateStatistics() {
Expand Down
8 changes: 0 additions & 8 deletions fbpcf/scheduler/LazyScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,6 @@ void LazyScheduler::decreaseReferenceCountBatch(
wireKeeper_->decreaseBatchReferenceCount(id);
}

std::pair<uint64_t, uint64_t> LazyScheduler::getTrafficStatistics() const {
if (engine_) {
return engine_->getTrafficStatistics();
} else {
return engineTrafficStatisticsBuffer_;
}
}

// band a number of batches into one batch.
IScheduler::WireId<IScheduler::Boolean> LazyScheduler::batchingUp(
std::vector<WireId<Boolean>> src) {
Expand Down
5 changes: 0 additions & 5 deletions fbpcf/scheduler/LazyScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,6 @@ class LazyScheduler final : public IArithmeticScheduler {

//======== Below are miscellaneous APIs: ========

/**
* @inherit doc
*/
std::pair<uint64_t, uint64_t> getTrafficStatistics() const override;

/**
* @inherit doc
*/
Expand Down
14 changes: 0 additions & 14 deletions fbpcf/scheduler/NetworkPlaintextScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,6 @@ class NetworkPlaintextScheduler final : public PlaintextScheduler {

//======== Below are miscellaneous APIs: ========

/**
* @inherit doc
*/
std::pair<uint64_t, uint64_t> getTrafficStatistics() const override {
uint64_t sent = 0;
uint64_t received = 0;
for (auto& item : agentMap_) {
auto traffic = item.second->getTrafficStatistics();
sent += traffic.first;
received += traffic.second;
}
return {sent, received};
}

/**
* @inherit doc
*/
Expand Down
7 changes: 0 additions & 7 deletions fbpcf/scheduler/PlaintextScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,13 +508,6 @@ class PlaintextScheduler : public IArithmeticScheduler {

//======== Below are miscellaneous APIs: ========

/**
* @inherit doc
*/
std::pair<uint64_t, uint64_t> getTrafficStatistics() const override {
return {0, 0};
}

/**
* @inherit doc
*/
Expand Down
4 changes: 0 additions & 4 deletions fbpcf/scheduler/test/benchmarks/SchedulerBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ class SchedulerBenchmark : public engine::util::NetworkedBenchmark {
runMethod(receiver_);
}

std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}

virtual std::unique_ptr<IScheduler> getScheduler(
int myId,
engine::communication::IPartyCommunicationAgentFactory&
Expand Down