Skip to content

Commit

Permalink
asbench 1.6.0 (#79)
Browse files Browse the repository at this point in the history
* fix: add some missing END_TEST macros

* feat: build and run on arm64 linux

* build: use tso gcc plugin on arm linux

* chore: update c client

* ci: use tagged server image in tests

Co-authored-by: Kyle Singer <[email protected]>
  • Loading branch information
dwelch-spike and kyle-singer authored Nov 16, 2022
1 parent db8ffcd commit 77aa7f5
Show file tree
Hide file tree
Showing 18 changed files with 1,792 additions and 116 deletions.
53 changes: 39 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ 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 @@ -59,7 +77,7 @@ INCLUDES = $(DIR_INCLUDE:%=-I%)

DIR_ENV = $(ROOT)/env

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

Expand Down Expand Up @@ -131,7 +149,8 @@ LDFLAGS += -lm -lz
TEST_LDFLAGS = $(LDFLAGS) -Ltest_target/lib -lcheck
BUILD_LDFLAGS = $(LDFLAGS) -Ltarget/lib

CC = cc
CC ?= cc
LD := $(CC)
AR = ar

BUILD_CFLAGS = $(CFLAGS)
Expand Down Expand Up @@ -212,6 +231,7 @@ 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 @@ -231,10 +251,15 @@ target/lib: | target
target/obj/hdr_histogram: | target/obj
mkdir $@

target/obj/%.o: src/main/%.c | target/obj
$(TSO_LIB):
if [ $(ARCH) = "aarch64" ]; then \
$(MAKE) -C $(DIR_TSO); \
fi

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

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

target/lib/libyaml.a: $(DIR_LIBYAML_BUILD)/libyaml.a | target/lib
Expand All @@ -246,8 +271,8 @@ target/lib/libcyaml.a: $(DIR_LIBCYAML_BUILD)/libcyaml.a | target/lib
$(C_CLIENT_LIB):
$(MAKE) -C $(DIR_C_CLIENT)

target/asbench: $(MAIN_OBJECT) $(OBJECTS) $(HDR_OBJECTS) target/lib/libcyaml.a target/lib/libyaml.a $(DIR_C_CLIENT)/target/$(PLATFORM)/lib/libaerospike.a | target
$(CC) -o $@ $(MAIN_OBJECT) $(OBJECTS) $(HDR_OBJECTS) target/lib/libcyaml.a target/lib/libyaml.a $(DIR_C_CLIENT)/target/$(PLATFORM)/lib/libaerospike.a $(BUILD_LDFLAGS)
target/asbench: $(MAIN_OBJECT) $(OBJECTS) $(HDR_OBJECTS) target/lib/libcyaml.a target/lib/libyaml.a $(C_CLIENT_LIB) | target
$(CC) -o $@ $(MAIN_OBJECT) $(OBJECTS) $(HDR_OBJECTS) target/lib/libcyaml.a target/lib/libyaml.a $(C_CLIENT_LIB) $(BUILD_LDFLAGS)

-include $(wildcard $(MAIN_DEPENDENCIES))
-include $(wildcard $(DEPENDENCIES))
Expand All @@ -272,7 +297,7 @@ test: unit integration

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

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

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

test_target/obj/hdr_histogram%.o: modules/hdr_histogram/%.c | test_target/obj/hdr_histogram
test_target/obj/hdr_histogram%.o: modules/hdr_histogram/%.c | $(TSO_LIB) 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 $(DIR_C_CLIENT)/target/$(PLATFORM)/lib/libaerospike.a | test_target
$(CC) -fprofile-arcs -coverage -o $@ $(TEST_OBJECTS) test_target/lib/libcyaml.a test_target/lib/libyaml.a $(DIR_C_CLIENT)/target/$(PLATFORM)/lib/libaerospike.a $(TEST_LDFLAGS)
test_target/test: $(TEST_OBJECTS) test_target/lib/libcyaml.a test_target/lib/libyaml.a $(C_CLIENT_LIB) | test_target
$(CC) -fprofile-arcs -coverage -o $@ $(TEST_OBJECTS) test_target/lib/libcyaml.a test_target/lib/libyaml.a $(C_CLIENT_LIB) $(TEST_LDFLAGS)

# build the benchmark executable with code coverage
test_target/lib/libyaml.a: $(DIR_LIBYAML_BUILD)/libyaml.a | test_target/lib
Expand All @@ -311,8 +336,8 @@ test_target/lib/libyaml.a: $(DIR_LIBYAML_BUILD)/libyaml.a | test_target/lib
test_target/lib/libcyaml.a: $(DIR_LIBCYAML_BUILD)/libcyaml.a | test_target/lib
cp $< $@

test_target/asbench: $(TEST_MAIN_OBJECT) $(TEST_BENCH_OBJECTS) $(TEST_HDR_OBJECTS) test_target/lib/libcyaml.a test_target/lib/libyaml.a $(DIR_C_CLIENT)/target/$(PLATFORM)/lib/libaerospike.a | test_target
$(CC) -fprofile-arcs -coverage -o $@ $(TEST_MAIN_OBJECT) $(TEST_BENCH_OBJECTS) test_target/lib/libcyaml.a test_target/lib/libyaml.a $(TEST_HDR_OBJECTS) $(DIR_C_CLIENT)/target/$(PLATFORM)/lib/libaerospike.a $(TEST_LDFLAGS)
test_target/asbench: $(TEST_MAIN_OBJECT) $(TEST_BENCH_OBJECTS) $(TEST_HDR_OBJECTS) test_target/lib/libcyaml.a test_target/lib/libyaml.a $(C_CLIENT_LIB) | test_target
$(CC) -fprofile-arcs -coverage -o $@ $(TEST_MAIN_OBJECT) $(TEST_BENCH_OBJECTS) test_target/lib/libcyaml.a test_target/lib/libyaml.a $(TEST_HDR_OBJECTS) $(C_CLIENT_LIB) $(TEST_LDFLAGS)

-include $(wildcard $(TEST_DEPENDENCIES))

Expand Down
2 changes: 1 addition & 1 deletion modules/c-client
Submodule c-client updated 106 files
6 changes: 0 additions & 6 deletions src/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ uint32_t gen_rand_range(as_random*, uint32_t max);
*/
uint64_t gen_rand_range_64(as_random*, uint64_t max);

/*
* compares two as_val's, returning true if they are the same
*/
int as_val_cmp(const as_val* v1, const as_val* v2);


/*
* given the length of the bin base name in characters and the number of bins,
* determines whether any key will be too large to fit in an as_bin_name buffer
Expand Down
4 changes: 2 additions & 2 deletions src/include/object_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <aerospike/as_boolean.h>
#include <aerospike/as_bytes.h>
#include <aerospike/as_double.h>
#include <aerospike/as_hashmap.h>
#include <aerospike/as_orderedmap.h>
#include <aerospike/as_integer.h>
#include <aerospike/as_list.h>
#include <aerospike/as_record.h>
Expand Down Expand Up @@ -219,7 +219,7 @@ struct bin_spec_s {
} map;

struct {
as_hashmap val;
as_orderedmap val;
} const_map;

};
Expand Down
71 changes: 21 additions & 50 deletions src/main/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <time.h>

#include <aerospike/as_boolean.h>
#include <aerospike/as_msgpack.h>

#include "common.h"

Expand Down Expand Up @@ -195,51 +196,6 @@ uint64_t gen_rand_range_64(as_random* random, uint64_t max)
return r % max;
}

int
as_val_cmp(const as_val* v1, const as_val* v2)
{
if (v1->type == AS_CMP_WILDCARD || v2->type == AS_CMP_WILDCARD) {
return 0;
}

if (v1->type != v2->type) {
return v1->type - v2->type;
}

switch (v1->type) {
case AS_BOOLEAN:
return ((as_boolean*)v1)->value - ((as_boolean*)v2)->value;

case AS_INTEGER: {
int64_t cmp = ((as_integer*)v1)->value - ((as_integer*)v2)->value;
return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
}

case AS_DOUBLE: {
double cmp = ((as_double*)v1)->value - ((as_double*)v2)->value;
return cmp < 0.0 ? -1 : cmp > 0.0 ? 1 : 0;
}

case AS_STRING:
return strcmp(((as_string*)v1)->value, ((as_string*)v2)->value);

case AS_GEOJSON:
return strcmp(((as_geojson*)v1)->value, ((as_geojson*)v2)->value);

case AS_BYTES:
return as_bytes_cmp((as_bytes*)v1, (as_bytes*)v2);

case AS_LIST:
return as_list_cmp((as_list*)v1, (as_list*)v2);

case AS_MAP:
return as_map_cmp((as_map*)v1, (as_map*)v2);

default:
return 0;
}
}

bool bin_name_too_large(size_t name_len, uint32_t n_bins)
{
if (n_bins == 1) {
Expand Down Expand Up @@ -525,9 +481,9 @@ LOCAL_HELPER int
as_list_cmp_max(const as_list* list1, const as_list* list2, uint32_t max, uint32_t fin)
{
for (uint32_t i = 0; i < max; i++) {
int cmp = as_val_cmp(as_list_get(list1, i), as_list_get(list2, i));
msgpack_compare_t cmp = as_val_cmp(as_list_get(list1, i), as_list_get(list2, i));

if (cmp != 0) {
if (cmp != MSGPACK_COMPARE_EQUAL) {
return cmp;
}
}
Expand Down Expand Up @@ -556,9 +512,9 @@ as_vector_cmp(as_vector* list1, as_vector* list2)
{
// Size of vectors should already be the same.
for (uint32_t i = 0; i < list1->size; i++) {
int cmp = as_val_cmp(as_vector_get_ptr(list1, i), as_vector_get_ptr(list2, i));
msgpack_compare_t cmp = as_val_cmp(as_vector_get_ptr(list1, i), as_vector_get_ptr(list2, i));

if (cmp != 0) {
if (cmp != MSGPACK_COMPARE_EQUAL) {
return cmp;
}
}
Expand All @@ -575,7 +531,22 @@ key_append(const as_val* key, const as_val* val, void* udata)
LOCAL_HELPER int
key_cmp(const void* v1, const void* v2)
{
return as_val_cmp(*(as_val**)v1, *(as_val**)v2);
// we offset by 1 here because as_val_cmp considers 0 as less than, 1 as equal, and 2 as greater.
// https://github.com/aerospike/aerospike-common/blob/master/src/include/aerospike/as_msgpack.h#L61
int cmp = (int) as_val_cmp(*(as_val**)v1, *(as_val**)v2);
switch (cmp)
{
case MSGPACK_COMPARE_LESS:
return -1;
case MSGPACK_COMPARE_EQUAL:
return 0;
case MSGPACK_COMPARE_GREATER:
return 1;
default:
// shouldn't happen but
// don't fail if it does
return 0;
}
}

LOCAL_HELPER bool
Expand Down
6 changes: 3 additions & 3 deletions src/main/coordinator.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ thr_coordinator_complete(thr_coord_t* coord)
coord->unfinished_threads = rem_threads;
// commit this write before signaling the condition variable and releasing
// the lock, since it was not atomic
as_fence_memory();
as_fence_seq();

if (rem_threads == 0) {
pthread_cond_broadcast(&coord->complete);
Expand Down Expand Up @@ -271,7 +271,7 @@ _finish_req_duration(thr_coord_t* coord)
coord->unfinished_threads = rem_threads;
// commit this write before signaling the condition variable and releasing
// the lock, since it was not atomic
as_fence_memory();
as_fence_seq();

// if we're the last thread finishing, notify any threads waiting on the
// complete condition variable
Expand Down Expand Up @@ -309,6 +309,6 @@ clear_cdata_counts(cdata_t* cdata)
cdata->udf_timeout_count = 0;
cdata->udf_error_count = 0;

as_fence_memory();
as_fence_seq();
}

Loading

0 comments on commit 77aa7f5

Please sign in to comment.