Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance cliff when running apps with many protobuf classes #573

Closed
mkustermann opened this issue Jan 27, 2022 · 3 comments
Closed

Performance cliff when running apps with many protobuf classes #573

mkustermann opened this issue Jan 27, 2022 · 3 comments

Comments

@mkustermann
Copy link
Collaborator

When running apps with many proto classes one can run into a performance cliff due to doing runtime function type checks in the Dart VM (which are currently implemented via a cache that has maximum size).

The "offending" code in the protobuf library is in generated_message:

  static final Map<Function?, Function> _defaultMakers = {};

  static T Function() _defaultMakerFor<T extends GeneratedMessage>(
      T Function()? createFn) {
    return (_defaultMakers[createFn] ??= _createDefaultMakerFor<T>(createFn!))
        as T Function();
  }

When inserting createFn into the Map<Function?, Function> we loose track of its function type T Function()?. That means when getting it out of the map we have to do a runtime function type check which is very expensive.

@mkustermann
Copy link
Collaborator Author

We could land a change that replaces this runtime function type test with a simpler runtime interface type check that is more efficiently implemented in the Dart VM.

See PR #574

/cc @sstrickl

@mraleph
Copy link
Member

mraleph commented Mar 15, 2022

@mkustermann I presume this is fixed by your PR?

@mkustermann
Copy link
Collaborator Author

Those particular function type checks are gone now, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants