Repository navigation
Commit 87201aa
authored
Network/Scheduling Improvements (stellar#5450)
# Description
This PR contains a collection of implementation specific fixes and
optimizations. There aren't really any design or logical changes (with
the exception of early tx set preparation), but just a bunch of cleanups
and optimizations at the scheduling and networking stack layer. I think
these are all cheap, uncontroversial wins that remove some bottlenecks
that might affect future larger experiments.
Each change has it's own commit:
- `f3dcf1357` Fixes a loadgen bug, were we'd always submit a TX to our
mempool twice.
- `c87b8750b` Enables concurrent TX set emission. Previously, while the
underlying transport layer was parallel, the command dispatcher blocked
on completion of some workloads, like tx sets. This means the leader had
a de-facto serial scheduling conflict. This commit removes a bunch of
unnecessary blocking at the command dispatch level. It also has a few
other scheduling optimizations, like separating fetch request from the
actual response write in the scheduler.
- `f85d70def` Prepare tx sets in advance. This is the only logical
change. TX set preparation takes a long time for the leader. However, if
we finish a ledger early, the leader just waits idle until the next
ledger trigger, then starts construction. This starts construction
early, such that the leader node starts preparing a tx set immediately
after closing the last ledger. We also extend this to the 2nd eligible
leader, where they also prepare a tx set in advance so we don't stall
further on nomination time out.
- `368fa9044` Stream priorities. This implements stream priorities, such
the SCP messages are highest priority, TX Sets next, then transaction
flooding at lowest priority. This is all done via QUIC native
capabilities. We also move some of the message types previously in the
TX Set stream into the SCP stream. Specifically, the tx set fetching
(and in the future, DONT_HAVE messages) all get assigned in the high
priority SCP stream, where the actual tx set payload comes through the
TX set stream. Basically, any small message related to consensus (SCP
messages and "control" messages related to tx set fetching) are highest
priority in SCP stream.
- `4db17d26f` UDP buffer settings. This changes a few low level UDP
settings. During load, we actually have a lot of dropped packets, so I
(claude) tinkered with the network settings. This made a surprisingly
large difference.
- `842e4e690` Only deliver TX sets to core on request. This change makes
is such that the rust overlay subprocess will cache incoming tx sets and
only give them to core when requested. TX set serialization across C++
and rust is expensive, and the issue is that rust would sent multiple
copies of the same TX set to C++ before C++ told rust that it had got
and processed the tx set. This removes this duplication so we process a
given TX set just once.
- `ff620f2fe` Reduce tx set copies. We maintain less redundant copies
and allocations when a leader is transmitting TX sets.
- `1a0e5fa80` Fixes race conditions in the tx queue, where sometimes we
wouldn't properly remove externalized TXs.
These changes made a significant impact on top line performance. I was
mostly concerned with benchmarking the phase 1 SAC goals (3k SAC TPS, 10
orgs, 2s block). We are still quite far from this goal in
overlay-v2-shared, so I ran latency tests at 1k TPS and 2k TPS (3k TPS
just fails at any block time). This was all with 200 ms simulated apply.
## 1000 TPS
| Metric | Original overlay-v2-shared |Changes |
|---|---:|---:|
| Median block interval | 2.143 s | 1.995 s |
| p99 block interval | 4.244 s | 2.189 s |
| Maximum block interval | 4.399 s | 2.889 s |
| Harness verdict | **FAIL** | **PASS** |
## 2000 TPS
| Metric | Original overlay-v2-shared |Changes |
|---|---:|---:|
| Median block interval | 4.735 s | 3.803 s |
| p99 block interval | 8.131 s | 5.420 s |
| Maximum block interval | 8.117 s | 5.930 s |
| Harness verdict | **FAIL** | **FAIL** |
These changes did have an impact on median latency, but most
importantly, we are much more stable under load with more bounded
extremes.
Note that the diff is large because I had to self vendor a dependency.
The low-level QUIC features aren't configurable based on the wrapper
that libp2p exposes. It's unfortunate, QUIC supports the features, the
libraries that libp2p uses under the hood support the features, but
libp2p itself doesn't pass the args forward. The hack is to self-vendor
a patched libp2p. Not a great prod solution, but I don't really care for
this feature branch, and the features made a very meaningful impact.
# Checklist
- [x] Reviewed the
[contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#opening-a-pull-request)
document
- [x] Rebased on top of master (no merge commits)
- [x] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio
extension)
- [x] Compiles
- [x] Ran all tests
- [ ] If change impacts performance, include supporting evidence per the
[performance
document](https://github.com/stellar/stellar-core/blob/master/performance-eval/performance-eval.md)151 files changed
Lines changed: 30626 additions & 1010 deletions
File tree
- .github/workflows
- docs
- rust-overlay
- overlay
- src
- flood
- ipc
- libp2p_overlay
- vendor
- libp2p-core
- src
- generated
- muxing
- transport
- upgrade
- tests
- libp2p-quic
- src
- connection
- provider
- tests
- libp2p-swarm
- benches
- src
- behaviour
- connection
- pool
- handler
- tests
- ui/fail
- multistream-select
- src
- tests
- src
- herder
- test
- overlay/test
- scp
- test
- simulation
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
This file was deleted.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
5 | 13 | | |
6 | 14 | | |
7 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | | - | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
110 | | - | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
114 | 118 | | |
115 | | - | |
| 119 | + | |
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
| |||
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
128 | 121 | | |
129 | 122 | | |
130 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
| |||
159 | 158 | | |
160 | 159 | | |
161 | 160 | | |
162 | | - | |
163 | | - | |
| 161 | + | |
| 162 | + | |
164 | 163 | | |
165 | 164 | | |
166 | 165 | | |
0 commit comments