Commit 0b10ad8
authored
Reuse zstd compression context when writing IPC (#8405)
# Which issue does this PR close?
- Closes #8386
# Rationale for this change
Reusing the zstd context between subsequent calls to compress_zstd in
the Arrow IPC writer for performance improvement.
Benchmark results:
```
arrow_ipc_stream_writer/StreamWriter/write_10/zstd
time: [4.0972 ms 4.1038 ms 4.1110 ms]
change: [-53.848% -53.586% -53.335%] (p = 0.00 < 0.05)
Performance has improved.
```
# What changes are included in this PR?
Adds a `CompressionContext` struct, which when the zstd feature is
enabled contains a zstd::bulk::Compressor object. This context object is
owned by the ipc `StreamWriter`/`FileWriter` objects and is passed by
mutable reference through the `IpcDataGenerator` to the
`CompressionCodec` where it is used when compressing the ipc bytes.
# Are these changes tested?
Yes the existing unit tests cover the changed code paths
# Are there any user-facing changes?
Yes, the method `IpcDataGenerator::encoded_batch` now takes `&mut
CompressionContext` as an argument.1 parent 48686c8 commit 0b10ad8
File tree
7 files changed
+206
-36
lines changed- arrow-flight/src
- arrow-integration-testing/src
- flight_client_scenarios
- flight_server_scenarios
- arrow-ipc/src
7 files changed
+206
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
| 650 | + | |
650 | 651 | | |
651 | 652 | | |
652 | 653 | | |
| |||
655 | 656 | | |
656 | 657 | | |
657 | 658 | | |
| 659 | + | |
658 | 660 | | |
659 | 661 | | |
660 | 662 | | |
| |||
666 | 668 | | |
667 | 669 | | |
668 | 670 | | |
669 | | - | |
670 | | - | |
671 | | - | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
672 | 677 | | |
673 | 678 | | |
674 | 679 | | |
| |||
1596 | 1601 | | |
1597 | 1602 | | |
1598 | 1603 | | |
| 1604 | + | |
1599 | 1605 | | |
1600 | 1606 | | |
1601 | | - | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
1602 | 1613 | | |
1603 | 1614 | | |
1604 | 1615 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
94 | 96 | | |
95 | 97 | | |
96 | | - | |
97 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
| |||
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
| 98 | + | |
| 99 | + | |
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
| |||
101 | 106 | | |
102 | 107 | | |
103 | 108 | | |
| 109 | + | |
104 | 110 | | |
105 | 111 | | |
106 | 112 | | |
| |||
123 | 129 | | |
124 | 130 | | |
125 | 131 | | |
| 132 | + | |
126 | 133 | | |
127 | 134 | | |
128 | 135 | | |
| |||
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
| 162 | + | |
155 | 163 | | |
156 | 164 | | |
157 | 165 | | |
158 | 166 | | |
159 | | - | |
| 167 | + | |
160 | 168 | | |
161 | 169 | | |
162 | 170 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
148 | 153 | | |
149 | 154 | | |
150 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
25 | 60 | | |
26 | 61 | | |
27 | 62 | | |
| |||
58 | 93 | | |
59 | 94 | | |
60 | 95 | | |
| 96 | + | |
61 | 97 | | |
62 | 98 | | |
63 | 99 | | |
| |||
67 | 103 | | |
68 | 104 | | |
69 | 105 | | |
70 | | - | |
| 106 | + | |
71 | 107 | | |
72 | 108 | | |
73 | 109 | | |
| |||
115 | 151 | | |
116 | 152 | | |
117 | 153 | | |
118 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
119 | 160 | | |
120 | 161 | | |
121 | | - | |
| 162 | + | |
122 | 163 | | |
123 | 164 | | |
124 | 165 | | |
| |||
175 | 216 | | |
176 | 217 | | |
177 | 218 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
183 | 226 | | |
184 | 227 | | |
185 | 228 | | |
186 | 229 | | |
187 | 230 | | |
188 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
189 | 236 | | |
190 | 237 | | |
191 | 238 | | |
| |||
227 | 274 | | |
228 | 275 | | |
229 | 276 | | |
230 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
231 | 280 | | |
232 | 281 | | |
233 | 282 | | |
| |||
240 | 289 | | |
241 | 290 | | |
242 | 291 | | |
243 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
244 | 295 | | |
245 | 296 | | |
246 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2702 | 2702 | | |
2703 | 2703 | | |
2704 | 2704 | | |
2705 | | - | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
2706 | 2711 | | |
2707 | 2712 | | |
2708 | 2713 | | |
| |||
2740 | 2745 | | |
2741 | 2746 | | |
2742 | 2747 | | |
2743 | | - | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
2744 | 2754 | | |
2745 | 2755 | | |
2746 | 2756 | | |
| |||
0 commit comments