Skip to content

Commit f4053e3

Browse files
rakudramacommit-bot@chromium.org
authored andcommitted
[dart2js] Use Maplet in deferred_Load
On a very big partition this reduces the memory footprint of the ImportSets by 70% and is slightly faster. This is because most ImportSet._transition maps have one entry. Change-Id: I318a5675d8c3cf135c4937b2b0f63409e5c2d754 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155725 Commit-Queue: Stephen Adams <[email protected]> Reviewed-by: Joshua Litt <[email protected]>
1 parent ac71a39 commit f4053e3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/compiler/lib/src/deferred_load.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import 'options.dart';
2828
import 'universe/use.dart';
2929
import 'universe/world_impact.dart'
3030
show ImpactUseCase, WorldImpact, WorldImpactVisitorImpl;
31+
import 'util/maplet.dart';
3132
import 'util/util.dart' show makeUnique;
3233
import 'world.dart' show KClosedWorld;
3334

@@ -1050,8 +1051,11 @@ class ImportSetLattice {
10501051
b = b._previous;
10511052
}
10521053
}
1053-
while (imports.isNotEmpty) {
1054-
result = result._add(imports.removeLast());
1054+
1055+
// Add merged elements back in reverse order. It is tempting to pop them off
1056+
// with `removeLast()` but that causes measurable shrinking reallocations.
1057+
for (int i = imports.length - 1; i >= 0; i--) {
1058+
result = result._add(imports[i]);
10551059
}
10561060
return result;
10571061
}
@@ -1091,7 +1095,7 @@ class ImportSet {
10911095
}
10921096

10931097
/// Links to other import sets in the lattice by adding one import.
1094-
final Map<_DeferredImport, ImportSet> _transitions = {};
1098+
final Map<_DeferredImport, ImportSet> _transitions = Maplet();
10951099

10961100
ImportSet.empty()
10971101
: _import = null,

0 commit comments

Comments
 (0)