Skip to content

[AI-8th] perf: add reflection cache#1415

Open
kuleat wants to merge 3 commits intosofastack:masterfrom
kuleat:feature/reflection-cache
Open

[AI-8th] perf: add reflection cache#1415
kuleat wants to merge 3 commits intosofastack:masterfrom
kuleat:feature/reflection-cache

Conversation

@kuleat
Copy link
Copy Markdown

@kuleat kuleat commented Apr 7, 2026

#1409

Changes

  • introduce ReflectionCache to cache repeated reflection lookups
  • support configuration via sofa.boot.reflection.cache.enabled
  • apply reflection cache to HealthIndicatorProcessor and DataSourceBeanPostProcessor
  • add reflection-cache actuator endpoint for stats and clear operation
  • add related unit tests and smoke tests

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 88.99522% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.06%. Comparing base (459b02f) to head (5e20b6d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...m/alipay/sofa/boot/reflection/ReflectionCache.java 87.36% 8 Missing and 15 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1415      +/-   ##
============================================
+ Coverage     82.94%   83.06%   +0.12%     
- Complexity     2975     3018      +43     
============================================
  Files           340      345       +5     
  Lines          9833    10040     +207     
  Branches       1178     1200      +22     
============================================
+ Hits           8156     8340     +184     
- Misses         1163     1171       +8     
- Partials        514      529      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a reusable ReflectionCache facility to reduce repeated reflection lookups across SOFABoot, wires it into key components (health readiness + datasource tracer), and exposes cache stats/clear via a new actuator endpoint.

Changes:

  • Add core ReflectionCache implementation with hit/miss statistics and clear support
  • Auto-configure the cache via sofa.boot.reflection.cache.enabled and integrate it into readiness health + datasource processing
  • Add reflection-cache actuator endpoint plus unit tests and smoke/integration tests

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sofa-boot-tests/sofa-boot-smoke-tests/sofa-boot-smoke-tests-actuator/src/test/java/com/alipay/sofa/smoke/tests/actuator/reflection/ReflectionCacheEndpointWebTests.java Smoke test coverage for the new actuator endpoint over HTTP
sofa-boot-project/sofa-boot/src/test/java/com/alipay/sofa/boot/reflection/ReflectionCacheTests.java Unit tests validating cache hit/miss behavior, miss caching, and disabled mode
sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/reflection/ReflectionCache.java New reflection lookup cache implementation + stats/clear
sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/constant/SofaBootConstants.java Adds reflection-cache to the default web exposure list
sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/datasource/DataSourceBeanPostProcessor.java Uses cached method lookup when available
sofa-boot-project/sofa-boot-autoconfigure/src/test/java/com/alipay/sofa/boot/autoconfigure/tracer/datasource/DataSourceAutoConfigurationTests.java Ensures datasource auto-config runs with reflection-cache auto-config present
sofa-boot-project/sofa-boot-autoconfigure/src/test/java/com/alipay/sofa/boot/autoconfigure/reflection/ReflectionCacheAutoConfigurationTests.java Tests for reflection-cache auto-configuration and property toggle
sofa-boot-project/sofa-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports Registers ReflectionCacheAutoConfiguration for Boot auto-import
sofa-boot-project/sofa-boot-autoconfigure/src/main/java/com/alipay/sofa/boot/autoconfigure/tracer/datasource/DataSourceAutoConfiguration.java Injects ReflectionCache into DataSourceBeanPostProcessor
sofa-boot-project/sofa-boot-autoconfigure/src/main/java/com/alipay/sofa/boot/autoconfigure/reflection/ReflectionCacheProperties.java Adds configuration properties for enabling/disabling caching
sofa-boot-project/sofa-boot-autoconfigure/src/main/java/com/alipay/sofa/boot/autoconfigure/reflection/ReflectionCacheAutoConfiguration.java Creates/configures the ReflectionCache bean
sofa-boot-project/sofa-boot-actuator/src/test/java/com/alipay/sofa/boot/actuator/reflection/ReflectionCacheEndpointTests.java Unit tests for endpoint stats + clear behavior
sofa-boot-project/sofa-boot-actuator/src/main/java/com/alipay/sofa/boot/actuator/reflection/ReflectionCacheEndpoint.java New reflection-cache actuator endpoint (stats + clear)
sofa-boot-project/sofa-boot-actuator/src/main/java/com/alipay/sofa/boot/actuator/health/HealthIndicatorProcessor.java Uses cached Class.forName for excluded indicator class loading
sofa-boot-project/sofa-boot-actuator-autoconfigure/src/test/java/com/alipay/sofa/boot/actuator/autoconfigure/rpc/RpcActuatorAutoConfigurationTests.java Test wiring updated to include reflection-cache auto-config
sofa-boot-project/sofa-boot-actuator-autoconfigure/src/test/java/com/alipay/sofa/boot/actuator/autoconfigure/reflection/ReflectionCacheEndpointAutoConfigurationTests.java Tests conditional creation of the new endpoint auto-config
sofa-boot-project/sofa-boot-actuator-autoconfigure/src/test/java/com/alipay/sofa/boot/actuator/autoconfigure/health/ReadinessEndpointAutoConfigurationTests.java Test wiring updated to include reflection-cache auto-config
sofa-boot-project/sofa-boot-actuator-autoconfigure/src/test/java/com/alipay/sofa/boot/actuator/autoconfigure/health/ReadinessAutoConfigurationTests.java Test wiring updated to include reflection-cache auto-config
sofa-boot-project/sofa-boot-actuator-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports Registers endpoint auto-config for Boot auto-import
sofa-boot-project/sofa-boot-actuator-autoconfigure/src/main/java/com/alipay/sofa/boot/actuator/autoconfigure/reflection/ReflectionCacheEndpointAutoConfiguration.java Auto-configures the ReflectionCacheEndpoint when exposed/available
sofa-boot-project/sofa-boot-actuator-autoconfigure/src/main/java/com/alipay/sofa/boot/actuator/autoconfigure/health/ReadinessAutoConfiguration.java Injects ReflectionCache into HealthIndicatorProcessor bean setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CrazyHZM
Copy link
Copy Markdown
Member

@kuleat, please handle the Copilot's comments first.

@kuleat
Copy link
Copy Markdown
Author

kuleat commented Apr 24, 2026

@kuleat, please handle the Copilot's comments first.

@CrazyHZM Thanks, I’ve addressed Copilot’s comments. PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants