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(config): read zone conf once #10790
Merged
qzhuyan
merged 13 commits into
emqx:release-51
from
qzhuyan:perf/william/explicit-default-zone
Jun 1, 2023
Merged
perf(config): read zone conf once #10790
qzhuyan
merged 13 commits into
emqx:release-51
from
qzhuyan:perf/william/explicit-default-zone
Jun 1, 2023
Conversation
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
qzhuyan
force-pushed
the
perf/william/explicit-default-zone
branch
9 times, most recently
from
May 26, 2023 11:22
593590d
to
4e753ce
Compare
qzhuyan
force-pushed
the
perf/william/explicit-default-zone
branch
5 times, most recently
from
May 30, 2023 06:28
47177a7
to
ce63b7f
Compare
note, with many different attempts in the PR, need to squash the commits before the merge. |
qzhuyan
commented
May 30, 2023
qzhuyan
force-pushed
the
perf/william/explicit-default-zone
branch
from
May 30, 2023 13:36
16c03f9
to
5c3707d
Compare
qzhuyan
changed the title
WIP: perf(config): read zone conf once
perf(config): read zone conf once
May 30, 2023
qzhuyan
commented
May 31, 2023
qzhuyan
commented
May 31, 2023
qzhuyan
commented
May 31, 2023
qzhuyan
commented
May 31, 2023
qzhuyan
commented
May 31, 2023
qzhuyan
commented
May 31, 2023
also improve: emqx_mgmt_caps:get_caps |
qzhuyan
force-pushed
the
perf/william/explicit-default-zone
branch
from
May 31, 2023 09:51
85973d3
to
2148dde
Compare
lafirest
reviewed
May 31, 2023
lafirest
reviewed
May 31, 2023
qzhuyan
force-pushed
the
perf/william/explicit-default-zone
branch
from
June 1, 2023 08:35
3d47689
to
9f964a1
Compare
need squash after review |
zhongwencool
approved these changes
Jun 1, 2023
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.
LGTM
test with schema defaults
qzhuyan
force-pushed
the
perf/william/explicit-default-zone
branch
from
June 1, 2023 12:58
9f964a1
to
eea0336
Compare
Enhancements
|
增强
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes EMQX-9801
Summary
Prior to this change, the
default
zone could be referenced by the listeners and it is not necessarily an item in the CONF PT if it is not defined under rootzones
by user .Reading config for the zone must be done through the
emqx_config:get_zone_conf/2
in which it first reads if thedefault
zone exists in the config, otherwise it fallback to reading from the root of EMQX as the default fallback. If thedefault
zone does exist but the field is undefined, it will fallback to read from default as well.Generally, it has the following issues:
Inconsistent return val of
emqx_config:get_zone_conf(default,[])
andemqx_config:get([zones, default])
that one of them return some value another read failure.Always read the config twice if no user-defined
default
zone or the field is undefined. (first read miss then fallback to default) which hurts overall performance if read is done in the hot code path.Read a zone with a none existing zone name (not
default
) will also return values that may confuse the users.In this PR:
In CONF, The default zone which is referenced by the listeners is now explicitly inserted into the runtime config during emqx config initialization during emqx schema loading. the values are merged with zone global defaults and user-defined values.
in RAWCONF, it remains unchanged and it keeps a copy of user-defined configs for reference
When there is an update on the global defaults, it will be merged into the zones.
When there is an update on the existing zone, it is just a regular update no merge with global defaults.
When there is an insertion of new zones, they will be merged with zone global defaults
During initialization, loading config order is enforced. load
zones
after the other ROOTs.Breaking changes:
emqx_schema
is loaded, CONF PT stores the runtime config that has adefault
zone with complete children fields all setzones
(<<"zones">>)PR Checklist
Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:
changes/{ce,ee}/(feat|perf|fix)-<PR-id>.en.md
filesChecklist for CI (.github/workflows) changes
changes/
dir for user-facing artifacts update