Skip to content

Commit feab351

Browse files
committed
Merge bitcoin/bitcoin#30161: util: add VecDeque
7b8eea0 tests: add fuzz tests for VecDeque (Pieter Wuille) 62fd24a util: add VecDeque (Pieter Wuille) Pull request description: Extracted from #30126. This adds a `VecDeque` data type, inspired by `std::deque`, but backed by a single allocated memory region used as a ring buffer instead of a linked list of arrays. This gives better memory locality and less allocation overhead, plus better guarantees (some C++ standard library implementations, though not libstdc++ and libc++, use a separate allocation per element in a deque). It is intended for the candidate set search queue in #30126, but may be useful as a replacement for `std::deque` in other places too. It's not a full drop-in replacement, as I did not add iteration support which is unnecessary for the intended use case, but nothing prevents adding that if needed. Everything is tested through a simulation-based fuzz test that compares the behavior with normal `std::deque` equivalent operations, both for trivially-copyable/destructible types and others. ACKs for top commit: instagibbs: reACK bitcoin/bitcoin@7b8eea0 cbergqvist: re-ACK 7b8eea0 hebasto: re-ACK 7b8eea0, I've verified changes since my recent [review](bitcoin/bitcoin#30161 (review)) with glozow: ACK 7b8eea0 Tree-SHA512: 1b62f3ba1a43a1293d8c9de047e2399442e74c46de2df81406151fe27538716ce265f35fb6779ee56d77a39cddf8fb4b4e15bda8f04ebf3b149e2f05fa55cb21
2 parents 4a020ca + 7b8eea0 commit feab351

File tree

4 files changed

+809
-0
lines changed

4 files changed

+809
-0
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ BITCOIN_CORE_H = \
333333
util/translation.h \
334334
util/types.h \
335335
util/ui_change_type.h \
336+
util/vecdeque.h \
336337
util/vector.h \
337338
validation.h \
338339
validationinterface.h \

src/Makefile.test.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ test_fuzz_fuzz_SOURCES = \
397397
test/fuzz/utxo_snapshot.cpp \
398398
test/fuzz/utxo_total_supply.cpp \
399399
test/fuzz/validation_load_mempool.cpp \
400+
test/fuzz/vecdeque.cpp \
400401
test/fuzz/versionbits.cpp
401402
endif # ENABLE_FUZZ_BINARY
402403

0 commit comments

Comments
 (0)