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

SOLR-17340: add cache on top of BeanInfo instrospector #2538

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

psalagnac
Copy link
Contributor

@psalagnac psalagnac commented Jun 27, 2024

https://issues.apache.org/jira/browse/SOLR-17340

Description

Solr endpoint /solr/admin/info/system is slow because of time spent in Java beans introspection.

Solution

Add a simple cache on top of bean info introspection. For each bean class, the introspection will be run only once for the JVM lifespan.

Tests

Naive performance benchmark. See results in Jira comment

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

@psalagnac psalagnac changed the title JIRA-:17340 add cache on top of BeanInfo instrospector JIRA-17340 add cache on top of BeanInfo instrospector Jun 27, 2024
@psalagnac psalagnac changed the title JIRA-17340 add cache on top of BeanInfo instrospector JIRA-17340: add cache on top of BeanInfo instrospector Jun 27, 2024
@dsmiley dsmiley changed the title JIRA-17340: add cache on top of BeanInfo instrospector SOLR-17330: add cache on top of BeanInfo instrospector Jul 17, 2024
Comment on lines -830 to +848
MetricUtils.addMXBeanMetrics(obj, intf, null, consumer);
MetricUtils.addMXBeanMetrics(obj, intf, prefix, consumer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this about here; seems like metrics would be published in a different spot, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to comment on this when creating the pull request.

I think this was a typo when this code was initially added. The prefix parameter of the method is not passed through to the other method. In practice, all callers to addMXBeanMetrics() in Solr code set null for this parameter, so this will not change anything.

Another option could be to just remove the parameter, but I think it's better to keep it if we have later more categories for metrics.

@psalagnac psalagnac changed the title SOLR-17330: add cache on top of BeanInfo instrospector SOLR-17340: add cache on top of BeanInfo instrospector Jul 22, 2024
@@ -152,6 +152,8 @@ Optimizations

* SOLR-17349: SolrDocumentFetcher should always skip lazy field loading overhead if documentCache==null (Michael Gibney)

* JIRA-17340: Add cache on top of system metrics BeanInfos to make call to /admin/info/system faster (Pierre Salagnac)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* JIRA-17340: Add cache on top of system metrics BeanInfos to make call to /admin/info/system faster (Pierre Salagnac)
* SOLR-17340: Add cache on top of system metrics BeanInfos to make call to /admin/info/system faster (Pierre Salagnac)

@dsmiley dsmiley merged commit 0da7a78 into apache:main Jul 22, 2024
3 checks passed
dsmiley pushed a commit that referenced this pull request Jul 22, 2024
Note the prefix arg was always null, thus this one-line change is just a refactoring for correctness.

(cherry picked from commit 0da7a78)
@psalagnac psalagnac deleted the system-probe branch July 23, 2024 09:32
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

Successfully merging this pull request may close these issues.

2 participants