Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

refactor: 重构依赖解析方法。取消递归并增加类型成员缓存,消除在大量依赖和循环依赖下的性能问题。 #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

softworm
Copy link
Contributor

  1. 解决了部分场景下的性能问题。

实际使用中随着服务越来越多,依赖越来越复杂,逐渐产生了Autowired注入耗时过长问题——72个内部相互依赖的服务,注入时间达到1500ms。(虽然这样依赖并不合理 😄 )

经过排查优化,消除了递归解析与递归验证实例存在的方式,同样场景下注入时间减少至个位数。

  1. 循环依赖的判定规则进行调整

原逻辑为上层路径的实例与当前类型匹配则复用(GetInstance);现调整为绝对相等才可复用instaceSet.Contains

假设有 IBiz 继承 IBase,那么原来由IBiz得到的实例可以给IBase复用;现在解析为两个对象,与官方GetService<T>保持一致。

希望大佬审阅,择机发版 😄

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant