Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.0.1-wip

- Small improvements to RAM usage.

## 3.0.0

- Removed unused deps: `meta`, `pool`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ class LibraryCycleGraphLoader {
/// for its sorting, so earlier phases are processed first in [_nextIdToLoad].
final SplayTreeMap<int, List<AssetId>> _idsToLoad = SplayTreeMap();

final List<(int, AssetId)> _loadingIds = [];

/// All loaded library cycles, by asset.
final Map<AssetId, PhasedValue<LibraryCycle>> _cycles = {};

Expand Down Expand Up @@ -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);
}

Expand Down
28 changes: 20 additions & 8 deletions build/lib/src/state/lru_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<K, V> {
_Entry<K, V>? _head;
Expand Down Expand Up @@ -55,13 +57,15 @@ class LruCache<K, V> {
_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;
Expand All @@ -75,19 +79,27 @@ class LruCache<K, V> {
_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;
_head = link;
_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.
Expand Down
5 changes: 3 additions & 2 deletions build/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,14 +10,15 @@ 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
crypto: ^3.0.0
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

Expand Down
32 changes: 32 additions & 0 deletions build/test/state/lru_cache_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
4 changes: 4 additions & 0 deletions build_resolvers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.0.1-wip

- Use `build` 3.0.1.

## 3.0.0

- Remove unused deps: `graphs`, `logging`, `stream_transform`.
Expand Down
6 changes: 3 additions & 3 deletions build_resolvers/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions build_runner/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.6.1-wip

- Use `build` 3.0.1.

## 2.6.0

- Remove unused deps: `analyzer`, `build_resolvers`, `collection`, `http`,
Expand Down
6 changes: 3 additions & 3 deletions build_runner/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions build_runner_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 9.2.1-wip

- Use `build` 3.0.1.

## 9.2.0

- Removed unused dev_deps: `test_process`.
Expand Down
8 changes: 4 additions & 4 deletions build_runner_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions build_test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions build_test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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

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
Expand Down
9 changes: 6 additions & 3 deletions tool/leak_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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