Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Cache significant segments computations for layouts in physical promotion #87745

Merged

Conversation

jakobbotsch
Copy link
Member

Also removes the fixed bit vector debug checking code as I felt it had served its purpose and I didn't want to further complicate the caching.

This should save a lot of JIT-EE calls from physical promotion.

 JitEnablePhysicalPromotion=1
 benchmarks.run_pgo:
-Total num SignificantSegments calls: 2543
+Total num SignificantSegments calls: 915
 (Per context) SignificantSegments calls
      <=          0 ===>       0 count (  0% of total)
-      1 ..       1 ===>     312 count ( 37% of total)
-      2 ..       2 ===>      58 count ( 44% of total)
-      3 ..       3 ===>     181 count ( 66% of total)
-      4 ..       5 ===>     191 count ( 90% of total)
-      6 ..      10 ===>      66 count ( 98% of total)
-     11 ..      20 ===>      12 count ( 99% of total)
-     21 ..      35 ===>       4 count (100% of total)
+      1 ..       1 ===>     741 count ( 89% of total)
+      2 ..       2 ===>      75 count ( 99% of total)
+      3 ..       3 ===>       8 count (100% of total)
+      4 ..       5 ===>       0 count (100% of total)
+      6 ..      10 ===>       0 count (100% of total)
+     11 ..      20 ===>       0 count (100% of total)
+     21 ..      35 ===>       0 count (100% of total)
      36 ..      50 ===>       0 count (100% of total)
      51 ..      75 ===>       0 count (100% of total)
      76 ..     100 ===>       0 count (100% of total)
@@ -19,19 +19,19 @@ Total num SignificantSegments calls: 2543
     501 ..    1000 ===>       0 count (100% of total)
 
 libraries.pmi:
-Total num SignificantSegments calls: 28525
+Total num SignificantSegments calls: 9061
 (Per context) SignificantSegments calls
      <=          0 ===>       0 count (  0% of total)
-      1 ..       1 ===>    1154 count ( 19% of total)
-      2 ..       2 ===>    1878 count ( 50% of total)
-      3 ..       3 ===>     809 count ( 64% of total)
-      4 ..       5 ===>     782 count ( 77% of total)
-      6 ..      10 ===>     831 count ( 91% of total)
-     11 ..      20 ===>     357 count ( 97% of total)
-     21 ..      35 ===>     101 count ( 98% of total)
-     36 ..      50 ===>      29 count ( 99% of total)
-     51 ..      75 ===>      29 count ( 99% of total)
-     76 ..     100 ===>       8 count (100% of total)
+      1 ..       1 ===>    4172 count ( 69% of total)
+      2 ..       2 ===>    1105 count ( 88% of total)
+      3 ..       3 ===>     416 count ( 95% of total)
+      4 ..       5 ===>     214 count ( 98% of total)
+      6 ..      10 ===>      67 count ( 99% of total)
+     11 ..      20 ===>       3 count ( 99% of total)
+     21 ..      35 ===>       1 count (100% of total)
+     36 ..      50 ===>       0 count (100% of total)
+     51 ..      75 ===>       0 count (100% of total)
+     76 ..     100 ===>       0 count (100% of total)
     101 ..     150 ===>       0 count (100% of total)
     151 ..     250 ===>       0 count (100% of total)
     251 ..     500 ===>       0 count (100% of total)
@@ -39,39 +39,39 @@ Total num SignificantSegments calls: 28525
 
 JitEnablePhysicalPromotion=1;JitStressModeNames=STRESS_NO_OLD_PROMOTION
 benchmarks.run_pgo:
-Total num SignificantSegments calls: 90839
+Total num SignificantSegments calls: 15082
 (Per context) SignificantSegments calls
      <=          0 ===>       0 count (  0% of total)
