-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 #23777
base: master
Are you sure you want to change the base?
Conversation
@walkinggo Please add the following content to your PR description and select a checkbox:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation approach isn't correct. The cache should be an implementation details of the PulsarClientImplementationBindingImpl and not exposed externally.
The key in the cache could be the org.apache.pulsar.client.impl.schema.SchemaDefinitionImpl, however that would require adding hashCode&equals implementations to that class. The cache should have weak keys to prevent memory leaks.
public Schema getAvroSchemaCache(Class clazz); | ||
public Schema getProtobufSchemaCache(Class clazz); | ||
public Schema getJsonSchemaCache(Class clazz); | ||
public void setAvroSchemaCache(Class clazz,Schema schema); | ||
public void setProtobufSchemaCache(Class clazz,Schema schema); | ||
public void setJsonSchemaCache(Class clazz,Schema schema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cache should be encapsulated in the PulsarClientImplementationBindingImpl and not exposed outside of the interface.
There's another PR #23808 where I've provided suggestions about the minimal implementation: #23808 (comment) |
Main Issue: #23707
Motivation
Cache Schema instances for classes in a weak reference cache since creating an instance could be CPU intensive
Modifications
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete