Disable new sample collection after first bad_alloc

- Add more info to --async_xacts description
- Clean up unused macro in fdb_api.hpp
This commit is contained in:
Junhyun Shim 2022-04-26 10:54:39 +02:00
parent 81f9279db2
commit 81211989f1
3 changed files with 21 additions and 15 deletions

View File

@ -26,14 +26,6 @@
#define FDB_API_VERSION 720
#endif
#if defined(__GNUG__)
#define force_inline inline __attribute__((__always_inline__))
#elif defined(_MSC_VER)
#define force_inline __forceinline
#else
#error Missing force inline
#endif
#include <cassert>
#include <cstdint>
#include <memory>

View File

@ -58,7 +58,8 @@ Arguments
- | ``--async_xacts <xacts>``
| Number of transactions per worker process to run asynchronously (Default: 0)
| ``<xacts>`` > 0 switches the execution mode to non-blocking (See ``-t | --threads``)
| ``<xacts>`` > 0 switches the execution mode to non-blocking (See ``-t | --threads``), with the exception of blob granules API
| Note: throttling options, e.g. ``--tpsmax``, ``--tpsmin``, ``--tpschange``, ``--tpsinterval``, are ignored in asynchronous mode
- | ``-r | --rows <rows>``
| Number of rows initially populated (Default: 100000)

View File

@ -25,6 +25,7 @@
#include <cstdint>
#include <cstring>
#include <list>
#include <new>
#include <utility>
#include "operations.hpp"
#include "time.hpp"
@ -32,14 +33,14 @@
namespace mako {
/* size of each block to get detailed latency for each operation */
constexpr const size_t LAT_BLOCK_SIZE = 4095;
constexpr const size_t LAT_BLOCK_SIZE = 4093;
/* memory block allocated to each operation when collecting detailed latency */
class LatencySampleBlock {
uint64_t samples[LAT_BLOCK_SIZE]{
0,
};
uint32_t index{ 0 };
uint64_t index{ 0 };
public:
LatencySampleBlock() noexcept = default;
@ -52,19 +53,31 @@ public:
std::pair<uint64_t const*, size_t> data() const noexcept { return { samples, index }; }
};
/* collect sampled latencies */
/* collect sampled latencies until OOM is hit */
class LatencySampleBin {
std::list<LatencySampleBlock> blocks;
bool noMoreAlloc{false};
bool tryAlloc() {
try {
blocks.emplace_back();
} catch (const std::bad_alloc&) {
noMoreAlloc = true;
return false;
}
return true;
}
public:
void reserveOneBlock() {
if (blocks.empty())
blocks.emplace_back();
tryAlloc();
}
void put(timediff_t td) {
if (blocks.empty() || blocks.back().full())
blocks.emplace_back();
if (blocks.empty() || blocks.back().full()) {
if (noMoreAlloc || !tryAlloc()) return;
}
blocks.back().put(td);
}