-      1 ..       1 ===>     681 count (  7% of total)
-      2 ..       2 ===>    1035 count ( 17% of total)
-      3 ..       3 ===>    1635 count ( 34% of total)
-      4 ..       5 ===>    1053 count ( 45% of total)
-      6 ..      10 ===>    3162 count ( 78% of total)
-     11 ..      20 ===>     814 count ( 87% of total)
-     21 ..      35 ===>     931 count ( 96% of total)
-     36 ..      50 ===>     215 count ( 99% of total)
-     51 ..      75 ===>      69 count ( 99% of total)
-     76 ..     100 ===>       4 count ( 99% of total)
-    101 ..     150 ===>       4 count ( 99% of total)
-    151 ..     250 ===>       0 count ( 99% of total)
-    251 ..     500 ===>      11 count (100% of total)
+      1 ..       1 ===>    6709 count ( 69% of total)
+      2 ..       2 ===>    1735 count ( 87% of total)
+      3 ..       3 ===>     462 count ( 92% of total)
+      4 ..       5 ===>     471 count ( 97% of total)
+      6 ..      10 ===>     237 count (100% of total)
+     11 ..      20 ===>       0 count (100% of total)
+     21 ..      35 ===>       0 count (100% of total)
+     36 ..      50 ===>       0 count (100% of total)
+     51 ..      75 ===>       0 count (100% of total)
+     76 ..     100 ===>       0 count (100% of total)
+    101 ..     150 ===>       0 count (100% of total)
+    151 ..     250 ===>       0 count (100% of total)
+    251 ..     500 ===>       0 count (100% of total)
     501 ..    1000 ===>       0 count (100% of total)
 
 libraries.pmi:
-Total num SignificantSegments calls: 277708
+Total num SignificantSegments calls: 68938
 (Per context) SignificantSegments calls
      <=          0 ===>       0 count (  0% of total)
-      1 ..       1 ===>    6993 count ( 17% of total)
-      2 ..       2 ===>    8197 count ( 38% of total)
-      3 ..       3 ===>    5225 count ( 51% of total)
-      4 ..       5 ===>    5380 count ( 65% of total)
-      6 ..      10 ===>    7141 count ( 83% of total)
-     11 ..      20 ===>    4094 count ( 93% of total)
-     21 ..      35 ===>    1627 count ( 97% of total)
-     36 ..      50 ===>     519 count ( 98% of total)
-     51 ..      75 ===>     292 count ( 99% of total)
-     76 ..     100 ===>      98 count ( 99% of total)
-    101 ..     150 ===>      59 count ( 99% of total)
-    151 ..     250 ===>      11 count ( 99% of total)
-    251 ..     500 ===>       4 count (100% of total)
+      1 ..       1 ===>   24323 count ( 61% of total)
+      2 ..       2 ===>    8687 count ( 83% of total)
+      3 ..       3 ===>    3357 count ( 91% of total)
+      4 ..       5 ===>    2378 count ( 97% of total)
+      6 ..      10 ===>     789 count ( 99% of total)
+     11 ..      20 ===>     105 count ( 99% of total)
+     21 ..      35 ===>       1 count (100% of total)
+     36 ..      50 ===>       0 count (100% of total)
+     51 ..      75 ===>       0 count (100% of total)
+     76 ..     100 ===>       0 count (100% of total)
+    101 ..     150 ===>       0 count (100% of total)
+    151 ..     250 ===>       0 count (100% of total)
+    251 ..     500 ===>       0 count (100% of total)
     501 ..    1000 ===>       0 count (100% of total)

…promotion

Before:
JitEnablePhysicalPromotion=1
benchmarks.run_pgo:
Total num SignificantSegments calls: 2543
(Per context) SignificantSegments calls
     <=          0 ===>       0 count (  0% of total)
      1 ..       1 ===>     312 count ( 37% of total)
      2 ..       2 ===>      58 count ( 44% of total)
      3 ..       3 ===>     181 count ( 66% of total)
      4 ..       5 ===>     191 count ( 90% of total)
      6 ..      10 ===>      66 count ( 98% of total)
     11 ..      20 ===>      12 count ( 99% of total)
     21 ..      35 ===>       4 count (100% of total)
     36 ..      50 ===>       0 count (100% of total)
     51 ..      75 ===>       0 count (100% of total)
     76 ..     100 ===>       0 count (100% of total)
    101 ..     150 ===>       0 count (100% of total)
    151 ..     250 ===>       0 count (100% of total)
    251 ..     500 ===>       0 count (100% of total)
    501 ..    1000 ===>       0 count (100% of total)

libraries.pmi:
Total num SignificantSegments calls: 28525
(Per context) SignificantSegments calls
     <=          0 ===>       0 count (  0% of total)
      1 ..       1 ===>    1154 count ( 19% of total)
      2 ..       2 ===>    1878 count ( 50% of total)
      3 ..       3 ===>     809 count ( 64% of total)
      4 ..       5 ===>     782 count ( 77% of total)
      6 ..      10 ===>     831 count ( 91% of total)
     11 ..      20 ===>     357 count ( 97% of total)
     21 ..      35 ===>     101 count ( 98% of total)
     36 ..      50 ===>      29 count ( 99% of total)
     51 ..      75 ===>      29 count ( 99% of total)
     76 ..     100 ===>       8 count (100% of total)
    101 ..     150 ===>       0 count (100% of total)
    151 ..     250 ===>       0 count (100% of total)
    251 ..     500 ===>       0 count (100% of total)
    501 ..    1000 ===>       0 count (100% of total)

JitEnablePhysicalPromotion=1;JitStressModeNames=STRESS_NO_OLD_PROMOTION
benchmarks.run_pgo:
Total num SignificantSegments calls: 90839
(Per context) SignificantSegments calls
     <=          0 ===>       0 count (  0% of total)
      1 ..       1 ===>     681 count (  7% of total)
      2 ..       2 ===>    1035 count ( 17% of total)
      3 ..       3 ===>    1635 count ( 34% of total)
      4 ..       5 ===>    1053 count ( 45% of total)
      6 ..      10 ===>    3162 count ( 78% of total)
     11 ..      20 ===>     814 count ( 87% of total)
     21 ..      35 ===>     931 count ( 96% of total)
     36 ..      50 ===>     215 count ( 99% of total)
     51 ..      75 ===>      69 count ( 99% of total)
     76 ..     100 ===>       4 count ( 99% of total)
    101 ..     150 ===>       4 count ( 99% of total)
    151 ..     250 ===>       0 count ( 99% of total)
    251 ..     500 ===>      11 count (100% of total)
    501 ..    1000 ===>       0 count (100% of total)

libraries.pmi:
Total num SignificantSegments calls: 277708
(Per context) SignificantSegments calls
     <=          0 ===>       0 count (  0% of total)
      1 ..       1 ===>    6993 count ( 17% of total)
      2 ..       2 ===>    8197 count ( 38% of total)
      3 ..       3 ===>    5225 count ( 51% of total)
      4 ..       5 ===>    5380 count ( 65% of total)
      6 ..      10 ===>    7141 count ( 83% of total)
     11 ..      20 ===>    4094 count ( 93% of total)
     21 ..      35 ===>    1627 count ( 97% of total)
     36 ..      50 ===>     519 count ( 98% of total)
     51 ..      75 ===>     292 count ( 99% of total)
     76 ..     100 ===>      98 count ( 99% of total)
    101 ..     150 ===>      59 count ( 99% of total)
    151 ..     250 ===>      11 count ( 99% of total)
    251 ..     500 ===>       4 count (100% of total)
    501 ..    1000 ===>       0 count (100% of total)

