Problem
For a single method in SpringMvcClassExporter.exportMethod(), these rule evaluations occur:
| Rule Key |
Count |
Notes |
API_CLASS_PARSE_BEFORE |
1 |
Event |
API_METHOD_PARSE_BEFORE |
1 |
Event |
API_NAME |
1 |
|
FOLDER_NAME |
2 |
Method + Class |
METHOD_DOC |
2 |
Direct + via resolveApiName fallback |
CLASS_DOC |
1 |
|
METHOD_CONTENT_TYPE |
1 |
|
METHOD_DEFAULT_HTTP |
1 |
|
PATH_MULTI |
1 |
|
PARAM_HTTP_TYPE |
N |
Per parameter |
PARAM_NAME |
N |
Per parameter |
PARAM_DOC |
N |
Per parameter |
PARAM_REQUIRED |
N |
Per parameter |
PARAM_IGNORE |
N |
Per parameter |
PARAM_TYPE |
N |
Per parameter |
PARAM_DEFAULT_VALUE |
N |
Per parameter |
PARAM_DEMO |
N |
Per parameter |
PARAM_MOCK |
N |
Per parameter |
METHOD_ADDITIONAL_HEADER |
1 |
|
METHOD_ADDITIONAL_PARAM |
1 |
|
METHOD_ADDITIONAL_RESPONSE_HEADER |
1 |
|
METHOD_RETURN |
1 |
|
EXPORT_AFTER |
1 |
Event |
API_METHOD_PARSE_AFTER |
1 |
Event |
API_CLASS_PARSE_AFTER |
1 |
Event |
For a method with 5 parameters, that's ~55 rule evaluations per method. With 50 controllers Γ 5 methods = 2,750 rule evaluations just for Spring MVC.
Each rule evaluation creates a RuleContext, loads expressions from config, and potentially executes Groovy scripts.
Impact
Combined with the parsers recomputation and loadExpressionsWithFilters caching issues, this compounds the overhead significantly.
Estimated speedup: 1.3-1.5x
Potential Fixes
- Batch related rule evaluations:
resolveApiName, resolveFolderName, resolveMethodDoc could share a single RuleContext instead of creating separate ones
- Short-circuit when no rules configured: If
loadExpressionsWithFilters(key) returns empty, skip RuleContext creation entirely
- Combine parameter metadata resolution: Instead of 9 separate rule evaluations per parameter, resolve all parameter metadata in a single pass
- Avoid duplicate evaluations:
METHOD_DOC is evaluated both in resolveApiName (as fallback) and resolveMethodDoc β cache the result
Location
src/main/kotlin/com/itangcent/easyapi/exporter/springmvc/SpringMvcClassExporter.kt:90-160
src/main/kotlin/com/itangcent/easyapi/psi/helper/ApiMetadataResolver.kt
Problem
For a single method in
SpringMvcClassExporter.exportMethod(), these rule evaluations occur:API_CLASS_PARSE_BEFOREAPI_METHOD_PARSE_BEFOREAPI_NAMEFOLDER_NAMEMETHOD_DOCCLASS_DOCMETHOD_CONTENT_TYPEMETHOD_DEFAULT_HTTPPATH_MULTIPARAM_HTTP_TYPEPARAM_NAMEPARAM_DOCPARAM_REQUIREDPARAM_IGNOREPARAM_TYPEPARAM_DEFAULT_VALUEPARAM_DEMOPARAM_MOCKMETHOD_ADDITIONAL_HEADERMETHOD_ADDITIONAL_PARAMMETHOD_ADDITIONAL_RESPONSE_HEADERMETHOD_RETURNEXPORT_AFTERAPI_METHOD_PARSE_AFTERAPI_CLASS_PARSE_AFTERFor a method with 5 parameters, that's ~55 rule evaluations per method. With 50 controllers Γ 5 methods = 2,750 rule evaluations just for Spring MVC.
Each rule evaluation creates a
RuleContext, loads expressions from config, and potentially executes Groovy scripts.Impact
Combined with the
parsersrecomputation andloadExpressionsWithFilterscaching issues, this compounds the overhead significantly.Estimated speedup: 1.3-1.5x
Potential Fixes
resolveApiName,resolveFolderName,resolveMethodDoccould share a singleRuleContextinstead of creating separate onesloadExpressionsWithFilters(key)returns empty, skipRuleContextcreation entirelyMETHOD_DOCis evaluated both inresolveApiName(as fallback) andresolveMethodDocβ cache the resultLocation
src/main/kotlin/com/itangcent/easyapi/exporter/springmvc/SpringMvcClassExporter.kt:90-160src/main/kotlin/com/itangcent/easyapi/psi/helper/ApiMetadataResolver.kt