-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use fixed-length List where possible.
In short: Heap size: -155 MB, about 9% Object count: -4.6 * 10^6, about 20% rwf-materials/01-setting-up-your-environment === Before. [Analysis contexts: 35] [time: 16521 ms] [26802 ms] Created HeapSnapshotGraph. externalSize: 1984 shallowSize: 1757489376 Objects: 23454755 [26803 ms] Created Analysis. All objects. size count class -------- -------- -------- 278670 kb 2110088 _OneByteString dart:core 270497 kb 2090817 _List dart:core 229974 kb 2066512 _Uint32List dart:typed_data 154250 kb 4936008 _GrowableList dart:core 63129 kb 160607 _Uint8List dart:typed_data 56224 kb 1199459 Reference package:analyzer/src/summary2/reference.dart 42643 kb 682297 _InfoMethodDeclaration package:analyzer/src/summary2/informative_data.dart 40358 kb 234812 PropertyAccessorElementImpl_ImplicitGetter package:analyzer/src/dart/element/element.dart 38075 kb 203067 ConstFieldElementImpl package:analyzer/src/dart/element/element.dart 32181 kb 686528 _InfoFormalParameter package:analyzer/src/summary2/informative_data.dart 29730 kb 475685 _Closure dart:core 27724 kb 6868 _TwoByteString dart:core 25594 kb 409516 _Map dart:collection 17778 kb 81273 ClassElementImpl package:analyzer/src/dart/element/element.dart 16479 kb 411894 Context 14672 kb 93903 LibraryImportElementImpl package:analyzer/src/dart/element/element.dart 14074 kb 90077 ParameterElementImpl package:analyzer/src/dart/element/element.dart 13316 kb 284078 _InfoFieldDeclaration package:analyzer/src/summary2/informative_data.dart 13138 kb 19582 Instructions 11985 kb 191772 InterfaceTypeImpl package:analyzer/src/dart/element/type.dart -------- -------- 1701770 kb 23237353 Instances of: _GrowableList size count class -------- -------- -------- 154250 kb 4936008 _GrowableList dart:core Instances of empty: _GrowableList size count class -------- -------- -------- 119542 kb 3825345 _GrowableList dart:core === After [Analysis contexts: 35] [time: 16946 ms] [24964 ms] Created HeapSnapshotGraph. externalSize: 1984 shallowSize: 1611104288 Objects: 18819706 [24965 ms] Created Analysis. All objects. size count class -------- -------- -------- 278679 kb 2110125 _OneByteString dart:core 265723 kb 2097564 _List dart:core 229974 kb 2066512 _Uint32List dart:typed_data 62996 kb 158742 _Uint8List dart:typed_data 56224 kb 1199459 Reference package:analyzer/src/summary2/reference.dart 42643 kb 682297 _InfoMethodDeclaration package:analyzer/src/summary2/informative_data.dart 40358 kb 234812 PropertyAccessorElementImpl_ImplicitGetter package:analyzer/src/dart/element/element.dart 38075 kb 203067 ConstFieldElementImpl package:analyzer/src/dart/element/element.dart 32181 kb 686528 _InfoFormalParameter package:analyzer/src/summary2/informative_data.dart 29730 kb 475685 _Closure dart:core 27724 kb 6868 _TwoByteString dart:core 25594 kb 409516 _Map dart:collection 17778 kb 81273 ClassElementImpl package:analyzer/src/dart/element/element.dart 16479 kb 411894 Context 14672 kb 93903 LibraryImportElementImpl package:analyzer/src/dart/element/element.dart 14074 kb 90077 ParameterElementImpl package:analyzer/src/dart/element/element.dart 13316 kb 284078 _InfoFieldDeclaration package:analyzer/src/summary2/informative_data.dart 13117 kb 19633 Instructions 11985 kb 191772 InterfaceTypeImpl package:analyzer/src/dart/element/type.dart 11520 kb 184326 FieldElementLinkedData package:analyzer/src/summary2/bundle_reader.dart -------- -------- 1546419 kb 18428158 Instances of: LibraryElementImpl size count class -------- -------- -------- 4491 kb 15129 LibraryElementImpl package:analyzer/src/dart/element/element.dart Instances of: _GrowableList size count class -------- -------- -------- 3795 kb 121445 _GrowableList dart:core Instances of empty: _GrowableList size count class -------- -------- -------- 2075 kb 66426 _GrowableList dart:core Change-Id: I4ed72298a2361e9fe004bef5482a9f8bae5de6df Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279644 Reviewed-by: Samuel Rawlins <srawlins@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
- Loading branch information
Showing
31 changed files
with
326 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
b4640c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this, but it's weird to me the fixed list is of type list. Won't this create issues in maintenance in the future, like
const a = []; a.add(1)
is invalid? Is there anything we can make to make the development experience better/more explicit in this regard?b4640c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, ideally we would need separate types for immutable collections, and mutable collections.
You are right, that the absence of the type-level separation makes it impossible to know if such code will fail at runtime.
But we (in the
analyzer
) are limited by the language capabilities.b4640c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @munificent pleaseeee
b4640c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waaaay back before Dart 1.0 when the collections API was first designed, the folks working on it spent a lot of time discussing whether Dart should expose separate read-only and read-write APIs for collections. That way, if you had an immutable list, the API for the list wouldn't even let you try to call mutating methods on it.
They decided to not do that. Their argument was that it kept the API simpler (which it does). We sort of have it for lists with
Iterable
andList
. ButIterable
doesn't have operator[]
. (Though it does haveelementAt()
.)We could conceivably add a new read-only list (and map and set) interface, but given how close
Iterable
already is to that, it would probably just add confusion.In practice, users want to distinguish between:
const
in C++).Deciding which of those properties are visible in the type system and API design (and thus statically checked) is a Hard Problem.