Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
Commitc012c8a
authored
This implements the delayed reuse of mimalloc pages that contain Pythonobjects in the free-threaded build.Allocations of the same size class are grouped in data structures calledpages. These are different from operating system pages. For thread-safety, wewant to ensure that memory used to store PyObjects remains valid as long asthere may be concurrent lock-free readers; we want to delay using it forother size classes, in other heaps, or returning it to the operating system.When a mimalloc page becomes empty, instead of immediately freeing it, we tagit with a QSBR goal and insert it into a per-thread state linked list ofpages to be freed. When mimalloc needs a fresh page, we process the queue andfree any still empty pages that are now deemed safe to be freed. Pageswaiting to be freed are still available for allocations of the same sizeclass and allocating from a page prevent it from being freed. There isadditional logic to handle abandoned pages when threads exit.
1 parent02ee475 commitc012c8a
File tree
9 files changed
+199
-17
lines changed- Include/internal
- mimalloc/mimalloc
- Objects
- mimalloc
- Python
9 files changed
+199
-17
lines changedLines changed: 8 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
311 | 311 |
| |
312 | 312 |
| |
313 | 313 |
| |
| 314 | + | |
314 | 315 |
| |
315 | 316 |
| |
316 | 317 |
| |
| |||
336 | 337 |
| |
337 | 338 |
| |
338 | 339 |
| |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
339 | 345 |
| |
340 |
| - | |
| 346 | + | |
341 | 347 |
| |
342 | 348 |
| |
343 | 349 |
| |
| |||
555 | 561 |
| |
556 | 562 |
| |
557 | 563 |
| |
| 564 | + | |
558 | 565 |
| |
559 | 566 |
| |
560 | 567 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
| 51 | + | |
51 | 52 |
| |
52 | 53 |
| |
53 | 54 |
| |
|
Lines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
32 | 38 |
| |
33 | 39 |
| |
34 | 40 |
| |
| |||
89 | 95 |
| |
90 | 96 |
| |
91 | 97 |
| |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
92 | 107 |
| |
93 | 108 |
| |
94 | 109 |
| |
|
Lines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
98 | 98 |
| |
99 | 99 |
| |
100 | 100 |
| |
101 |
| - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
102 | 105 |
| |
103 | 106 |
| |
104 | 107 |
| |
| |||
153 | 156 |
| |
154 | 157 |
| |
155 | 158 |
| |
| 159 | + | |
| 160 | + | |
| 161 | + | |
156 | 162 |
| |
157 | 163 |
| |
158 | 164 |
| |
|
Lines changed: 33 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
225 | 225 |
| |
226 | 226 |
| |
227 | 227 |
| |
| 228 | + | |
| 229 | + | |
| 230 | + | |
228 | 231 |
| |
229 | 232 |
| |
230 | 233 |
| |
| |||
267 | 270 |
| |
268 | 271 |
| |
269 | 272 |
| |
| 273 | + | |
270 | 274 |
| |
271 | 275 |
| |
272 | 276 |
| |
| |||
383 | 387 |
| |
384 | 388 |
| |
385 | 389 |
| |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
386 | 397 |
| |
387 | 398 |
| |
388 | 399 |
| |
| |||
417 | 428 |
| |
418 | 429 |
| |
419 | 430 |
| |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
420 | 436 |
| |
421 | 437 |
| |
422 | 438 |
| |
| |||
444 | 460 |
| |
445 | 461 |
| |
446 | 462 |
| |
| 463 | + | |
| 464 | + | |
| 465 | + | |
447 | 466 |
| |
448 | 467 |
| |
449 | 468 |
| |
| |||
465 | 484 |
| |
466 | 485 |
| |
467 | 486 |
| |
468 |
| - | |
| 487 | + | |
469 | 488 |
| |
470 | 489 |
| |
471 | 490 |
| |
| |||
480 | 499 |
| |
481 | 500 |
| |
482 | 501 |
| |
483 |
| - | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
484 | 506 |
| |
485 | 507 |
| |
486 | 508 |
| |
| |||
661 | 683 |
| |
662 | 684 |
| |
663 | 685 |
| |
| 686 | + | |
664 | 687 |
| |
665 | 688 |
| |
666 | 689 |
| |
| |||
691 | 714 |
| |
692 | 715 |
| |
693 | 716 |
| |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
694 | 721 |
| |
695 | 722 |
| |
696 | 723 |
| |
| |||
750 | 777 |
| |
751 | 778 |
| |
752 | 779 |
| |
| 780 | + | |
753 | 781 |
| |
754 | 782 |
| |
755 | 783 |
| |
| |||
760 | 788 |
| |
761 | 789 |
| |
762 | 790 |
| |
| 791 | + | |
763 | 792 |
| |
764 | 793 |
| |
765 | 794 |
| |
| |||
785 | 814 |
| |
786 | 815 |
| |
787 | 816 |
| |
| 817 | + | |
788 | 818 |
| |
789 | 819 |
| |
790 | 820 |
| |
| |||
878 | 908 |
| |
879 | 909 |
| |
880 | 910 |
| |
| 911 | + | |
881 | 912 |
| |
882 | 913 |
| |
883 | 914 |
| |
|
Lines changed: 13 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
982 | 982 |
| |
983 | 983 |
| |
984 | 984 |
| |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
985 | 989 |
| |
986 | 990 |
| |
987 | 991 |
| |
| |||
1270 | 1274 |
| |
1271 | 1275 |
| |
1272 | 1276 |
| |
1273 |
| - | |
| 1277 | + | |
1274 | 1278 |
| |
1275 | 1279 |
| |
1276 | 1280 |
| |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
1277 | 1284 |
| |
1278 | 1285 |
| |
1279 | 1286 |
| |
| |||
1344 | 1351 |
| |
1345 | 1352 |
| |
1346 | 1353 |
| |
1347 |
| - | |
| 1354 | + | |
1348 | 1355 |
| |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
1349 | 1359 |
| |
1350 | 1360 |
| |
1351 | 1361 |
| |
1352 | 1362 |
| |
1353 | 1363 |
| |
1354 | 1364 |
| |
1355 |
| - | |
| 1365 | + | |
1356 | 1366 |
| |
1357 | 1367 |
| |
1358 | 1368 |
| |
|
Lines changed: 113 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
15 | 21 |
| |
16 | 22 |
| |
17 | 23 |
| |
| |||
86 | 92 |
| |
87 | 93 |
| |
88 | 94 |
| |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
89 | 202 |
| |
90 | 203 |
| |
91 | 204 |
| |
|
0 commit comments
Comments
(0)