After:
benchmarks.run_pgo:
Total num SignificantSegments calls: 915
(Per context) SignificantSegments calls
     <=          0 ===>       0 count (  0% of total)
      1 ..       1 ===>     741 count ( 89% of total)
      2 ..       2 ===>      75 count ( 99% of total)
      3 ..       3 ===>       8 count (100% of total)
      4 ..       5 ===>       0 count (100% of total)
      6 ..      10 ===>       0 count (100% of total)
     11 ..      20 ===>       0 count (100% of total)
     21 ..      35 ===>       0 count (100% of total)
     36 ..      50 ===>       0 count (100% of total)
     51 ..      75 ===>       0 count (100% of total)
     76 ..     100 ===>       0 count (100% of total)
    101 ..     150 ===>       0 count (100% of total)
    151 ..     250 ===>       0 count (100% of total)
    251 ..     500 ===>       0 count (100% of total)
    501 ..    1000 ===>       0 count (100% of total)

libraries.pmi:
Total num SignificantSegments calls: 9061
(Per context) SignificantSegments calls
     <=          0 ===>       0 count (  0% of total)
      1 ..       1 ===>    4172 count ( 69% of total)
      2 ..       2 ===>    1105 count ( 88% of total)
      3 ..       3 ===>     416 count ( 95% of total)
      4 ..       5 ===>     214 count ( 98% of total)
      6 ..      10 ===>      67 count ( 99% of total)
     11 ..      20 ===>       3 count ( 99% of total)
     21 ..      35 ===>       1 count (100% of total)
     36 ..      50 ===>       0 count (100% of total)
     51 ..      75 ===>       0 count (100% of total)
     76 ..     100 ===>       0 count (100% of total)
    101 ..     150 ===>       0 count (100% of total)
    151 ..     250 ===>       0 count (100% of total)
    251 ..     500 ===>       0 count (100% of total)
    501 ..    1000 ===>       0 count (100% of total)

JitEnablePhysicalPromotion=1;JitStressModeNames=STRESS_NO_OLD_PROMOTION
benchmarks.run_pgo:
Total num SignificantSegments calls: 15082
(Per context) SignificantSegments calls
     <=          0 ===>       0 count (  0% of total)
      1 ..       1 ===>    6709 count ( 69% of total)
      2 ..       2 ===>    1735 count ( 87% of total)
      3 ..       3 ===>     462 count ( 92% of total)
      4 ..       5 ===>     471 count ( 97% of total)
      6 ..      10 ===>     237 count (100% of total)
     11 ..      20 ===>       0 count (100% of total)
     21 ..      35 ===>       0 count (100% of total)
     36 ..      50 ===>       0 count (100% of total)
     51 ..      75 ===>       0 count (100% of total)
     76 ..     100 ===>       0 count (100% of total)
    101 ..     150 ===>       0 count (100% of total)
    151 ..     250 ===>       0 count (100% of total)
    251 ..     500 ===>       0 count (100% of total)
    501 ..    1000 ===>       0 count (100% of total)

libraries.pmi:
Total uncached SignificantSegments calls: 68938
(Per context) SignificantSegments calls
     <=          0 ===>       0 count (  0% of total)
      1 ..       1 ===>   24323 count ( 61% of total)
      2 ..       2 ===>    8687 count ( 83% of total)
      3 ..       3 ===>    3357 count ( 91% of total)
      4 ..       5 ===>    2378 count ( 97% of total)
      6 ..      10 ===>     789 count ( 99% of total)
     11 ..      20 ===>     105 count ( 99% of total)
     21 ..      35 ===>       1 count (100% of total)
     36 ..      50 ===>       0 count (100% of total)
     51 ..      75 ===>       0 count (100% of total)
     76 ..     100 ===>       0 count (100% of total)
    101 ..     150 ===>       0 count (100% of total)
    151 ..     250 ===>       0 count (100% of total)
    251 ..     500 ===>       0 count (100% of total)
    501 ..    1000 ===>       0 count (100% of total)
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 18, 2023
@ghost ghost assigned jakobbotsch Jun 18, 2023
@ghost
Copy link

