Skip to content

Commit

Permalink
Merge branch 'main' into cli-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm authored Oct 2, 2023
2 parents db71667 + 59c7d08 commit 5e463ba
Show file tree
Hide file tree
Showing 14 changed files with 582 additions and 89 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI
on: [push]
jobs:
CI:
runs-on: ubuntu-22.04 # latest at time of writing
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: '3.9' # default version on Amazon Linux 2023

- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17' # default version on Amazon Linux 2023

- run: python -m pip install -r scripts/requirements.txt

- name: Lint Python scripts
run: python scripts/lint-python.py

- name: Lint s3-benchrunner-c
run: python runners/s3-benchrunner-c/scripts/lint.py

- name: Lint s3-benchrunner-crt-java
run: python runners/s3-benchrunner-crt-java/scripts/lint.py

- name: Check that benchmark.run.json files are up to date
# build benchmarks and see if any files change
run: |
python scripts/build-benchmarks.py
git diff --exit-code
- name: Build s3-benchrunner-c
run: python runners/s3-benchrunner-c/scripts/build.py --build-dir ${{runner.temp}}/build/c

- name: Build s3-benchrunner-crt-java
run: python runners/s3-benchrunner-crt-java/scripts/build.py --build-dir ${{runner.temp}}/build/crt-java
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -1090,3 +1090,6 @@ FodyWeavers.xsd
# Additional files built by Visual Studio

# End of https://www.toptal.com/developers/gitignore/api/c++,python,node,java,visualstudiocode,intellij,pycharm,clion,macos,windows,visualstudio

# temporary file created by maven-shade-plugin
dependency-reduced-pom.xml
60 changes: 60 additions & 0 deletions runners/s3-benchrunner-c/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
Language: Cpp
# BasedOnStyle: Mozilla
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
ColumnLimit: 120
ContinuationIndentWidth: 4
DerivePointerAlignment: false
FixNamespaceComments : true
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 100000
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

76 changes: 41 additions & 35 deletions runners/s3-benchrunner-c/benchrunner.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <chrono>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <functional>
#include <future>
#include <iostream>
#include <list>
#include <random>
#include <thread>
Expand All @@ -14,9 +14,9 @@
#include <aws/io/channel_bootstrap.h>
#include <aws/io/event_loop.h>
#include <aws/io/host_resolver.h>
#include <aws/s3/s3_client.h>
#include <aws/io/stream.h>
#include <aws/io/tls_channel_handler.h>
#include <aws/s3/s3_client.h>
#include <nlohmann/json.hpp>

using namespace std;
Expand Down Expand Up @@ -132,16 +132,18 @@ class Task

FILE *downloadFile = NULL;

static int onDownloadData(struct aws_s3_meta_request *meta_request,
const struct aws_byte_cursor *body,
uint64_t range_start,
void *user_data);
static int onDownloadData(
struct aws_s3_meta_request *meta_request,
const struct aws_byte_cursor *body,
uint64_t range_start,
void *user_data);

static void onFinished(struct aws_s3_meta_request *meta_request,
const struct aws_s3_meta_request_result *meta_request_result,
void *user_data);
static void onFinished(
struct aws_s3_meta_request *meta_request,
const struct aws_s3_meta_request_result *meta_request_result,
void *user_data);

public:
public:
// Creates the task and begins its work
Task(Benchmark &benchmark, size_t taskI);

Expand Down Expand Up @@ -169,7 +171,7 @@ class Benchmark
// if uploading, and filesOnDisk is false, then upload this
vector<uint8_t> randomDataForUpload;

public:
public:
// Instantiates S3 Client, does not run the benchmark yet
Benchmark(const BenchmarkConfig &config, string_view bucket, string_view region, double targetThroughputGbps);

Expand Down Expand Up @@ -374,10 +376,7 @@ void addHeader(aws_http_message *request, string_view name, string_view value)
}

Task::Task(Benchmark &benchmark, size_t taskI)
: benchmark(benchmark),
taskI(taskI),
config(benchmark.config.tasks[taskI]),
donePromise(),
: benchmark(benchmark), taskI(taskI), config(benchmark.config.tasks[taskI]), donePromise(),
doneFuture(donePromise.get_future())
{

Expand Down Expand Up @@ -406,8 +405,8 @@ Task::Task(Benchmark &benchmark, size_t taskI)
else
{
// set up input-stream that uploads random data from a buffer
auto randomDataCursor = aws_byte_cursor_from_array(
benchmark.randomDataForUpload.data(), benchmark.randomDataForUpload.size());
auto randomDataCursor =
aws_byte_cursor_from_array(benchmark.randomDataForUpload.data(), benchmark.randomDataForUpload.size());
auto inMemoryStreamForUpload = aws_input_stream_new_from_cursor(benchmark.alloc, &randomDataCursor);
aws_http_message_set_body_stream(request, inMemoryStreamForUpload);
aws_input_stream_release(inMemoryStreamForUpload);
Expand Down Expand Up @@ -447,17 +446,21 @@ Task::Task(Benchmark &benchmark, size_t taskI)
aws_http_message_release(request);
}

void Task::onFinished(struct aws_s3_meta_request *meta_request,
const struct aws_s3_meta_request_result *meta_request_result,
void *user_data)
void Task::onFinished(
struct aws_s3_meta_request *meta_request,
const struct aws_s3_meta_request_result *meta_request_result,
void *user_data)
{
Task *task = static_cast<Task *>(user_data);
// TODO: report failed meta-requests instead of killing benchmark?
if (meta_request_result->error_code != 0)
{
printf("Task[%zu] failed. action:%s key:%s error_code:%s\n",
task->taskI, task->config.action.c_str(), task->config.key.c_str(),
aws_error_name(meta_request_result->error_code));
printf(
"Task[%zu] failed. action:%s key:%s error_code:%s\n",
task->taskI,
task->config.action.c_str(),
task->config.key.c_str(),
aws_error_name(meta_request_result->error_code));
if (meta_request_result->response_status != 0)
printf("Status-Code: %d\n", meta_request_result->response_status);

Expand All @@ -468,7 +471,8 @@ void Task::onFinished(struct aws_s3_meta_request *meta_request,
{
aws_http_header headerI;
aws_http_headers_get_index(headers, i, &headerI);
printf(PRInSTR ": " PRInSTR "\n", AWS_BYTE_CURSOR_PRI(headerI.name), AWS_BYTE_CURSOR_PRI(headerI.value));
printf(
PRInSTR ": " PRInSTR "\n", AWS_BYTE_CURSOR_PRI(headerI.name), AWS_BYTE_CURSOR_PRI(headerI.value));
}
}

Expand All @@ -486,10 +490,11 @@ void Task::onFinished(struct aws_s3_meta_request *meta_request,
task->donePromise.set_value();
}

int Task::onDownloadData(struct aws_s3_meta_request *meta_request,
const struct aws_byte_cursor *body,
uint64_t range_start,
void *user_data)
int Task::onDownloadData(
struct aws_s3_meta_request *meta_request,
const struct aws_byte_cursor *body,
uint64_t range_start,
void *user_data)
{
auto *task = static_cast<Task *>(user_data);

Expand Down Expand Up @@ -525,13 +530,14 @@ int main(int argc, char *argv[])

duration<double> runDurationSecs = high_resolution_clock::now() - runStart;
double runSecs = runDurationSecs.count();
printf("Run:%d Secs:%.3f Gb/s:%.1f Mb/s:%.1f GiB/s:%.1f MiB/s:%.1f\n",
runI + 1,
runSecs,
bytesToGigabit(bytesPerRun) / runSecs,
bytesToMegabit(bytesPerRun) / runSecs,
bytesToGiB(bytesPerRun) / runSecs,
bytesToMiB(bytesPerRun) / runSecs);
printf(
"Run:%d Secs:%.3f Gb/s:%.1f Mb/s:%.1f GiB/s:%.1f MiB/s:%.1f\n",
runI + 1,
runSecs,
bytesToGigabit(bytesPerRun) / runSecs,
bytesToMegabit(bytesPerRun) / runSecs,
bytesToGiB(bytesPerRun) / runSecs,
bytesToMiB(bytesPerRun) / runSecs);

// break out if we've exceeded maxRepeatSecs
duration<double> appDurationSecs = high_resolution_clock::now() - appStart;
Expand Down
26 changes: 26 additions & 0 deletions runners/s3-benchrunner-c/scripts/lint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
import argparse
import os
from pathlib import Path

PARSER = argparse.ArgumentParser(description="Check formatting")

if __name__ == '__main__':
args = PARSER.parse_args()

runner_dir = Path(__file__).parent.parent
files: list[str] = []
for pattern in ['*.cpp', '*.c', '*.h']:
for i in runner_dir.glob(pattern):
files.append(str(i))

failed = False
for file in files:
# using shell commands because it's way shorter than proper python
if os.system(f'clang-format {file} | diff -u {file} -') != 0:
failed = True

if failed:
# display clang format version
os.system('clang-format --version')
exit('FAILED')
47 changes: 0 additions & 47 deletions runners/s3-benchrunner-crt-java/dependency-reduced-pom.xml

This file was deleted.

Loading

0 comments on commit 5e463ba

Please sign in to comment.