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

Speed up / lazy initialization #142

Closed
trydofor opened this issue Oct 18, 2023 · 4 comments
Closed

Speed up / lazy initialization #142

trydofor opened this issue Oct 18, 2023 · 4 comments
Labels
investigate :no_bell: something may be defective

Comments

@trydofor
Copy link
Owner

trydofor commented Oct 18, 2023

spring.main.lazy-initialization=true

  • the first request slower
  • miss some errors on startup
  • ClassNotFoundException during runtime

logging.level.org.springframework.boot.autoconfigure=DEBUG

to exclude unnecessary autoconfiguration

spring-context-indexer

@trydofor trydofor changed the title lazy-initialization Speed up / lazy initialization Oct 18, 2023
@trydofor trydofor added the investigate :no_bell: something may be defective label Oct 18, 2023
@trydofor
Copy link
Owner Author

avoid using expressions to scan, may be very slow.

@AfterReturning("execution(* com.abc.admin.controller.*.*(..)) || " +
        "execution(* com.abc.front.controller.*.*(..)) || " +
        "execution(* com.abc.devops.controller.*.*(..))")

@trydofor
Copy link
Owner Author

trydofor commented Oct 21, 2023

ConfigurationClassPostProcessor

BeanFactoryPostProcessor used for bootstrapping processing of @Configuration classes.
Registered by default when using <context:annotation-config/> or <context:component-scan/>. Otherwise, may be declared manually as with any other BeanFactoryPostProcessor.
This post processor is priority-ordered as it is important that any @Bean methods declared in @Configuration classes have their corresponding bean definitions registered before any other BeanFactoryPostProcessor executes.

  • Sort by previously determined @Order value, if applicable
  • LinkedHashSet - @Import or @ComponentScan

ConfigurationClassParser

Parses a Configuration class definition, populating a collection of ConfigurationClass objects (parsing a single Configuration class may result in any number of ConfigurationClass objects because one Configuration class may import another using the Import annotation).
This class helps separate the concern of parsing the structure of a Configuration class from the concern of registering BeanDefinition objects based on the content of that model (with the exception of @ComponentScan annotations which need to be registered immediately).
This ASM-based implementation avoids reflection and eager class loading in order to interoperate effectively with lazy class loading in a Spring ApplicationContext.

DeferredImportSelector to handle auto-configuration.

@AutoConfigureOrder sorted

  • *.AutoConfigureOrder.imports all together
  • each @ImportAutoConfiguration class as a group

see

  • EnableAutoConfiguration - AutoConfigurationImportSelector
  • ImportAutoConfiguration - ImportAutoConfigurationImportSelector

@trydofor
Copy link
Owner Author

trydofor commented Oct 23, 2023

https://github.com/trydofor/pro.fessional.wings-issue/tree/main/issue142

  • RULE1 - Auto vs Auto
  • RULE2 - .imports sort
  • RULE3 - @ImportAutoConfiguration sort

@trydofor
Copy link
Owner Author

trydofor commented Oct 26, 2023

user before instead of Order, Auto vs Auto, Conf vs Conf, remove unnecessary Scan

  • add spring-context-indexer
  • 💥 remove aegis module
  • 💥 remove wings ordering and naming
  • 💥 disable auto scan */spring/bean/*
  • 💥 move AutoConfig from boot to conf

trydofor added a commit that referenced this issue Oct 26, 2023
trydofor added a commit that referenced this issue Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate :no_bell: something may be defective
Projects
Archived in project
Development

No branches or pull requests

1 participant