Commit 136ad9a
authored
### Rationale for this change
#45551 describes the basic idea. Some profiling from real cases follows.
Take https://github.com/apache/arrow/blob/a53a77c93217399c4fda8c6328db2c492a30b0b0/cpp/src/arrow/acero/hash_join_node_test.cc#L3368 and print the memory pool stats at the end.
Before this change:
```
heap stats: peak total freed current unit count
reserved: 22.6 GiB 30.3 GiB 8.5 GiB 21.8 GiB not all freed!
committed: 22.9 GiB 30.6 GiB 8.4 GiB 22.1 GiB not all freed!
```
After this change:
```
heap stats: peak total freed current unit count
reserved: 17.5 GiB 30.3 GiB 16.0 GiB 14.3 GiB not all freed!
committed: 17.8 GiB 30.5 GiB 15.8 GiB 14.7 GiB not all freed!
```
The peak memory is reduced from `22.9GB` to `17.8GB`. Though the reduction is really case-by-case, IMO this could be considered a good improvement for most general cases at zero cost.
### What changes are included in this PR?
Make `hash_table_build_`, which only holds temporary states for building the final hash table, transient. And release it (via pointer) as early as possible.
### Are these changes tested?
Existing tests should suffice.
### Are there any user-facing changes?
None. Except that the user will see good reduction on peak memory usage :)
* GitHub Issue: #45551
Authored-by: Rossi Sun <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
1 parent a53a77c commit 136ad9a
1 file changed
+18
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2590 | 2590 | | |
2591 | 2591 | | |
2592 | 2592 | | |
2593 | | - | |
| 2593 | + | |
| 2594 | + | |
2594 | 2595 | | |
2595 | 2596 | | |
2596 | 2597 | | |
| |||
2609 | 2610 | | |
2610 | 2611 | | |
2611 | 2612 | | |
2612 | | - | |
| 2613 | + | |
| 2614 | + | |
2613 | 2615 | | |
2614 | 2616 | | |
2615 | 2617 | | |
| |||
2639 | 2641 | | |
2640 | 2642 | | |
2641 | 2643 | | |
2642 | | - | |
| 2644 | + | |
| 2645 | + | |
2643 | 2646 | | |
2644 | 2647 | | |
2645 | 2648 | | |
| |||
2654 | 2657 | | |
2655 | 2658 | | |
2656 | 2659 | | |
2657 | | - | |
| 2660 | + | |
| 2661 | + | |
2658 | 2662 | | |
2659 | | - | |
| 2663 | + | |
2660 | 2664 | | |
2661 | 2665 | | |
2662 | 2666 | | |
2663 | 2667 | | |
2664 | 2668 | | |
2665 | 2669 | | |
2666 | | - | |
| 2670 | + | |
| 2671 | + | |
2667 | 2672 | | |
2668 | 2673 | | |
2669 | 2674 | | |
2670 | 2675 | | |
2671 | 2676 | | |
2672 | 2677 | | |
2673 | | - | |
| 2678 | + | |
| 2679 | + | |
2674 | 2680 | | |
2675 | 2681 | | |
2676 | 2682 | | |
| |||
2679 | 2685 | | |
2680 | 2686 | | |
2681 | 2687 | | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
2682 | 2691 | | |
2683 | 2692 | | |
2684 | 2693 | | |
| |||
2910 | 2919 | | |
2911 | 2920 | | |
2912 | 2921 | | |
2913 | | - | |
| 2922 | + | |
| 2923 | + | |
2914 | 2924 | | |
2915 | 2925 | | |
2916 | 2926 | | |
| |||
0 commit comments