Skip to content

[AI-8th] optimizes SOFABoot bean async initialization#1423

Open
pmupkin wants to merge 1 commit intosofastack:masterfrom
pmupkin:Smart-Analysis
Open

[AI-8th] optimizes SOFABoot bean async initialization#1423
pmupkin wants to merge 1 commit intosofastack:masterfrom
pmupkin:Smart-Analysis

Conversation

@pmupkin
Copy link
Copy Markdown

@pmupkin pmupkin commented Apr 25, 2026

Summary

This PR(Related issue #1408) optimizes SOFABoot bean async initialization by adding smart async candidate analysis, unified async-init configuration, startup optimization reporting, and an actuator endpoint for optimization suggestions.

Changes

  • Added SmartAsyncInitAnalyzer to automatically identify safe async-init candidates based on bean metadata, dependency signals, stateful annotations, constructor/property references, and auto mode.
  • Added async-init configuration properties under sofa.boot.async-init, including:
    • enabled
    • corePoolSize
    • maxPoolSize
    • queueCapacity
    • timeoutMillis
    • autoMode
  • Added AsyncInitAutoMode with OFF, CONSERVATIVE, and AGGRESSIVE modes.
  • Enhanced async-init processing to preserve explicit @SofaAsyncInit and XML configuration behavior.
  • Added timeout support to AsyncInitMethodManager.
  • Added startup optimization model and analyzer:
    • StartupOptimizer
    • StartupReport
    • BeanInitInfo
    • StartupRecommendation
  • Added startup-optimization actuator endpoint to expose startup bottleneck analysis and slow bean information.
  • Added actuator auto-configuration for the new startup optimization endpoint.
  • Added focused unit tests for analyzer behavior, async-init configuration binding, timeout handling, startup recommendations, endpoint behavior, and auto-configuration.

Compatibility

  • Keeps compatibility with existing @SofaAsyncInit usage.
  • Explicit async-init enable/disable declarations continue to take precedence.
  • Legacy async executor properties remain supported.
  • Async initialization can be disabled with:
sofa:
  boot:
    async-init:
      enabled: false

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

❌ Patch coverage is 70.91503% with 89 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.61%. Comparing base (459b02f) to head (ee19b3d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...pay/sofa/runtime/async/SmartAsyncInitAnalyzer.java 47.41% 37 Missing and 24 partials ⚠️
...lipay/sofa/boot/startup/StartupRecommendation.java 37.50% 10 Missing ⚠️
...com/alipay/sofa/boot/startup/StartupOptimizer.java 83.92% 2 Missing and 7 partials ⚠️
...onfigure/runtime/SofaRuntimeAutoConfiguration.java 84.61% 0 Missing and 4 partials ⚠️
...ava/com/alipay/sofa/boot/startup/BeanInitInfo.java 88.23% 2 Missing ⚠️
.../actuator/startup/StartupOptimizationEndpoint.java 85.71% 0 Missing and 1 partial ⚠️
...oot/autoconfigure/runtime/AsyncInitProperties.java 96.00% 1 Missing ⚠️
...time/spring/AsyncInitBeanFactoryPostProcessor.java 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1423      +/-   ##
============================================
- Coverage     82.94%   82.61%   -0.34%     
- Complexity     2975     3080     +105     
============================================
  Files           340      349       +9     
  Lines          9833    10128     +295     
  Branches       1178     1241      +63     
============================================
+ Hits           8156     8367     +211     
- Misses         1163     1214      +51     
- Partials        514      547      +33     

☔ 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.

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.

1 participant