Commit 43f7936
[SPARK-53446][CORE] Optimize BlockManager remove operations with cached block mappings
### What changes were proposed in this pull request?
Continue #52210.
Introduced three concurrent hash maps to track block ID associations for optimize BlockManager remove operations by introducing cached mappings to eliminate O(n) linear scans.
### Why are the changes needed?
Previously, removeRdd(), removeBroadcast(), and removeCache() required scanning all blocks in blockInfoManager.entries to find matches. This approach becomes a serious bottleneck when:
1. Large block counts: In production deployments with millions or even tens of millions of cached blocks, linear scans can be prohibitively slow
2. High cleanup frequency: Workloads that repeatedly create and discard RDDs or broadcast variables accumulate overhead quickly
The original removeRdd() method already contained a TODO noting that an additional mapping would be needed to avoid linear scans. This PR implements that improvement.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
New UT.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #52646 from zml1206/SPARK-53446.
Authored-by: zml1206 <zhuml1206@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>1 parent 8446b6d commit 43f7936
File tree
3 files changed
+116
-8
lines changed- core/src
- main/scala/org/apache/spark/storage
- test/scala/org/apache/spark/storage
3 files changed
+116
-8
lines changedLines changed: 91 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
152 | 160 | | |
153 | 161 | | |
154 | 162 | | |
| |||
445 | 453 | | |
446 | 454 | | |
447 | 455 | | |
| 456 | + | |
448 | 457 | | |
449 | 458 | | |
450 | 459 | | |
| |||
535 | 544 | | |
536 | 545 | | |
537 | 546 | | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
538 | 564 | | |
539 | 565 | | |
540 | 566 | | |
| |||
551 | 577 | | |
552 | 578 | | |
553 | 579 | | |
| 580 | + | |
554 | 581 | | |
555 | 582 | | |
556 | 583 | | |
| |||
573 | 600 | | |
574 | 601 | | |
575 | 602 | | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
576 | 606 | | |
577 | 607 | | |
578 | 608 | | |
579 | 609 | | |
580 | 610 | | |
581 | 611 | | |
582 | 612 | | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
583 | 674 | | |
Lines changed: 3 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2054 | 2054 | | |
2055 | 2055 | | |
2056 | 2056 | | |
2057 | | - | |
2058 | 2057 | | |
2059 | | - | |
| 2058 | + | |
2060 | 2059 | | |
2061 | 2060 | | |
2062 | 2061 | | |
| |||
2090 | 2089 | | |
2091 | 2090 | | |
2092 | 2091 | | |
2093 | | - | |
2094 | | - | |
2095 | | - | |
| 2092 | + | |
2096 | 2093 | | |
2097 | 2094 | | |
2098 | 2095 | | |
| |||
2104 | 2101 | | |
2105 | 2102 | | |
2106 | 2103 | | |
2107 | | - | |
2108 | | - | |
2109 | | - | |
| 2104 | + | |
2110 | 2105 | | |
2111 | 2106 | | |
2112 | 2107 | | |
| |||
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2634 | 2634 | | |
2635 | 2635 | | |
2636 | 2636 | | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
2637 | 2659 | | |
2638 | 2660 | | |
2639 | 2661 | | |
| |||
0 commit comments