-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
perf: speed up the first loading of namespace when startup meet 404 #61
Merged
nobodyiam
merged 10 commits into
apolloconfig:main
from
Anilople:perf/speed-up-when-startup
May 18, 2024
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4a35cca
perf: speed up then first time loading of namespace when meet 404
Anilople bd66c13
test: fix the number of http requests
Anilople 8e3fd24
test: fix
Anilople 060fd4d
test: use mockserver-netty to refactor test case
Anilople 2b27120
add apache LICENSE-2.0
Anilople 7b76640
feat: add initialize method
Anilople 366766f
fix
Anilople 9baf77f
Update CHANGES.md
Anilople d413a6a
test: use initialize instead of trySync
Anilople 406042e
fix: change to default empty implementation for compability
Anilople File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to call trySync?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to
trySync
here will slower startup. Let me try to illustrate it.1. everything from the rate limiter in RemoteConfigRepository
If we do not wait for 2 consecutive calls to method
sync
, the rateLimter in RemoteConfigRepository will block current thread 500ms on the second call because codem_loadConfigRateLimiter.tryAcquire(5, TimeUnit.SECONDS)
, that is why so slower when startup.apollo-java/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java
Lines 182 to 188 in bcc4053
2. how to solve it?
There are 2 solution to speed up.
solution 1: forbid 2 consecutive calls to method
sync
,solution 2: use another method on m_loadConfigRateLimiter let it won't block current thread 500ms .
3. Back to talk about method
initialize
in DefaultConfig.According to the code
apollo-java/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
Lines 72 to 78 in bcc4053
m_configRepository.getConfig() will invoke method
sync
.When we change to code
m_configRepository.initialize();
andm_configRepository.getConfig()
alway invoke methodsync
,i.e 2 consecutive calls to method
sync
, that will let startup slower.But the different in
m_configRepository.initialize();
, if we usesync
instead oftrySync
,the exception will throw quickly, so
updateConfig(m_configRepository.getConfig(), m_configRepository.getSourceType());
won't execute,i.e choose solution 1: forbid 2 consecutive calls to method
sync
to speed up.That's why use
sync
instead oftrySync
here.Maybe there is better solution here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. Let's keep it as it is.