ghost commented Jun 18, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Also removes the fixed bit vector debug checking code as I felt it had served its purpose and I didn't want to further complicate the caching.

This should save a lot of JIT-EE calls from physical promotion.

 JitEnablePhysicalPromotion=1
 benchmarks.run_pgo:
-Total num SignificantSegments calls: 2543
+Total num SignificantSegments calls: 915
 (Per context) SignificantSegments calls
      <=          0 ===>       0 count (  0% of total)
-      1 ..       1 ===>     312 count ( 37% of total)
-      2 ..       2 ===>      58 count ( 44% of total)
-      3 ..       3 ===>     181 count ( 66% of total)
-      4 ..       5 ===>     191 count ( 90% of total)
-      6 ..      10 ===>      66 count ( 98% of total)
-     11 ..      20 ===>      12 count ( 99% of total)
-     21 ..      35 ===>       4 count (100% of total)
+      1 ..       1 ===>     741 count ( 89% of total)
+      2 ..       2 ===>      75 count ( 99% of total)
+      3 ..       3 ===>       8 count (100% of total)
+      4 ..       5 ===>       0 count (100% of total)
+      6 ..      10 ===>       0 count (100% of total)
+     11 ..      20 ===>       0 count (100% of total)
+     21 ..      35 ===>       0 count (100% of total)
      36 ..      50 ===>       0 count (100% of total)
      51 ..      75 ===>       0 count (100% of total)
      76 ..     100 ===>       0 count (100% of total)
@@ -19,19 +19,19 @@ Total num SignificantSegments calls: 2543
     501 ..    1000 ===>       0 count (100% of total)
 
 libraries.pmi:
-Total num SignificantSegments calls: 28525
+Total num SignificantSegments calls: 9061
 (Per context) SignificantSegments calls
      <=          0 ===>       0 count (  0% of total)
-      1 ..       1 ===>    1154 count ( 19% of total)
-      2 ..       2 ===>    1878 count ( 50% of total)
-      3 ..       3 ===>     809 count ( 64% of total)
-      4 ..       5 ===>     782 count ( 77% of total)
-      6 ..      10 ===>     831 count ( 91% of total)
-     11 ..      20 ===>     357 count ( 97% of total)
-     21 ..      35 ===>     101 count ( 98% of total)
-     36 ..      50 ===>      29 count ( 99% of total)
-     51 ..      75 ===>      29 count ( 99% of total)
-     76 ..     100 ===>       8 count (100% of total)
+      1 ..       1 ===>    4172 count ( 69% of total)
+      2 ..       2 ===>    1105 count ( 88% of total)
+      3 ..       3 ===>     416 count ( 95% of total)
+      4 ..       5 ===>     214 count ( 98% of total)
+      6 ..      10 ===>      67 count ( 99% of total)
+     11 ..      20 ===>       3 count ( 99% of total)
+     21 ..      35 ===>       1 count (100% of total)
+     36 ..      50 ===>       0 count (100% of total)
+     51 ..      75 ===>       0 count (100% of total)
+     76 ..     100 ===>       0 count (100% of total)
     101 ..     150 ===>       0 count (100% of total)
     151 ..     250 ===>       0 count (100% of total)
     251 ..     500 ===>       0 count (100% of total)
@@ -39,39 +39,39 @@ Total num SignificantSegments calls: 28525
 
 JitEnablePhysicalPromotion=1;JitStressModeNames=STRESS_NO_OLD_PROMOTION
 benchmarks.run_pgo:
-Total num SignificantSegments calls: 90839
+Total num SignificantSegments calls: 15082
 (Per context) SignificantSegments calls
      <=          0 ===>       0 count (  0% of total)
