Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ce54746a4a | |||
| b15959d62c | |||
| b009de1c2b | |||
| 55a230c75e | |||
| 0711ec3831 | |||
| 0280bd77e5 | |||
| 359f6f0042 | |||
| aa8504ddba | |||
| fb7cf18f9b | |||
| b808b97940 | |||
| e480f66846 | |||
| d5bc9221a0 | |||
| 9d23b81d6f |
@@ -361,21 +361,7 @@ void benchWorstCaseForRadixRangeRead() {
|
|||||||
void benchCreateAndDestroy() {
|
void benchCreateAndDestroy() {
|
||||||
ankerl::nanobench::Bench bench;
|
ankerl::nanobench::Bench bench;
|
||||||
|
|
||||||
bench.run("create and destroy", [&]() {
|
bench.run("create and destroy", [&]() { ConflictSet cs{0}; });
|
||||||
ConflictSet cs{0};
|
|
||||||
ConflictSet::WriteRange w;
|
|
||||||
uint8_t b[9];
|
|
||||||
b[8] = 0;
|
|
||||||
for (int64_t i = 0; i < 1000; i += 7) {
|
|
||||||
auto x = __builtin_bswap64(i);
|
|
||||||
memcpy(b, &x, 8);
|
|
||||||
w.begin.p = b;
|
|
||||||
w.begin.len = 8;
|
|
||||||
w.end.len = 0;
|
|
||||||
w.end.p = b;
|
|
||||||
cs.addWrites(&w, 1, 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|||||||
+354
-680
File diff suppressed because it is too large
Load Diff
@@ -24,16 +24,15 @@ Hardware for all benchmarks is an AMD Ryzen 9 7900 with (2x32GB) 5600MT/s CL28-3
|
|||||||
|
|
||||||
| ns/op | op/s | err% | ins/op | cyc/op | IPC | bra/op | miss% | total | benchmark
|
| ns/op | op/s | err% | ins/op | cyc/op | IPC | bra/op | miss% | total | benchmark
|
||||||
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|
||||||
| 10.80 | 92,600,541.52 | 0.6% | 180.38 | 54.49 | 3.310 | 41.51 | 0.4% | 0.01 | `point reads`
|
| 11.04 | 90,614,308.12 | 0.8% | 180.38 | 55.13 | 3.272 | 41.51 | 0.4% | 0.01 | `point reads`
|
||||||
| 15.00 | 66,687,691.68 | 0.4% | 278.44 | 76.44 | 3.642 | 55.56 | 0.3% | 0.01 | `prefix reads`
|
| 14.96 | 66,843,629.12 | 0.4% | 274.41 | 74.73 | 3.672 | 55.05 | 0.3% | 0.01 | `prefix reads`
|
||||||
| 36.81 | 27,163,394.61 | 0.4% | 795.06 | 187.91 | 4.231 | 142.67 | 0.2% | 0.01 | `range reads`
|
| 37.06 | 26,982,847.61 | 0.2% | 791.04 | 185.28 | 4.269 | 142.67 | 0.2% | 0.01 | `range reads`
|
||||||
| 18.14 | 55,137,674.01 | 1.2% | 338.19 | 92.86 | 3.642 | 42.81 | 0.4% | 0.01 | `point writes`
|
| 17.89 | 55,887,365.73 | 0.6% | 335.54 | 89.79 | 3.737 | 43.84 | 0.4% | 0.01 | `point writes`
|
||||||
| 33.19 | 30,127,119.71 | 0.1% | 681.03 | 170.05 | 4.005 | 98.68 | 0.2% | 0.01 | `prefix writes`
|
| 31.85 | 31,394,336.65 | 0.3% | 615.32 | 159.63 | 3.855 | 87.69 | 0.2% | 0.01 | `prefix writes`
|
||||||
| 37.37 | 26,759,432.70 | 1.9% | 779.70 | 195.45 | 3.989 | 114.21 | 0.0% | 0.01 | `range writes`
|
| 36.17 | 27,647,221.45 | 0.6% | 705.11 | 182.80 | 3.857 | 100.62 | 0.1% | 0.01 | `range writes`
|
||||||
| 74.36 | 13,448,582.47 | 1.9% | 1,425.68 | 389.08 | 3.664 | 258.88 | 0.1% | 0.01 | `monotonic increasing point writes`
|
| 79.01 | 12,656,457.78 | 0.7% | 1,498.35 | 402.46 | 3.723 | 270.50 | 0.1% | 0.01 | `monotonic increasing point writes`
|
||||||
| 316,928.00 | 3,155.29 | 1.5% | 3,992,986.00 | 1,699,813.00 | 2.349 | 806,226.50 | 0.0% | 0.01 | `worst case for radix tree`
|
| 303,667.50 | 3,293.08 | 1.1% | 3,931,273.00 | 1,612,702.50 | 2.438 | 806,223.33 | 0.0% | 0.01 | `worst case for radix tree`
|
||||||
| 75.26 | 13,286,517.16 | 0.5% | 1,590.01 | 386.67 | 4.112 | 258.00 | 0.0% | 0.01 | `create and destroy`
|
| 83.70 | 11,947,443.83 | 0.7% | 1,738.03 | 429.06 | 4.051 | 270.01 | 0.0% | 0.01 | `create and destroy`
|
||||||
|
|
||||||
|
|
||||||
# "Real data" test
|
# "Real data" test
|
||||||
|
|
||||||
@@ -48,7 +47,7 @@ Check: 4.47891 seconds, 364.05 MB/s, Add: 4.55599 seconds, 123.058 MB/s, Gc rati
|
|||||||
## radix tree
|
## radix tree
|
||||||
|
|
||||||
```
|
```
|
||||||
Check: 0.910234 seconds, 1791.35 MB/s, Add: 1.25908 seconds, 445.287 MB/s, Gc ratio: 44.0415%
|
Check: 0.958985 seconds, 1700.28 MB/s, Add: 1.35083 seconds, 415.044 MB/s, Gc ratio: 44.4768%, Peak idle memory: 2.33588e+06
|
||||||
```
|
```
|
||||||
|
|
||||||
## hash table
|
## hash table
|
||||||
|
|||||||
+68
-12
@@ -11,6 +11,8 @@
|
|||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "ConflictSet.h"
|
#include "ConflictSet.h"
|
||||||
#include "third_party/nadeau.h"
|
#include "third_party/nadeau.h"
|
||||||
@@ -175,25 +177,22 @@ double toSeconds(timeval t) {
|
|||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
struct PerfCounter {
|
struct PerfCounter {
|
||||||
explicit PerfCounter(int event) {
|
PerfCounter(int type, int config, const std::string &labels = {})
|
||||||
|
: labels(labels) {
|
||||||
struct perf_event_attr pe;
|
struct perf_event_attr pe;
|
||||||
|
|
||||||
memset(&pe, 0, sizeof(pe));
|
memset(&pe, 0, sizeof(pe));
|
||||||
pe.type = PERF_TYPE_HARDWARE;
|
pe.type = type;
|
||||||
pe.size = sizeof(pe);
|
pe.size = sizeof(pe);
|
||||||
pe.config = event;
|
pe.config = config;
|
||||||
pe.inherit = 1;
|
pe.inherit = 1;
|
||||||
pe.exclude_kernel = 1;
|
pe.exclude_kernel = 1;
|
||||||
pe.exclude_hv = 1;
|
pe.exclude_hv = 1;
|
||||||
|
|
||||||
fd = perf_event_open(&pe, 0, -1, -1, 0);
|
fd = perf_event_open(&pe, 0, -1, -1, 0);
|
||||||
if (fd == -1) {
|
|
||||||
fprintf(stderr, "Error opening leader %llx\n", pe.config);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t total() {
|
int64_t total() const {
|
||||||
int64_t count;
|
int64_t count;
|
||||||
if (read(fd, &count, sizeof(count)) != sizeof(count)) {
|
if (read(fd, &count, sizeof(count)) != sizeof(count)) {
|
||||||
perror("read instructions from perf");
|
perror("read instructions from perf");
|
||||||
@@ -202,10 +201,26 @@ struct PerfCounter {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
~PerfCounter() { close(fd); }
|
PerfCounter(PerfCounter &&other)
|
||||||
|
: fd(std::exchange(other.fd, -1)), labels(std::move(other.labels)) {}
|
||||||
|
PerfCounter &operator=(PerfCounter &&other) {
|
||||||
|
fd = std::exchange(other.fd, -1);
|
||||||
|
labels = std::move(other.labels);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~PerfCounter() {
|
||||||
|
if (fd >= 0) {
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ok() const { return fd >= 0; }
|
||||||
|
const std::string &getLabels() const { return labels; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fd;
|
int fd;
|
||||||
|
std::string labels;
|
||||||
static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
||||||
int cpu, int group_fd, unsigned long flags) {
|
int cpu, int group_fd, unsigned long flags) {
|
||||||
int ret;
|
int ret;
|
||||||
@@ -216,7 +231,7 @@ private:
|
|||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
struct PerfCounter {
|
struct PerfCounter {
|
||||||
explicit PerPerfCounter(int) {}
|
PerfCounter(int, int) {}
|
||||||
int64_t total() { return 0; }
|
int64_t total() { return 0; }
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -233,8 +248,43 @@ int main(int argc, char **argv) {
|
|||||||
int metricsCount;
|
int metricsCount;
|
||||||
cs.getMetricsV1(&metrics, &metricsCount);
|
cs.getMetricsV1(&metrics, &metricsCount);
|
||||||
|
|
||||||
PerfCounter instructions{PERF_COUNT_HW_INSTRUCTIONS};
|
PerfCounter instructions{PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS};
|
||||||
PerfCounter cycles{PERF_COUNT_HW_CPU_CYCLES};
|
PerfCounter cycles{PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES};
|
||||||
|
|
||||||
|
std::vector<PerfCounter> cacheCounters;
|
||||||
|
for (auto [id, idStr] : std::initializer_list<std::pair<int, std::string>>{
|
||||||
|
{PERF_COUNT_HW_CACHE_L1D, "l1d"},
|
||||||
|
{PERF_COUNT_HW_CACHE_L1I, "l1i"},
|
||||||
|
{PERF_COUNT_HW_CACHE_LL, "ll"},
|
||||||
|
{PERF_COUNT_HW_CACHE_DTLB, "dtlb"},
|
||||||
|
// Somehow was showing a miss rate > 1 /shrug
|
||||||
|
// {PERF_COUNT_HW_CACHE_ITLB, "itlb"},
|
||||||
|
{PERF_COUNT_HW_CACHE_BPU, "bpu"},
|
||||||
|
{PERF_COUNT_HW_CACHE_NODE, "node"},
|
||||||
|
}) {
|
||||||
|
for (auto [op, opStr] :
|
||||||
|
std::initializer_list<std::pair<int, std::string>>{
|
||||||
|
{PERF_COUNT_HW_CACHE_OP_READ, "read"},
|
||||||
|
{PERF_COUNT_HW_CACHE_OP_WRITE, "write"},
|
||||||
|
{PERF_COUNT_HW_CACHE_OP_PREFETCH, "prefetch"},
|
||||||
|
}) {
|
||||||
|
for (auto [result, resultStr] :
|
||||||
|
std::initializer_list<std::pair<int, std::string>>{
|
||||||
|
{PERF_COUNT_HW_CACHE_RESULT_MISS, "miss"},
|
||||||
|
{PERF_COUNT_HW_CACHE_RESULT_ACCESS, "access"},
|
||||||
|
}) {
|
||||||
|
auto labels = "{id=\"" + idStr + "\", op=\"" + opStr +
|
||||||
|
"\", result=\"" + resultStr + "\"}";
|
||||||
|
cacheCounters.emplace_back(PERF_TYPE_HW_CACHE,
|
||||||
|
id | (op << 8) | (result << 16), labels);
|
||||||
|
if (!cacheCounters.back().ok()) {
|
||||||
|
fprintf(stderr, "Could not open cache event: %s\n", labels.c_str());
|
||||||
|
cacheCounters.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto w = std::thread{workload, &cs};
|
auto w = std::thread{workload, &cs};
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -272,6 +322,12 @@ int main(int argc, char **argv) {
|
|||||||
"cycles_total ";
|
"cycles_total ";
|
||||||
body += std::to_string(cycles.total());
|
body += std::to_string(cycles.total());
|
||||||
body += "\n";
|
body += "\n";
|
||||||
|
body += "# HELP cache_event_total Total number of cache events\n"
|
||||||
|
"# TYPE cache_event_total counter\n";
|
||||||
|
for (const auto &counter : cacheCounters) {
|
||||||
|
body += "cache_event_total" + counter.getLabels() + " " +
|
||||||
|
std::to_string(counter.total()) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < metricsCount; ++i) {
|
for (int i = 0; i < metricsCount; ++i) {
|
||||||
body += "# HELP ";
|
body += "# HELP ";
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user