Skip to content

Commit 89d930c

Browse files
Internal change
PiperOrigin-RevId: 890673373
1 parent 0be05fd commit 89d930c

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/google/protobuf/arena.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ struct ABSL_ATTRIBUTE_WARN_UNUSED ArenaOptions final {
177177
// individual arena allocation request occurs with a size larger than this
178178
// maximum). Requested block sizes increase up to this value, then remain
179179
// here.
180-
size_t max_block_size = internal::AllocationPolicy::kDefaultMaxBlockSize;
180+
size_t max_block_size = internal::AllocationPolicy::DefaultMaxBlockSize();
181181

182182
// An initial block of memory for the arena to use, or nullptr for none. If
183183
// provided, the block must live at least as long as the arena itself. The
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "google/protobuf/arena_allocation_policy.h"
2+
3+
#include <cstddef>
4+
5+
#include "third_party/tcmalloc/experiment.h"
6+
#include "third_party/tcmalloc/experiment_config.h"
7+
8+
namespace google {
9+
namespace protobuf {
10+
namespace internal {
11+
12+
size_t AllocationPolicy::DefaultMaxBlockSize() {
13+
return 32 << 10;
14+
}
15+
16+
} // namespace internal
17+
} // namespace protobuf
18+
} // namespace google

src/google/protobuf/arena_allocation_policy.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ namespace internal {
2222
// public configuration class such as `ArenaOptions`.
2323
struct AllocationPolicy {
2424
static constexpr size_t kDefaultStartBlockSize = 256;
25-
static constexpr size_t kDefaultMaxBlockSize = 32 << 10;
25+
static size_t DefaultMaxBlockSize();
2626

2727
size_t start_block_size = kDefaultStartBlockSize;
28-
size_t max_block_size = kDefaultMaxBlockSize;
28+
size_t max_block_size = DefaultMaxBlockSize();
2929

3030
void* (*block_alloc)(size_t) = nullptr;
3131
void (*block_dealloc)(void*, size_t) = nullptr;
3232

3333
bool IsDefault() const {
3434
return start_block_size == kDefaultStartBlockSize &&
35-
max_block_size == kDefaultMaxBlockSize && block_alloc == nullptr &&
35+
max_block_size == DefaultMaxBlockSize() && block_alloc == nullptr &&
3636
block_dealloc == nullptr;
3737
}
3838
};

0 commit comments

Comments
 (0)