diff --git a/build/CHANGELOG.md b/build/CHANGELOG.md index 6a0e83030d..d3068409ab 100644 --- a/build/CHANGELOG.md +++ b/build/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.1-wip + +- Small improvements to RAM usage. + ## 3.0.0 - Removed unused deps: `meta`, `pool`. diff --git a/build/lib/src/library_cycle_graph/library_cycle_graph_loader.dart b/build/lib/src/library_cycle_graph/library_cycle_graph_loader.dart index fefe36eb32..217b04f3df 100644 --- a/build/lib/src/library_cycle_graph/library_cycle_graph_loader.dart +++ b/build/lib/src/library_cycle_graph/library_cycle_graph_loader.dart @@ -73,8 +73,6 @@ class LibraryCycleGraphLoader { /// for its sorting, so earlier phases are processed first in [_nextIdToLoad]. final SplayTreeMap> _idsToLoad = SplayTreeMap(); - final List<(int, AssetId)> _loadingIds = []; - /// All loaded library cycles, by asset. final Map> _cycles = {}; @@ -136,7 +134,6 @@ class LibraryCycleGraphLoader { // Return the last ID from the list of IDs at this phase because it's // cheapest to remove in `_removeIdToLoad`. final result = first.value.last; - _loadingIds.add((first.key, result)); return (first.key, result); } diff --git a/build/lib/src/state/lru_cache.dart b/build/lib/src/state/lru_cache.dart index 2194640688..3a59280752 100644 --- a/build/lib/src/state/lru_cache.dart +++ b/build/lib/src/state/lru_cache.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:meta/meta.dart'; + /// A basic LRU Cache. class LruCache { _Entry? _head; @@ -55,13 +57,15 @@ class LruCache { _currentWeightTotal -= entry.weight; _entries.remove(key); + // Remove from linked list. + entry.previous?.next = entry.next; + entry.next?.previous = entry.previous; + if (entry == _tail) { _tail = entry.next; - _tail?.previous = null; } if (entry == _head) { _head = entry.previous; - _head?.next = null; } return entry.value; @@ -75,12 +79,9 @@ class LruCache { _tail = link.next; } - if (link.previous != null) { - link.previous!.next = link.next; - } - if (link.next != null) { - link.next!.previous = link.previous; - } + // Remove from linked list. + link.previous?.next = link.next; + link.next?.previous = link.previous; _head?.next = link; link.previous = _head; @@ -88,6 +89,17 @@ class LruCache { _tail ??= link; link.next = null; } + + @visibleForTesting + int get linkedListLength { + var result = 0; + var current = _head; + while (current != null) { + ++result; + current = current.previous; + } + return result; + } } /// An entry in an [LruCache] which is also a part of a doubly linked list. diff --git a/build/pubspec.yaml b/build/pubspec.yaml index 4f6f7684d4..751c6179a6 100644 --- a/build/pubspec.yaml +++ b/build/pubspec.yaml @@ -1,5 +1,5 @@ name: build -version: 3.0.0 +version: 3.0.1-wip description: A package for authoring build_runner compatible code generators. repository: https://github.com/dart-lang/build/tree/master/build resolution: workspace @@ -10,7 +10,7 @@ environment: dependencies: analyzer: '>=7.4.0 <8.0.0' async: ^2.5.0 - build_runner_core: '9.2.0' + build_runner_core: '9.2.1-wip' built_collection: ^5.1.1 built_value: ^8.9.5 convert: ^3.0.0 @@ -18,6 +18,7 @@ dependencies: glob: ^2.0.0 graphs: ^2.2.0 logging: ^1.0.0 + meta: ^1.17.0 package_config: ^2.1.0 path: ^1.8.0 diff --git a/build/test/state/lru_cache_test.dart b/build/test/state/lru_cache_test.dart index f12002217d..d20781de4c 100644 --- a/build/test/state/lru_cache_test.dart +++ b/build/test/state/lru_cache_test.dart @@ -120,4 +120,36 @@ void main() { expect(cache['$i'], maxIndividualWeight); } }); + + test('removes also remove from linked list', () { + cache['a'] = 1; + expect(cache.linkedListLength, 1); + cache.remove('a'); + expect(cache.linkedListLength, 0); + }); + + test('removes also remove from middle of linked list', () { + cache['a'] = 1; + cache['b'] = 1; + cache['c'] = 1; + expect(cache.linkedListLength, 3); + cache.remove('b'); + expect(cache.linkedListLength, 2); + }); + + test('updates remove old from linked list', () { + cache['a'] = 1; + expect(cache.linkedListLength, 1); + cache['a'] = 2; + expect(cache.linkedListLength, 1); + }); + + test('updates remove old from middle of linked list', () { + cache['a'] = 1; + cache['b'] = 1; + cache['c'] = 1; + expect(cache.linkedListLength, 3); + cache['b'] = 2; + expect(cache.linkedListLength, 3); + }); } diff --git a/build_resolvers/CHANGELOG.md b/build_resolvers/CHANGELOG.md index 788d4f5ee8..2786d6ab5a 100644 --- a/build_resolvers/CHANGELOG.md +++ b/build_resolvers/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.1-wip + +- Use `build` 3.0.1. + ## 3.0.0 - Remove unused deps: `graphs`, `logging`, `stream_transform`. diff --git a/build_resolvers/pubspec.yaml b/build_resolvers/pubspec.yaml index eb293d2bf4..363506813d 100644 --- a/build_resolvers/pubspec.yaml +++ b/build_resolvers/pubspec.yaml @@ -1,5 +1,5 @@ name: build_resolvers -version: 3.0.0 +version: 3.0.1-wip description: Resolve Dart code in a Builder repository: https://github.com/dart-lang/build/tree/master/build_resolvers resolution: workspace @@ -10,8 +10,8 @@ environment: dependencies: analyzer: '>=7.4.0 <8.0.0' async: ^2.5.0 - build: '3.0.0' - build_runner_core: '9.2.0' + build: '3.0.1-wip' + build_runner_core: '9.2.1-wip' collection: ^1.17.0 convert: ^3.1.1 crypto: ^3.0.0 diff --git a/build_runner/CHANGELOG.md b/build_runner/CHANGELOG.md index 0b76292055..e578cccbaa 100644 --- a/build_runner/CHANGELOG.md +++ b/build_runner/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.6.1-wip + +- Use `build` 3.0.1. + ## 2.6.0 - Remove unused deps: `analyzer`, `build_resolvers`, `collection`, `http`, diff --git a/build_runner/pubspec.yaml b/build_runner/pubspec.yaml index 534b343c2f..9cf7cdddfe 100644 --- a/build_runner/pubspec.yaml +++ b/build_runner/pubspec.yaml @@ -1,5 +1,5 @@ name: build_runner -version: 2.6.0 +version: 2.6.1-wip description: A build system for Dart code generation and modular compilation. repository: https://github.com/dart-lang/build/tree/master/build_runner resolution: workspace @@ -15,10 +15,10 @@ platforms: dependencies: args: ^2.0.0 async: ^2.5.0 - build: '3.0.0' + build: '3.0.1-wip' build_config: ">=1.1.0 <1.2.0" build_daemon: ^4.0.0 - build_runner_core: '9.2.0' + build_runner_core: '9.2.1-wip' code_builder: ^4.2.0 crypto: ^3.0.0 dart_style: '>=2.3.7 <4.0.0' diff --git a/build_runner_core/CHANGELOG.md b/build_runner_core/CHANGELOG.md index 4ff89f420a..143ec17525 100644 --- a/build_runner_core/CHANGELOG.md +++ b/build_runner_core/CHANGELOG.md @@ -1,3 +1,7 @@ +## 9.2.1-wip + +- Use `build` 3.0.1. + ## 9.2.0 - Removed unused dev_deps: `test_process`. diff --git a/build_runner_core/pubspec.yaml b/build_runner_core/pubspec.yaml index 4f28717802..a66d858411 100644 --- a/build_runner_core/pubspec.yaml +++ b/build_runner_core/pubspec.yaml @@ -1,5 +1,5 @@ name: build_runner_core -version: 9.2.0 +version: 9.2.1-wip description: Core tools to organize the structure of a build and run Builders. repository: https://github.com/dart-lang/build/tree/master/build_runner_core resolution: workspace @@ -15,10 +15,10 @@ platforms: dependencies: analyzer: '>=6.9.0 <8.0.0' async: ^2.5.0 - build: '3.0.0' + build: '3.0.1-wip' build_config: ^1.0.0 - build_resolvers: '3.0.0' - build_runner: '2.6.0' + build_resolvers: '3.0.1-wip' + build_runner: '2.6.1-wip' built_collection: ^5.1.1 built_value: ^8.10.1 collection: ^1.15.0 diff --git a/build_test/CHANGELOG.md b/build_test/CHANGELOG.md index b4d94072da..74dce3ed4e 100644 --- a/build_test/CHANGELOG.md +++ b/build_test/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.3.1-wip + +- Use `build` 3.0.1. + ## 3.3.0 - Read build configs using `AssetReader` so they're easier to test: you can now diff --git a/build_test/pubspec.yaml b/build_test/pubspec.yaml index 08c57bb59d..e16872b1d7 100644 --- a/build_test/pubspec.yaml +++ b/build_test/pubspec.yaml @@ -1,6 +1,6 @@ name: build_test description: Utilities for writing unit tests of Builders. -version: 3.3.0 +version: 3.3.1-wip repository: https://github.com/dart-lang/build/tree/master/build_test resolution: workspace @@ -8,10 +8,10 @@ environment: sdk: ^3.7.0 dependencies: - build: '3.0.0' + build: '3.0.1-wip' build_config: ^1.0.0 - build_resolvers: '3.0.0' - build_runner_core: '9.2.0' + build_resolvers: '3.0.1-wip' + build_runner_core: '9.2.1-wip' crypto: ^3.0.0 glob: ^2.0.0 html: ^0.15.0 diff --git a/tool/leak_check.sh b/tool/leak_check.sh index 1cbe9d7cf0..2dcc387694 100755 --- a/tool/leak_check.sh +++ b/tool/leak_check.sh @@ -14,9 +14,9 @@ fi dart test/invalidation/invalidation_leak_checker.dart setup leak_amount=$(dart test/invalidation/invalidation_leak_checker.dart) -leak_limit=60000 +leak_limit=15000 -if test $((leak_amount)) -gt 60000; then +if test $((leak_amount)) -gt "$leak_limit"; then echo "Measured leak size $leak_amount > $leak_limit, failing!" exit 1 else @@ -30,4 +30,7 @@ fi # 52455, 52332, 52308 # # Initial check-in with https://dart-review.googlesource.com/c/sdk/+/441740: -# 21482, 11568, 13186 +# 21482, 11568, 13186 +# +# After `build_runner` leak fixes and analyzer 7.7.1 with 441740: +# 13147, 12515, 13320