Commit ecbf4ba
committed
Merge bitcoin/bitcoin#29114: util: Faster std::byte (pre)vector (un)serialize
fab4169 Allow int8_t optimized vector serialization (MarcoFalke)
facaa14 Faster std::byte (pre)vector (un)serialize (MarcoFalke)
Pull request description:
Currently, large vectors of `std::byte` are (un)serialized byte-by-byte, which is slow. Fix this, by enabling the already existing optimization for them.
On my system this gives a 10x speedup for `./src/bench/bench_bitcoin --filter=PrevectorDeserializeTrivial`, when `std::byte` are used:
```diff
diff --git a/src/bench/prevector.cpp b/src/bench/prevector.cpp
index 2524e21..76b16bc34e 100644
--- a/src/bench/prevector.cpp
+++ b/src/bench/prevector.cpp
@@ -17,7 +17,7 @@ struct nontrivial_t {
static_assert(!std::is_trivially_default_constructible<nontrivial_t>::value,
"expected nontrivial_t to not be trivially constructible");
-typedef unsigned char trivial_t;
+typedef std::byte trivial_t;
static_assert(std::is_trivially_default_constructible<trivial_t>::value,
"expected trivial_t to be trivially constructible");
```
However, the optimization does not cover `signed char`. Fix that as well.
ACKs for top commit:
sipa:
utACK fab4169
achow101:
ACK fab4169
TheCharlatan:
ACK fab4169
Tree-SHA512: a3e20f375fd1d0e0dedb827a8ce528de1173ea69660c8c891ad1343a86b422072f6505096fca0d3f8af4442fbe1378a02e32d5974919d4e88ff06934d0258cba2 files changed
+8
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
710 | 710 | | |
711 | 711 | | |
712 | 712 | | |
713 | | - | |
714 | 713 | | |
715 | 714 | | |
716 | 715 | | |
717 | 716 | | |
718 | 717 | | |
719 | 718 | | |
720 | | - | |
721 | 719 | | |
722 | 720 | | |
723 | 721 | | |
| |||
820 | 818 | | |
821 | 819 | | |
822 | 820 | | |
823 | | - | |
| 821 | + | |
824 | 822 | | |
825 | | - | |
826 | | - | |
| 823 | + | |
827 | 824 | | |
828 | 825 | | |
829 | 826 | | |
| |||
833 | 830 | | |
834 | 831 | | |
835 | 832 | | |
836 | | - | |
| 833 | + | |
837 | 834 | | |
838 | 835 | | |
839 | 836 | | |
| |||
856 | 853 | | |
857 | 854 | | |
858 | 855 | | |
859 | | - | |
| 856 | + | |
860 | 857 | | |
861 | | - | |
862 | | - | |
| 858 | + | |
863 | 859 | | |
864 | 860 | | |
865 | 861 | | |
| |||
877 | 873 | | |
878 | 874 | | |
879 | 875 | | |
880 | | - | |
| 876 | + | |
881 | 877 | | |
882 | 878 | | |
883 | 879 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
290 | 291 | | |
291 | 292 | | |
292 | 293 | | |
| 294 | + | |
293 | 295 | | |
294 | 296 | | |
295 | 297 | | |
| |||
0 commit comments