Skip to content

Commit

Permalink
asbench 1.7.0 (#83)
Browse files Browse the repository at this point in the history
* build: TOOLS-2257 Upgrade build std to C11 (#78)

* feat: [TOOLS-2274] build on m1 (#82)

* build: [TOOLS-2291] statically link openssl in mac builds (#81)

Co-authored-by: Jesse S <[email protected]>
  • Loading branch information
dwelch-spike and jdogmcsteezy authored Dec 21, 2022
1 parent 77aa7f5 commit 67aa14c
Show file tree
Hide file tree
Showing 24 changed files with 200 additions and 1,863 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark-artifact-linux.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build:Main
on:
push:
branches: [ main, mac_build ]
branches: [ main ]
jobs:
build-libraries:
runs-on: ubuntu-20.04
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/benchmark-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build and Test All

on:
push:
branches: [ main, test-ready ]
branches: [ main, test-ready, "*-bugfix" ]
pull_request:
branches: [ main, test-ready ]
branches: [ main, test-ready, "*-bugfix" ]
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -28,9 +28,9 @@ jobs:
fi
- name: install lcov
run: |
wget "https://github.com/linux-test-project/lcov/archive/master.zip"
unzip master.zip
cd lcov-master
wget "https://github.com/linux-test-project/lcov/archive/refs/tags/v1.16.zip"
unzip v1.16.zip
cd lcov-1.16
sudo make install
- name: Download libcheck
uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/mac-artifact.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Mac Artifact
on:
push:
branches: [actionsHub, main, test-ready ]
branches: [ main, test-ready, "bugfix-*" ]
pull_request:
branches: [actionsHub]
branches: []
workflow_call:
inputs:
submodule:
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
git describe --tags --always
- name: Build asbench
run: |
make EVENT_LIB=${{ matrix.ev-lib }} LIBUV_STATIC_PATH=/usr/local/lib LIBEVENT_STATIC_PATH=/usr/local/lib LIBEV_STATIC_PATH=/usr/local/lib
make EVENT_LIB=${{ matrix.ev-lib }} LIBUV_STATIC_PATH=/usr/local/lib LIBEVENT_STATIC_PATH=/usr/local/lib LIBEV_STATIC_PATH=/usr/local/lib OPENSSL_STATIC_PATH=/usr/local/opt/openssl/lib
working-directory: ${{ steps.working-dir.outputs.value }}
- name: Sanity test asbench artifact
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Version.java
modules/.*
target/
client_test-valgrind
.vscode

# Compiled source #
###################
Expand Down
18 changes: 0 additions & 18 deletions .vscode/c_cpp_properties.json

This file was deleted.

67 changes: 31 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@ VERSION := $(shell git describe 2>/dev/null; if [ $${?} != 0 ]; then echo 'unkno
ROOT = $(CURDIR)
NAME = $(shell basename $(ROOT))
OS = $(shell uname)
ARCH = $(shell uname -m)

M1_HOME_BREW =
ifeq ($(OS),Darwin)
ARCH = $(shell uname -m)
else
ARCH = $(shell uname -m)
ifneq ($(wildcard /opt/homebrew),)
M1_HOME_BREW = true
endif
endif

# M1 macs brew install openssl under /opt/homebrew/opt/openssl
# set OPENSSL_PREFIX to the prefix for your openssl if it is installed elsewhere
OPENSSL_PREFIX ?= /usr/local/opt/openssl
ifdef M1_HOME_BREW
OPENSSL_PREFIX = /opt/homebrew/opt/openssl
endif

CMAKE3_CHECK := $(shell cmake3 --help > /dev/null 2>&1 || (echo "cmake3 not found"))
Expand All @@ -33,7 +43,7 @@ else
endif
endif

CFLAGS = -std=gnu99 -Wall -fPIC -O3 -MMD -MP
CFLAGS = -std=gnu11 -Wall -fPIC -O3 -MMD -MP
CFLAGS += -fno-common -fno-strict-aliasing
CFLAGS += -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_GNU_SOURCE
CFLAGS += -DTOOL_VERSION=\"$(VERSION)\"
Expand All @@ -47,24 +57,6 @@ DIR_LIBCYAML_BUILD ?= $(ROOT)/modules/libcyaml/$(DIR_LIBCYAML_BUILD_REL)
DIR_C_CLIENT ?= $(ROOT)/modules/c-client
C_CLIENT_LIB := $(DIR_C_CLIENT)/target/$(PLATFORM)/lib/libaerospike.a

DIR_TSO := $(ROOT)/tso
TSO_LIB := $(DIR_TSO)/tso.so

ifeq ($(ARCH),aarch64)
# Plugin configuration.
PLUGIN_ENABLE = yes
PLUGIN_FIX_ASM = yes
PLUGIN_FIX_BUILT_IN = yes
PLUGIN_PROFILING = no

TSO_FLAGS = -fplugin=$(TSO_LIB) -fplugin-arg-tso-enable=$(PLUGIN_ENABLE) \
-fplugin-arg-tso-exclude=$(DIR_TSO)/exclude_ce.txt -fplugin-arg-tso-exclude=$(DIR_TSO)/exclude_ce.txt \
-fplugin-arg-tso-track-deps=yes -fplugin-arg-tso-fix-asm=$(PLUGIN_FIX_ASM) \
-fplugin-arg-tso-fix-built-in=$(PLUGIN_FIX_BUILT_IN) -fplugin-arg-tso-profiling=$(PLUGIN_PROFILING)

CFLAGS += $(TSO_FLAGS)
endif

DIR_INCLUDE = $(ROOT)/src/include
DIR_INCLUDE += $(ROOT)/modules
DIR_INCLUDE += $(DIR_LIBYAML)/include
Expand All @@ -77,7 +69,7 @@ INCLUDES = $(DIR_INCLUDE:%=-I%)

DIR_ENV = $(ROOT)/env

ifneq ($(ARCH),$(filter $(ARCH),ppc64 ppc64le aarch64))
ifneq ($(ARCH),$(filter $(ARCH),ppc64 ppc64le aarch64 arm64))
CFLAGS += -march=nocona
endif

Expand All @@ -103,7 +95,7 @@ LDFLAGS = -L/usr/local/lib

ifeq ($(OPENSSL_STATIC_PATH),)
ifeq ($(OS),Darwin)
LDFLAGS += -L/usr/local/opt/openssl/lib
LDFLAGS += -L$(OPENSSL_PREFIX)/lib
endif
LDFLAGS += -lssl
LDFLAGS += -lcrypto
Expand Down Expand Up @@ -146,6 +138,15 @@ endif

LDFLAGS += -lm -lz

# if this is an m1 mac using homebrew
# add the new homebrew lib and include path
# incase dependencies are installed there
# NOTE: /usr/local/include will be checked first
ifdef M1_HOME_BREW
LDFLAGS += -L/opt/homebrew/lib
INCLUDES += -I/opt/homebrew/include
endif

TEST_LDFLAGS = $(LDFLAGS) -Ltest_target/lib -lcheck
BUILD_LDFLAGS = $(LDFLAGS) -Ltarget/lib

Expand Down Expand Up @@ -231,7 +232,6 @@ target/libbench.a: $(OBJECTS)
clean:
rm -rf target test_target $(DIR_ENV)
$(MAKE) clean -C $(DIR_LIBCYAML)
$(MAKE) clean -C $(DIR_TSO)
if [ -d $(DIR_LIBYAML_BUILD) ]; then $(MAKE) clean -C $(DIR_LIBYAML_BUILD); fi
rm -rf $(DIR_LIBYAML_BUILD)
$(MAKE) -C $(DIR_C_CLIENT) clean
Expand All @@ -251,15 +251,10 @@ target/lib: | target
target/obj/hdr_histogram: | target/obj
mkdir $@

$(TSO_LIB):
if [ $(ARCH) = "aarch64" ]; then \
$(MAKE) -C $(DIR_TSO); \
fi

target/obj/%.o: src/main/%.c | $(TSO_LIB) target/obj
target/obj/%.o: src/main/%.c | target/obj
$(CC) $(BUILD_CFLAGS) -o $@ -c $< $(INCLUDES)

target/obj/hdr_histogram%.o: modules/hdr_histogram/%.c | $(TSO_LIB) target/obj/hdr_histogram
target/obj/hdr_histogram%.o: modules/hdr_histogram/%.c | target/obj/hdr_histogram
$(CC) $(BUILD_CFLAGS) -o $@ -c $< $(INCLUDES)

target/lib/libyaml.a: $(DIR_LIBYAML_BUILD)/libyaml.a | target/lib
Expand Down Expand Up @@ -297,7 +292,7 @@ test: unit integration

# unit testing
.PHONY: unit
unit: | $(TSO_LIB) test_target/test
unit: | test_target/test
@echo
@#valgrind --tool=memcheck --leak-check=full --track-origins=yes ./test_target/test
@./test_target/test
Expand All @@ -317,13 +312,13 @@ test_target/obj/hdr_histogram: | test_target/obj
test_target/lib: | test_target
mkdir $@

test_target/obj/unit/%.o: src/test/unit/%.c | $(TSO_LIB) test_target/obj/unit
test_target/obj/unit/%.o: src/test/unit/%.c | test_target/obj/unit
$(CC) $(TEST_CFLAGS) -o $@ -c $< $(INCLUDES)

test_target/obj/%.o: src/main/%.c | $(TSO_LIB) test_target/obj
test_target/obj/%.o: src/main/%.c | test_target/obj
$(CC) $(TEST_CFLAGS) -fprofile-arcs -ftest-coverage -coverage -o $@ -c $< $(INCLUDES)

test_target/obj/hdr_histogram%.o: modules/hdr_histogram/%.c | $(TSO_LIB) test_target/obj/hdr_histogram
test_target/obj/hdr_histogram%.o: modules/hdr_histogram/%.c | test_target/obj/hdr_histogram
$(CC) $(TEST_CFLAGS) -fprofile-arcs -ftest-coverage -coverage -o $@ -c $< $(INCLUDES)

test_target/test: $(TEST_OBJECTS) test_target/lib/libcyaml.a test_target/lib/libyaml.a $(C_CLIENT_LIB) | test_target
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ For more information on how to use the benchmark tool and configure it to your n

### Dependencies

Before building, you need to have a local copy of the [Aerospike C Client](https://github.com/aerospike/aerospike-client-c) and to have built it. After this, set the environment variable `CLIENTREPO` to point to the directory containing the built C client.
Asbackup builds the [Aerospike C Client](https://github.com/aerospike/aerospike-client-c) as a submodule.
Make sure all the C clients build dependencies are installed before starting the asbackup build.

Additional external dependencies:
* OpenSSL (libssl and libcrypto)
* libyaml-devel
* libev, libuv, or libevent, if an event library is used
* If on macOS install via `brew`

This project uses git submodules, so you will need to initialize and update submodules before building this project.

$ git submodule update --init
$ git submodule update --init --recursive

### Build

Expand Down
28 changes: 15 additions & 13 deletions src/include/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
******************************************************************************/
#pragma once

#include <stdatomic.h>

#include <aerospike/aerospike.h>
#include <aerospike/as_event.h>
#include <aerospike/as_password.h>
Expand Down Expand Up @@ -111,18 +113,18 @@ typedef struct clientdata_s {
aerospike client;

// TODO make all these counts thread-local to reduce contention
uint64_t read_hit_count;
uint64_t read_miss_count;
uint64_t read_timeout_count;
uint64_t read_error_count;
_Atomic(uint64_t) read_hit_count;
_Atomic(uint64_t) read_miss_count;
_Atomic(uint64_t) read_timeout_count;
_Atomic(uint64_t) read_error_count;

uint64_t write_count;
uint64_t write_timeout_count;
uint64_t write_error_count;
_Atomic(uint64_t) write_count;
_Atomic(uint64_t) write_timeout_count;
_Atomic(uint64_t) write_error_count;

uint64_t udf_count;
uint64_t udf_timeout_count;
uint64_t udf_error_count;
_Atomic(uint64_t) udf_count;
_Atomic(uint64_t) udf_timeout_count;
_Atomic(uint64_t) udf_error_count;

FILE* hdr_comp_read_output;
FILE* hdr_text_read_output;
Expand Down Expand Up @@ -162,18 +164,18 @@ typedef struct threaddata_s {
// thread index: [0, n_threads)
uint32_t t_idx;
// which workload stage we're currrently on
uint32_t stage_idx;
_Atomic(uint32_t) stage_idx;

/*
* note: to stop threads, tdata->finished must be set before tdata->do_work
* to prevent deadlocking
*/
// when true, things continue as normal, when set to false, worker
// threads will stop doing what they're doing and await orders
bool do_work;
atomic_bool do_work;
// when true, all threads will stop doing work and close (note that do_work
// must also be set to false for this to work)
bool finished;
atomic_bool finished;

// the following arguments are initialized for each stage
as_record fixed_full_record;
Expand Down
2 changes: 1 addition & 1 deletion src/include/coordinator.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef struct thr_coordinator_s {
// stage, plus this thread (which decrements this variable after returning
// from the as_sleep call, i.e. once the minimum required duration of the
// stage has elapsed)
uint32_t unfinished_threads;
_Atomic(uint32_t) unfinished_threads;
} thr_coord_t;

struct coordinator_worker_args_s {
Expand Down
8 changes: 4 additions & 4 deletions src/include/histogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef struct rangespec_s {


typedef struct histogram_s {
uint32_t* buckets;
_Atomic(uint32_t)* buckets;
struct bucket_range_desc_s* bounds;

// name to be printed before each output line of this histogram
Expand All @@ -48,9 +48,9 @@ typedef struct histogram_s {
delay_t range_max;

// a count of the number of data points below the minimum bucket
uint32_t underflow_cnt;
_Atomic(uint32_t) underflow_cnt;
// a count of the number of data points above the maximum bucket
uint32_t overflow_cnt;
_Atomic(uint32_t) overflow_cnt;

// the number of elements in the bounds array
uint32_t n_bounds;
Expand Down Expand Up @@ -102,7 +102,7 @@ uint64_t histogram_calc_total(const histogram_t* h);
/*
* insert the delay into the histogram in a thread-safe manner
*/
void histogram_add(histogram_t* h, delay_t elapsed_us);
void histogram_incr(histogram_t* h, delay_t elapsed_us);

/*
* returns the count in the bucket of the given index
Expand Down
4 changes: 2 additions & 2 deletions src/include/osx_pthread_barrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ typedef struct pthread_barrier {
// the number of threads that must meet at the barrier
uint32_t count;
// the count of threads that have met the barrier
uint32_t in;
_Atomic(uint32_t) in;
// the round number (starts at 0, incremented each time all threads reach
// the barrier)
uint32_t current_round;
_Atomic(uint32_t) current_round;
} pthread_barrier_t;

int32_t pthread_barrier_init(pthread_barrier_t*, void* attr,
Expand Down
4 changes: 2 additions & 2 deletions src/include/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
* queue
*/
typedef struct queue_s {
void** items;
_Atomic(void*)* items;
// length of items - 1 (length is always a power of 2)
uint32_t len_mask;

// the position of the next element to be inserted (modulo len)
uint32_t __attribute__((aligned(8))) pos;
_Atomic(uint32_t) __attribute__((aligned(8))) pos;
// the position of the head, i.e. the next element to be popped (modulo len)
uint32_t __attribute__((aligned(8))) head;

Expand Down
Loading

0 comments on commit 67aa14c

Please sign in to comment.