devtools icon indicating copy to clipboard operation
devtools copied to clipboard

optimize `_updateLocalClasses` in Inspector Service

Open CoderDake opened this issue 3 years ago • 1 comments

_updateLocalClasses fetches each of the objects individually. This causes a performance bottleneck on pub root directory change. If this class ends up being needed, the we will need to find a call that batches the request, to avoid overloading the vm with rpc calls.

NOTE: isLocalClass may not be hooked up to the fronted properly yet. So doing this optimization may not be needed until that is accomplished

CoderDake avatar Aug 19 '22 18:08 CoderDake

Ben recommends

final isolate = inspectorLibrary.isolate!;
final futures = <Future>[];
for (final libraryRef in isolate.libraries!) {
  if (isLocalUri(libraryRef.uri!)) {
    final future = inspectorLibrary.service.getObject(
        isolate.id!, libraryRef.id!
      ).then((result) {
        final library = result as Library;
        for (final classRef in library.classes!) {
          localClasses[classRef.name!] = classRef;
        }
      });
    futures.add(future);
  }
}
await Future.wait(futures);

as a temporary measure, although we may still need to find a batch approach long term https://github.com/flutter/devtools/pull/4394/files#r950499503

CoderDake avatar Aug 19 '22 19:08 CoderDake