Commit 093221a
Fine. Use library manifest handles; discard instances to save memory
Replace in-memory `LibraryManifest` objects with lightweight
`LibraryManifestHandle`s that carry a requirements hash and (optionally)
serialized bytes. Handles defer deserialization, can discard the live
instance, and rehydrate on demand. This reduces heap usage without
sacrificing correctness.
Key changes:
- Introduce `LibraryManifestHandle` with `hashForRequirements`, lazy
`instance` materialization, and `discardInstance()`.
- Persist and load handles in the linked bundle cache entry; cache now
stores the manifest hash + bytes instead of full objects.
- Change `LibraryElementImpl.manifest` to `LibraryManifestHandle?` and
update call sites to use `.instance` or `.hashForRequirements` as
appropriate.
- Update `BundleReader`, `LibraryContext`, and manifest builder to pass
and produce handles; builder emits handles via
`LibraryManifestHandle.fromInstance(...)`.
- Add `LinkedElementFactory.discardLibraryManifestInstances()` and call
it from the scheduler when idle (with fine dependencies enabled) to
aggressively free manifest instances.
- Bump `AnalysisDriver.DATA_VERSION` from 567 to 568 to invalidate old
cached entries that used plain manifests.
Impact:
- Peak memory drops from ~785 MB to ~652 MB (−133 MB, −17.0%) with
fine-grained dependencies enabled.
- Compared to the ~512 MB baseline without fine-grained dependencies,
the new peak is +140 MB (+27.3%).
Rationale: By storing only a digest and bytes most of the time, we keep
manifests off-heap until their full contents are needed, while
preserving stable IDs and compatibility across relinks.
Change-Id: Ibbfd0159d73ecca93835b7ee447cc05ec8eefb09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452260
Reviewed-by: Paul Berry <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>1 parent 1c13cd2 commit 093221a
File tree
9 files changed
+167
-90
lines changed- pkg/analyzer
- lib/src
- dart
- analysis
- element
- fine
- summary2
- test/src/dart/analysis
9 files changed
+167
-90
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
2637 | 2637 | | |
2638 | 2638 | | |
2639 | 2639 | | |
| 2640 | + | |
| 2641 | + | |
2640 | 2642 | | |
2641 | 2643 | | |
2642 | 2644 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
245 | | - | |
| 246 | + | |
246 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
247 | 251 | | |
248 | 252 | | |
249 | 253 | | |
250 | | - | |
| 254 | + | |
251 | 255 | | |
252 | 256 | | |
253 | 257 | | |
| |||
493 | 497 | | |
494 | 498 | | |
495 | 499 | | |
496 | | - | |
| 500 | + | |
497 | 501 | | |
498 | 502 | | |
499 | 503 | | |
| |||
548 | 552 | | |
549 | 553 | | |
550 | 554 | | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | 555 | | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
572 | 564 | | |
573 | 565 | | |
574 | 566 | | |
| |||
579 | 571 | | |
580 | 572 | | |
581 | 573 | | |
582 | | - | |
| 574 | + | |
583 | 575 | | |
584 | 576 | | |
585 | 577 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6036 | 6036 | | |
6037 | 6037 | | |
6038 | 6038 | | |
6039 | | - | |
| 6039 | + | |
6040 | 6040 | | |
6041 | 6041 | | |
6042 | 6042 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | 280 | | |
284 | 281 | | |
285 | 282 | | |
| |||
292 | 289 | | |
293 | 290 | | |
294 | 291 | | |
295 | | - | |
| 292 | + | |
296 | 293 | | |
297 | 294 | | |
298 | 295 | | |
| |||
310 | 307 | | |
311 | 308 | | |
312 | 309 | | |
313 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | | - | |
| 432 | + | |
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | | - | |
| 443 | + | |
| 444 | + | |
444 | 445 | | |
445 | 446 | | |
446 | 447 | | |
| |||
707 | 708 | | |
708 | 709 | | |
709 | 710 | | |
710 | | - | |
711 | | - | |
| 711 | + | |
712 | 712 | | |
713 | 713 | | |
714 | 714 | | |
| |||
731 | 731 | | |
732 | 732 | | |
733 | 733 | | |
734 | | - | |
| 734 | + | |
735 | 735 | | |
736 | 736 | | |
737 | 737 | | |
| |||
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
831 | | - | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
832 | 835 | | |
833 | 836 | | |
834 | 837 | | |
835 | 838 | | |
836 | 839 | | |
837 | 840 | | |
838 | 841 | | |
839 | | - | |
| 842 | + | |
840 | 843 | | |
841 | 844 | | |
842 | 845 | | |
843 | 846 | | |
844 | 847 | | |
845 | 848 | | |
846 | 849 | | |
847 | | - | |
| 850 | + | |
848 | 851 | | |
849 | 852 | | |
850 | 853 | | |
851 | | - | |
852 | 854 | | |
853 | 855 | | |
854 | 856 | | |
| |||
975 | 977 | | |
976 | 978 | | |
977 | 979 | | |
978 | | - | |
979 | | - | |
| 980 | + | |
980 | 981 | | |
981 | 982 | | |
982 | 983 | | |
983 | 984 | | |
984 | | - | |
985 | | - | |
986 | 985 | | |
987 | 986 | | |
988 | 987 | | |
989 | 988 | | |
990 | | - | |
| 989 | + | |
991 | 990 | | |
992 | 991 | | |
993 | 992 | | |
| |||
1097 | 1096 | | |
1098 | 1097 | | |
1099 | 1098 | | |
1100 | | - | |
| 1099 | + | |
1101 | 1100 | | |
1102 | 1101 | | |
1103 | 1102 | | |
| |||
1391 | 1390 | | |
1392 | 1391 | | |
1393 | 1392 | | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
1394 | 1468 | | |
1395 | 1469 | | |
1396 | 1470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
368 | | - | |
| 368 | + | |
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| |||
0 commit comments