-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
651 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,9 @@ | |
### Features | ||
|
||
- Added KKRT oblivious transfer. | ||
|
||
## Version 0.3.0 | ||
|
||
### Features | ||
|
||
- Added benchmark for Verse. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Copyright 2023 TikTok Pte. Ltd. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
cmake_minimum_required(VERSION 3.14) | ||
|
||
project(VERSEBench VERSION 0.3.0 LANGUAGES CXX) | ||
|
||
# If not called from root CMakeLists.txt | ||
if(NOT DEFINED VERSE_BUILD_BENCH) | ||
set(VERSE_BUILD_BENCH ON) | ||
|
||
find_package(PETAce-Verse 0.3.0 EXACT REQUIRED) | ||
|
||
add_compile_options(-msse4.2 -Wno-ignored-attributes -mavx) | ||
|
||
# Must define these variables and include macros | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) | ||
set(VERSE_THIRDPARTY_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty) | ||
set(THIRDPARTY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty) | ||
include(FetchContent) | ||
mark_as_advanced(FETCHCONTENT_BASE_DIR) | ||
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED) | ||
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED) | ||
mark_as_advanced(FETCHCONTENT_QUIET) | ||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake) | ||
include(VerseCustomMacros) | ||
else() | ||
set(THIRDPARTY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../thirdparty) | ||
endif() | ||
|
||
if(NOT DEFINED VERSE_BUILD_DEPS) | ||
# [option] VERSE_BUILD_DEPS (default: ON) | ||
# Download and build missing dependencies, throw error if disabled. | ||
set(VERSE_BUILD_DEPS_OPTION_STR "Automatically download and build unmet dependencies") | ||
option(VERSE_BUILD_DEPS ${VERSE_BUILD_DEPS_OPTION_STR} ON) | ||
endif() | ||
|
||
# if VERSE_BUILD_BENCH is ON, use GoogleBenchmark | ||
if(VERSE_BUILD_BENCH) | ||
|
||
if(VERSE_BUILD_DEPS) | ||
# tclap | ||
message(STATUS "Tclap: download ...") | ||
verse_fetch_thirdparty_content(ExternalTclap) | ||
else() | ||
message(FATAL_ERROR "Tclap: not found, please download and install manually") | ||
endif() | ||
|
||
# glog::glog | ||
if(NOT TARGET glog::glog) | ||
find_package(glog 0.4.0 QUIET CONFIG) | ||
if(glog_FOUND) | ||
message(STATUS "glog: found") | ||
else() | ||
if(VERSE_BUILD_DEPS) | ||
message(STATUS "glog: download ...") | ||
verse_fetch_thirdparty_content(ExternalGlog) | ||
else() | ||
message(FATAL_ERROR "glog: not found, please download and install manually") | ||
endif() | ||
endif() | ||
endif() | ||
|
||
# Add source files to bench | ||
set(VERSE_BENCH_FILES | ||
${CMAKE_CURRENT_LIST_DIR}/bench.cpp | ||
${CMAKE_CURRENT_LIST_DIR}/verse_bench.cpp | ||
) | ||
|
||
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl -lrt") | ||
add_executable(verse_bench ${VERSE_BENCH_FILES}) | ||
|
||
target_include_directories(verse_bench PRIVATE ${CMAKE_BINARY_DIR}/thirdparty/tclap-src/include) | ||
|
||
if(TARGET PETAce-Verse::verse) | ||
target_link_libraries(verse_bench PRIVATE PETAce-Verse::verse glog::glog) | ||
elseif(TARGET PETAce-Verse::verse_shared) | ||
target_link_libraries(verse_bench PRIVATE PETAce-Verse::verse_shared glog::glog) | ||
else() | ||
message(FATAL_ERROR "Cannot find target PETAce::verse or PETAce::verse_shared") | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# PETAce-Verse Benchmark | ||
|
||
We have prepared a series of performance tests for PETAce-Verse. | ||
|
||
## How to run the benchmark | ||
|
||
The benchmark codes of all test cases are available in `verse_bench.cpp`. | ||
You should set the option `VERSE_BUILD_BENCH` to be on when building Verse, and the binary file `verse_bench` will be found in `/build/bin`. | ||
To run the benchmark cases, open two terminal sessions and run the following command in the first terminal: | ||
|
||
```bash | ||
./build/bin/verse_bench -p 0 --log_path ./verse0.log | ||
``` | ||
This terminal will act as party 0 and execute the benchmark program. | ||
Similarly, run the following command in the second terminal. | ||
|
||
```bash | ||
./build/bin/verse_bench -p 1 --log_path ./verse1.log | ||
``` | ||
|
||
Then, you can find logs files in the `/build` directory, named `verse0.log` and `verse1.log`, which represent the performance metrics of Party 0 and Party 1, respectively. | ||
|
||
## Logging Format | ||
Logging information follows a specific format as follows: | ||
|
||
```bash | ||
case <case name> begin <timestamp> <test_iteration> <parameter> | ||
case <case name> end <timestamp> <cost time> <bytes_send> <bytes_received> | ||
``` | ||
```bash | ||
case <case name> begin <timestamp> <test_iteration> <parameter> | ||
stage <stage name> begin <timestamp> | ||
stage <stage name> end <timestamp> <cost time> <bytes_send> <bytes_received> | ||
case <case name> end <timestamp> <cost time> <bytes_send> <bytes_received> | ||
``` | ||
`case * begin` and `case * end` indicates the start and end of the test case, respectively. A test case may include multiple stages. For example, when calculating the dot product, one must first compute the element-wise multiplication of two vectors, followed by the summation of these products. We denote the start and end of a stage with the labels `stage begin` and `stage end`. | ||
The meanings of other fields are as follows: | ||
- `case name`: the name of the test case | ||
- `timestamp`: the timestamp of the start or end of the test case or stage | ||
- `test_iteration`: the number of the test case executions | ||
- `parameter`: the parameters of the test case | ||
- `stage name`: the name of the stage | ||
- `cost time`: the time cost of the test case or stage | ||
- `bytes_send`: the number of bytes sent | ||
- `bytes_received`: the number of bytes received | ||
## Benchmark with Various Network Conditions | ||
For MPC (Multi-Party Computation), network overhead is a critical metric. We offer a straightforward method to simulate various network conditions. | ||
The following command can be used to simulate a network with a given latency and bandwidth. | ||
```bash | ||
tc qdisc add dev lo root netem delay {latency}ms rate {bandwidth}mbit | ||
``` | ||
For example, to simulate a network with 10ms latency and 100Mbps bandwidth, run the following command. | ||
```bash | ||
tc qdisc add dev lo root netem delay 10ms rate 100mbit | ||
``` | ||
To remove this limitation, you can use the following command: | ||
```bash | ||
tc qdisc del dev lo root | ||
``` |
Oops, something went wrong.