-      1 ..       1 ===>     681 count (  7% of total)
-      2 ..       2 ===>    1035 count ( 17% of total)
-      3 ..       3 ===>    1635 count ( 34% of total)
-      4 ..       5 ===>    1053 count ( 45% of total)
-      6 ..      10 ===>    3162 count ( 78% of total)
-     11 ..      20 ===>     814 count ( 87% of total)
-     21 ..      35 ===>     931 count ( 96% of total)
-     36 ..      50 ===>     215 count ( 99% of total)
-     51 ..      75 ===>      69 count ( 99% of total)
-     76 ..     100 ===>       4 count ( 99% of total)
-    101 ..     150 ===>       4 count ( 99% of total)
-    151 ..     250 ===>       0 count ( 99% of total)
-    251 ..     500 ===>      11 count (100% of total)
+      1 ..       1 ===>    6709 count ( 69% of total)
+      2 ..       2 ===>    1735 count ( 87% of total)
+      3 ..       3 ===>     462 count ( 92% of total)
+      4 ..       5 ===>     471 count ( 97% of total)
+      6 ..      10 ===>     237 count (100% of total)
+     11 ..      20 ===>       0 count (100% of total)
+     21 ..      35 ===>       0 count (100% of total)
+     36 ..      50 ===>       0 count (100% of total)
+     51 ..      75 ===>       0 count (100% of total)
+     76 ..     100 ===>       0 count (100% of total)
+    101 ..     150 ===>       0 count (100% of total)
+    151 ..     250 ===>       0 count (100% of total)
+    251 ..     500 ===>       0 count (100% of total)
     501 ..    1000 ===>       0 count (100% of total)
 
 libraries.pmi:
-Total num SignificantSegments calls: 277708
+Total num SignificantSegments calls: 68938
 (Per context) SignificantSegments calls
      <=          0 ===>       0 count (  0% of total)
-      1 ..       1 ===>    6993 count ( 17% of total)
-      2 ..       2 ===>    8197 count ( 38% of total)
-      3 ..       3 ===>    5225 count ( 51% of total)
-      4 ..       5 ===>    5380 count ( 65% of total)
-      6 ..      10 ===>    7141 count ( 83% of total)
-     11 ..      20 ===>    4094 count ( 93% of total)
-     21 ..      35 ===>    1627 count ( 97% of total)
-     36 ..      50 ===>     519 count ( 98% of total)
-     51 ..      75 ===>     292 count ( 99% of total)
-     76 ..     100 ===>      98 count ( 99% of total)
-    101 ..     150 ===>      59 count ( 99% of total)
-    151 ..     250 ===>      11 count ( 99% of total)
-    251 ..     500 ===>       4 count (100% of total)
+      1 ..       1 ===>   24323 count ( 61% of total)
+      2 ..       2 ===>    8687 count ( 83% of total)
+      3 ..       3 ===>    3357 count ( 91% of total)
+      4 ..       5 ===>    2378 count ( 97% of total)
+      6 ..      10 ===>     789 count ( 99% of total)
+     11 ..      20 ===>     105 count ( 99% of total)
+     21 ..      35 ===>       1 count (100% of total)
+     36 ..      50 ===>       0 count (100% of total)
+     51 ..      75 ===>       0 count (100% of total)
+     76 ..     100 ===>       0 count (100% of total)
+    101 ..     150 ===>       0 count (100% of total)
+    151 ..     250 ===>       0 count (100% of total)
+    251 ..     500 ===>       0 count (100% of total)
     501 ..    1000 ===>       0 count (100% of total)
Author: jakobbotsch
Assignees: jakobbotsch
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @EgorBo

@jakobbotsch jakobbotsch requested a review from EgorBo June 19, 2023 09:34
@jakobbotsch jakobbotsch merged commit e834d42 into dotnet:main Jun 19, 2023
@jakobbotsch jakobbotsch deleted the physical-promotion-cache-StructSegments branch June 19, 2023 20:30
@ghost ghost locked as resolved and limited conversation to collaborators Jul 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants