Skip to content

Commit 4f603ad

Browse files
committed
Clean up allocator tags
1 parent db33cef commit 4f603ad

6 files changed

Lines changed: 22 additions & 20 deletions

File tree

src/libs/core/allocators/include/allocators/BlockAllocator.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ template<typename _ty,
7373
typename UseAllocator = DefaultBlockAllocator
7474
>
7575
class BlockAllocator {
76+
static constexpr std::string_view default_tag { "block_allocator" };
77+
7678
using tid_type = std::conditional_t<
7779
std::is_same_v<ValidatePolicy, ValidateDealloc>, std::thread::id, std::monostate
7880
>;
@@ -181,13 +183,13 @@ class BlockAllocator {
181183
std::size_t total_deallocs = 0;
182184
#endif
183185

184-
BlockAllocator(std::size_t elements, std::string_view tag = {}) requires std::same_as<ValidatePolicy, ValidateDealloc>
186+
BlockAllocator(std::size_t elements, std::string_view tag = default_tag) requires std::same_as<ValidatePolicy, ValidateDealloc>
185187
: tag_(tag)
186188
, thread_id_(std::this_thread::get_id()) {
187189
initialise(elements);
188190
}
189191

190-
BlockAllocator(std::size_t elements, std::string_view tag = {})
192+
BlockAllocator(std::size_t elements, std::string_view tag = default_tag)
191193
: tag_(tag) {
192194
initialise(elements);
193195
}
@@ -219,7 +221,7 @@ class BlockAllocator {
219221
++total_allocs;
220222
++active_count;
221223
#endif
222-
ALLOC_TRACK(tag_, mem_rep_bytes_alloc, sizeof(Block));
224+
ALLOC_TRACK(tag_, mem_rep_bytes_alloc, sizeof(_ty));
223225
return new (&block->obj) _ty(std::forward<Args>(args)...);
224226
}
225227

@@ -252,7 +254,7 @@ class BlockAllocator {
252254
++total_deallocs;
253255
--active_count;
254256
#endif
255-
ALLOC_TRACK(tag_, mem_rep_bytes_dealloc, sizeof(Block));
257+
ALLOC_TRACK(tag_, mem_rep_bytes_dealloc, sizeof(_ty));
256258
}
257259

258260
std::string_view tag() const {

src/libs/core/allocators/include/allocators/StaticAllocator.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ namespace ember::allocators {
1919

2020
template<std::size_t _size, std::size_t _elements>
2121
class StaticAllocator final {
22-
static constexpr std::string_view tag { "asio_static" };
22+
static constexpr std::string_view default_tag { "static_allocator" };
23+
static constexpr std::string_view block_tag { "static_allocator_block" };
2324

2425
struct alignas(std::max_align_t) AlignedStorage {
2526
std::byte storage[_size];
@@ -31,7 +32,7 @@ class StaticAllocator final {
3132
>;
3233

3334
class SlabAllocator {
34-
static constexpr std::string_view tag { "asio_static_slab" };
35+
static constexpr std::string_view tag { "static_slab_allocator" };
3536
static constexpr std::size_t slab_size = BlockAllocator<>::block_size * _elements;
3637

3738
alignas(std::max_align_t) std::array<std::byte, slab_size> storage;
@@ -73,22 +74,22 @@ class StaticAllocator final {
7374
};
7475

7576
BlockAllocator<SlabAllocator> allocator;
77+
std::string_view tag;
7678

7779
public:
78-
StaticAllocator()
79-
: allocator(_elements, tag) {
80-
ALLOC_TRACK(tag, mem_rep_create);
81-
}
82-
83-
StaticAllocator(std::string_view tag)
84-
: allocator(_elements, tag) {
80+
StaticAllocator(std::string_view tag = default_tag)
81+
: allocator(_elements, block_tag)
82+
, tag(tag) {
8583
ALLOC_TRACK(tag, mem_rep_create);
8684
}
8785

8886
~StaticAllocator() {
8987
ALLOC_TRACK(tag, mem_rep_destroy);
9088
}
9189

90+
StaticAllocator(const StaticAllocator&) = delete;
91+
StaticAllocator& operator=(const StaticAllocator&) = delete;
92+
9293
void* allocate(std::size_t size) {
9394
ALLOC_TRACK(tag, mem_rep_bytes_alloc, size);
9495

src/libs/core/allocators/include/allocators/TLSBlockAllocator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#pragma once
1010

11-
#include <allocators/AllocTrack.h>
1211
#include <allocators/BlockAllocator.h>
1312
#include <type_traits>
1413
#include <utility>

src/realm/ClientConnection.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ namespace ember::realm {
3333
class ClientHandler;
3434

3535
class ClientConnection final {
36+
static constexpr std::string_view allocator_tag { "realm_client_connection" };
37+
3638
public:
3739
static constexpr auto key_size = 40;
3840

3941
private:
40-
static constexpr std::string_view allocator_tag { "realm_client_connection "};
41-
4242
enum class ReadState {
4343
header,
4444
body,
@@ -52,7 +52,7 @@ class ClientConnection final {
5252
std::array<DynamicTLSBuffer, 2> outbound_buffers_;
5353
DynamicTLSBuffer* outbound_front_;
5454
DynamicTLSBuffer* outbound_back_;
55-
StaticChunkAllocator allocator_;
55+
StaticAllocator allocator_;
5656

5757
ClientHandler* handler_;
5858
ConnectionStats stats_;

src/realm/ConnectionDefines.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ using DynamicTLSBuffer = spark::io::DynamicTLSBuffer<
3838
outbound_size, prealloc_nodes, allocators::NoRefCounting, allocators::UnsafeEntrant
3939
>;
4040

41-
using StaticChunkAllocator = allocators::StaticAllocator<asio_chunk_size, asio_chunks>;
41+
using StaticAllocator = allocators::StaticAllocator<asio_chunk_size, asio_chunks>;
4242

4343
template<typename T>
44-
using AsioStaticAllocator = allocators::AsioAllocator<T, StaticChunkAllocator>;
44+
using AsioStaticAllocator = allocators::AsioAllocator<T, StaticAllocator>;
4545

4646
template<typename _ty>
4747
using message_view = protocol::message_view<_ty, BinaryStream>;

src/realm/commands/Connections.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void print_connection_stats_header(bprinter::TablePrinter& table) {
9999
table.AddColumn("Bytes In", 8);
100100
table.AddColumn("Bytes Out", 9);
101101
table.AddColumn("Ops In", 6);
102-
table.AddColumn("Opts Out", 8);
102+
table.AddColumn("Ops Out", 8);
103103
table.PrintHeader();
104104
}
105105

0 commit comments

Comments
 (0)