Commit 1f59259
Fine. Deduplicate prefix-scope requirement recording
Record import-prefix lookups only once per identifier during a single
requirements run. This avoids repeatedly writing the same
`exportedTopLevels` entries for every imported library when the same
name is looked up multiple times.
Key changes:
- Introduce `PrefixScopeRequirementState` and pass it to
`RequirementsManifest.record_importPrefixScope_lookup`. The method
now records requirements for a given `id` only on the first lookup
seen by that state.
- Add `InstanceElementRequirementState` and
`LibraryElementRequirementState` to cache per-owner lookups inside
`_getInstanceItem`, `_getInterfaceItem`, and `_getLibraryRequirements`,
reducing map churn.
- Add `RequirementsManifest.stopRecording()` and call it after
analysis/linking to dispose per-run state and reclaim memory.
- Update call sites:
- `PrefixScope.lookup()` now supplies a persistent state.
- `record_library_exportScope_get()` uses a one-shot state for
direct library export-scope queries.
Impact:
- Lowers the cost of requirement recording from ~6% to ~1.74% of total
analysis time in observed profiles.
- Preserves correctness: all needed exported IDs are still recorded;
we simply suppress duplicates.
- Trade-off: a small, transient per-run memory footprint for the
dedup sets and caches, cleared via `stopRecording()`.
Rationale: Repeated name lookups were causing redundant `Map` writes
(often writing the same `null`/ID values many times). By binding
prefix-scope recording to a per-run state and caching element/library
requirement slots, we remove hot-path duplication without sacrificing
precision.
Change-Id: Ibe07162aa0503348956b9c41beea493d469c0193
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450366
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>1 parent 3286cb4 commit 1f59259
File tree
5 files changed
+126
-4
lines changed- pkg/analyzer/lib/src
- dart
- analysis
- element
- fine
5 files changed
+126
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1395 | 1395 | | |
1396 | 1396 | | |
1397 | 1397 | | |
| 1398 | + | |
1398 | 1399 | | |
1399 | 1400 | | |
1400 | 1401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| 335 | + | |
335 | 336 | | |
336 | 337 | | |
337 | 338 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4221 | 4221 | | |
4222 | 4222 | | |
4223 | 4223 | | |
| 4224 | + | |
| 4225 | + | |
| 4226 | + | |
| 4227 | + | |
4224 | 4228 | | |
4225 | 4229 | | |
4226 | 4230 | | |
| |||
5999 | 6003 | | |
6000 | 6004 | | |
6001 | 6005 | | |
| 6006 | + | |
| 6007 | + | |
| 6008 | + | |
| 6009 | + | |
6002 | 6010 | | |
6003 | 6011 | | |
6004 | 6012 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
521 | 524 | | |
522 | 525 | | |
523 | 526 | | |
| |||
579 | 582 | | |
580 | 583 | | |
581 | 584 | | |
| 585 | + | |
582 | 586 | | |
583 | 587 | | |
584 | 588 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
194 | 216 | | |
195 | 217 | | |
196 | 218 | | |
| |||
330 | 352 | | |
331 | 353 | | |
332 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
333 | 373 | | |
334 | 374 | | |
335 | 375 | | |
| |||
701 | 741 | | |
702 | 742 | | |
703 | 743 | | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
704 | 767 | | |
705 | 768 | | |
706 | 769 | | |
| |||
714 | 777 | | |
715 | 778 | | |
716 | 779 | | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
717 | 784 | | |
718 | 785 | | |
719 | 786 | | |
| |||
1486 | 1553 | | |
1487 | 1554 | | |
1488 | 1555 | | |
| 1556 | + | |
1489 | 1557 | | |
1490 | 1558 | | |
1491 | 1559 | | |
| |||
1495 | 1563 | | |
1496 | 1564 | | |
1497 | 1565 | | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
1498 | 1571 | | |
1499 | 1572 | | |
1500 | 1573 | | |
| |||
1990 | 2063 | | |
1991 | 2064 | | |
1992 | 2065 | | |
| 2066 | + | |
1993 | 2067 | | |
1994 | 2068 | | |
1995 | 2069 | | |
| |||
2305 | 2379 | | |
2306 | 2380 | | |
2307 | 2381 | | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
2308 | 2399 | | |
2309 | 2400 | | |
2310 | 2401 | | |
| |||
2321 | 2412 | | |
2322 | 2413 | | |
2323 | 2414 | | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
2324 | 2420 | | |
2325 | 2421 | | |
2326 | 2422 | | |
| |||
2349 | 2445 | | |
2350 | 2446 | | |
2351 | 2447 | | |
2352 | | - | |
2353 | | - | |
| 2448 | + | |
2354 | 2449 | | |
2355 | 2450 | | |
2356 | 2451 | | |
| 2452 | + | |
2357 | 2453 | | |
2358 | 2454 | | |
2359 | 2455 | | |
2360 | 2456 | | |
2361 | 2457 | | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
2362 | 2463 | | |
2363 | 2464 | | |
2364 | 2465 | | |
| |||
2386 | 2487 | | |
2387 | 2488 | | |
2388 | 2489 | | |
2389 | | - | |
| 2490 | + | |
2390 | 2491 | | |
2391 | 2492 | | |
2392 | 2493 | | |
| 2494 | + | |
2393 | 2495 | | |
2394 | 2496 | | |
2395 | 2497 | | |
2396 | | - | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
2397 | 2505 | | |
2398 | 2506 | | |
2399 | 2507 | | |
| |||
0 commit comments