Commit 86f6eb6
committed
perf: reduce GC pressure in protobuf serialization
Replace ByteArrayOutputStream with direct CodedOutputStream serialization
to eliminate unnecessary allocations during query plan serialization.
This optimization:
- Pre-allocates exact buffer size using getSerializedSize()
- Eliminates ByteArrayOutputStream's internal buffer resizing
- Removes defensive array copying from toByteArray()
- Applies to 5 hot paths called per-partition during query execution
For a query with 1000 partitions, this eliminates 5000+ unnecessary
allocations and array copies, significantly reducing GC pressure.
Changes:
- operators.scala: getCometIterator() and convertBlock()
- CometNativeWriteExec.scala: serializedPlanOpt() and doExecute()
- ParquetFilters.scala: createNativeFilters()1 parent 313a9d9 commit 86f6eb6
File tree
3 files changed
+33
-20
lines changed- spark/src/main/scala/org/apache
- comet/parquet
- spark/sql/comet
3 files changed
+33
-20
lines changedLines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
885 | 887 | | |
886 | 888 | | |
887 | 889 | | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
892 | 896 | | |
893 | 897 | | |
894 | 898 | | |
| |||
Lines changed: 13 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
| |||
196 | 200 | | |
197 | 201 | | |
198 | 202 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
| |||
Lines changed: 12 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
| |||
414 | 416 | | |
415 | 417 | | |
416 | 418 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
421 | 425 | | |
422 | 426 | | |
423 | 427 | | |
| |||
0 commit comments