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

[Enhancement] Cache Schema instances for classes in a weak reference cache since creating an instance could be CPU intensive #23707

Open
1 of 2 tasks
lhotari opened this issue Dec 10, 2024 · 1 comment
Labels
type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Comments

@lhotari
Copy link
Member

lhotari commented Dec 10, 2024

Search before asking

  • I searched in the issues and found nothing similar.

Motivation

For example, Schema.AVRO(SomeClass.class) is fairly CPU intensive. It would be useful it there would be a weak reference cache for caching the schema instance.

Solution

  • add a weak reference cache for caching a scheme instance for Schema.AVRO, Schema.JSON, Schema.PROTOBUF.
  • Don't return the schema instance directly since schema instances are mutable. Instead return a clone of the cached instance.

Alternatives

Anything else?

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@lhotari lhotari added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Dec 10, 2024
@walkinggo
Copy link

Are there any limitations in the specific technical framework for implementing weak references? How should we limit the size of the cache?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

No branches or pull requests

2 participants