Skip to content

SubtypeTestCache overflows due to is checks with many different receivers #48235

Open
@mkustermann

Description

@mkustermann

We have code like this in the core libraries _Future implementation (from future_impl.dart)

  void _asyncComplete(FutureOr<T> value) {
    if (value is Future<T>) {
      _chainFuture(value);
      return;
    }
    _asyncCompleteWithValue(value as dynamic);
  }

This code will be called with return values of async functions. At runtime the value can therefore be of many different types. This causes an issue with this is Future<T> check.

The is check is performed via SubtypeTestCache which have a maximum length of 100 and will fallback to runtime after that. Since value will obtain many different class ids, the SubtypeTestCache easily fills up and causes very slow performance.

Due to the fact that this will happen on pretty much any program which uses lots of async code, it's quite a severe issue.

See also b/182183059

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.type-performanceIssue relates to performance or code size

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions