Commit 4312232
authored
[env](compiler)Optimize the compilation time of aggregate_function_orthogonal_bitmap.cpp (#61606)
### What problem does this PR solve?
Optimize the compilation time of
`aggregate_function_orthogonal_bitmap.cpp` by reducing template
instantiation bloat and improving build parallelism.
### Changes
**1. Split single translation unit into multiple files**
The original `aggregate_function_orthogonal_bitmap.cpp` instantiated all
6 aggregate functions (~36 template instances) in a single file, forcing
serial compilation. Now split into:
- `aggregate_function_orthogonal_bitmap.cpp` — forward declarations +
registration only (compiles fast)
- `aggregate_function_orth_bitmap_intersect.cpp`
- `aggregate_function_orth_bitmap_intersect_count.cpp`
- `aggregate_function_orth_bitmap_union_count.cpp`
- `aggregate_function_orth_intersect_count.cpp`
- `aggregate_function_orth_bitmap_expr_cal.cpp`
- `aggregate_function_orth_bitmap_expr_cal_count.cpp`
**2. Remove unnecessary `PrimitiveType` template parameter from
`OrthBitmapUnionCountData`**
`OrthBitmapUnionCountData<T>` never uses `T` — it only operates on
`ColumnBitmap` directly. Removed the template parameter, reducing 6
useless instantiations to 1.
**3. Eliminate type dispatch for `ExprCal` / `ExprCalCount`**
FE guarantees these functions receive exactly 3 parameters with VARCHAR
filter columns. Replaced the generic 6-type dispatch with direct
`TYPE_STRING` instantiation, reducing 12 instantiations to 2.
**4. Use precise expression tags matching FE definitions**
Added `ExprTag` template parameter to `AggFunctionOrthBitmapFunc`
(default: `VarargsExpression`):
| Function | FE Arity | Old BE Tag | New BE Tag |
|----------|----------|------------|------------|
| `orthogonal_bitmap_union_count` | `UnaryExpression` (1 arg) |
`VarargsExpression` | `UnaryExpression` |
| `orthogonal_bitmap_expr_calculate` | Fixed 3 args |
`VarargsExpression` | `MultiExpression` |
| `orthogonal_bitmap_expr_calculate_count` | Fixed 3 args |
`VarargsExpression` | `MultiExpression` |
| Others (intersect/intersect_count) | Varargs (≥3) |
`VarargsExpression` | `VarargsExpression` (unchanged) |
**5. Add `inline` to template specializations in `bitmap_intersect.h`**
The `Helper::write_to` / `serialize_size` / `read_from` template
specializations in the header lacked `inline`, causing duplicate symbol
linker errors after splitting into multiple translation units.
### Summary
| Metric | Before | After |
|--------|--------|-------|
| Translation units | 1 (serial) | 7 (parallel) |
| Template instantiations | ~36 | ~21 (~42% reduction) |
| `ExprCal`/`ExprCalCount` instantiations | 12 | 2 |
| `OrthBitmapUnionCountData` instantiations | 6 | 1 |1 parent 0a4f3a9 commit 4312232
10 files changed
Lines changed: 312 additions & 65 deletions
File tree
- be/src
- exprs/aggregate
- util
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
Lines changed: 30 additions & 48 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 18 | + | |
22 | 19 | | |
23 | 20 | | |
24 | | - | |
| 21 | + | |
25 | 22 | | |
26 | | - | |
27 | 23 | | |
28 | 24 | | |
29 | 25 | | |
30 | | - | |
31 | | - | |
32 | 26 | | |
33 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
34 | 30 | | |
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 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
60 | 34 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
67 | 50 | | |
68 | 51 | | |
69 | 52 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
74 | 56 | | |
75 | | - | |
| 57 | + | |
76 | 58 | | |
77 | | - | |
| 59 | + | |
78 | 60 | | |
79 | | - | |
| 61 | + | |
80 | 62 | | |
81 | | - | |
| 63 | + | |
82 | 64 | | |
83 | 65 | | |
84 | 66 | | |
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
340 | 339 | | |
341 | 340 | | |
342 | 341 | | |
| |||
373 | 372 | | |
374 | 373 | | |
375 | 374 | | |
376 | | - | |
| 375 | + | |
377 | 376 | | |
378 | | - | |
379 | | - | |
| 377 | + | |
| 378 | + | |
380 | 379 | | |
381 | 380 | | |
382 | 381 | | |
383 | 382 | | |
384 | 383 | | |
385 | | - | |
| 384 | + | |
| 385 | + | |
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| |||
0 commit comments