This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
refactor: 重构依赖解析方法。取消递归并增加类型成员缓存,消除在大量依赖和循环依赖下的性能问题。 #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
实际使用中随着服务越来越多,依赖越来越复杂,逐渐产生了Autowired注入耗时过长问题——72个内部相互依赖的服务,注入时间达到1500ms。(虽然这样依赖并不合理 😄 )
经过排查优化,消除了递归解析与递归验证实例存在的方式,同样场景下注入时间减少至个位数。
原逻辑为上层路径的实例与当前类型匹配则复用(
GetInstance
);现调整为绝对相等才可复用instaceSet.Contains
。假设有 IBiz 继承 IBase,那么原来由IBiz得到的实例可以给IBase复用;现在解析为两个对象,与官方
GetService<T>
保持一致。希望大佬审阅,择机发版 😄