Merge pull request #9954 from zmstone/0210-perf-do-not-make-gen_server-call-after-each-resource-ets-lookup
perf: avoid getting metrics (gen_server:call) for each resource lookup
This commit is contained in:
commit
910731c075
|
@ -46,7 +46,7 @@ emqx_bridge_api {
|
|||
|
||||
desc_param_path_enable {
|
||||
desc {
|
||||
en: """Whether or not the bridge is enabled"""
|
||||
en: """Whether to enable this bridge"""
|
||||
zh: """是否启用桥接"""
|
||||
}
|
||||
label: {
|
||||
|
|
|
@ -159,7 +159,7 @@ broker MUST support this feature."""
|
|||
|
||||
clean_start {
|
||||
desc {
|
||||
en: "Whether or not to start a clean session when reconnecting a remote broker for ingress bridge"
|
||||
en: "Whether to start a clean session when reconnecting a remote broker for ingress bridge"
|
||||
zh: "与 ingress MQTT 桥的远程服务器重连时是否清除老的 MQTT 会话。"
|
||||
}
|
||||
label: {
|
||||
|
|
|
@ -57,7 +57,7 @@ It's enum with `stomp`, `mqttsn`, `coap`, `lwm2m`, `exproto`"""
|
|||
|
||||
gateway_enable_in_path {
|
||||
desc {
|
||||
en: """Whether or not gateway is enabled"""
|
||||
en: """Whether to enable this gateway"""
|
||||
|
||||
zh: """是否开启此网关"""
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
config := resource_config(),
|
||||
state := resource_state(),
|
||||
status := resource_status(),
|
||||
metrics := emqx_metrics_worker:metrics()
|
||||
metrics => emqx_metrics_worker:metrics()
|
||||
}.
|
||||
-type resource_group() :: binary().
|
||||
-type creation_opts() :: #{
|
||||
|
|
|
@ -238,7 +238,7 @@ lookup(ResId) ->
|
|||
ets_lookup(ResId) ->
|
||||
case read_cache(ResId) of
|
||||
{Group, Data} ->
|
||||
{ok, Group, data_record_to_external_map_with_metrics(Data)};
|
||||
{ok, Group, data_record_to_external_map(Data)};
|
||||
not_found ->
|
||||
{error, not_found}
|
||||
end.
|
||||
|
@ -620,8 +620,8 @@ maybe_reply(Actions, undefined, _Reply) ->
|
|||
maybe_reply(Actions, From, Reply) ->
|
||||
[{reply, From, Reply} | Actions].
|
||||
|
||||
-spec data_record_to_external_map_with_metrics(data()) -> resource_data().
|
||||
data_record_to_external_map_with_metrics(Data) ->
|
||||
-spec data_record_to_external_map(data()) -> resource_data().
|
||||
data_record_to_external_map(Data) ->
|
||||
#{
|
||||
id => Data#data.id,
|
||||
mod => Data#data.mod,
|
||||
|
@ -629,10 +629,14 @@ data_record_to_external_map_with_metrics(Data) ->
|
|||
query_mode => Data#data.query_mode,
|
||||
config => Data#data.config,
|
||||
status => Data#data.status,
|
||||
state => Data#data.state,
|
||||
metrics => get_metrics(Data#data.id)
|
||||
state => Data#data.state
|
||||
}.
|
||||
|
||||
-spec data_record_to_external_map_with_metrics(data()) -> resource_data().
|
||||
data_record_to_external_map_with_metrics(Data) ->
|
||||
DataMap = data_record_to_external_map(Data),
|
||||
DataMap#{metrics => get_metrics(Data#data.id)}.
|
||||
|
||||
-spec wait_for_ready(resource_id(), integer()) -> ok | timeout | {error, term()}.
|
||||
wait_for_ready(ResId, WaitTime) ->
|
||||
do_wait_for_ready(ResId, WaitTime div ?WAIT_FOR_RESOURCE_DELAY).
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Improve bridge performance
|
|
@ -0,0 +1 @@
|
|||
优化桥接性能
|
|
@ -26,8 +26,8 @@ item() {
|
|||
}
|
||||
|
||||
section() {
|
||||
local section_name=$1
|
||||
for i in "${changes_dir}"/"${section_name}"-*."${language}".md; do
|
||||
local prefix=$1
|
||||
for i in "${changes_dir}"/"${prefix}"-*."${language}".md; do
|
||||
item "${i}"
|
||||
done
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ if [ "${language}" = "en" ]; then
|
|||
## Enhancements
|
||||
|
||||
$(section feat)
|
||||
$(section perf)
|
||||
|
||||
## Bug fixes
|
||||
|
||||
|
|
Loading…
Reference in New Issue