You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Yan-Daojiang (Code Review)" <ge...@cloudera.org> on 2026/09/04 07:51:01 UTC
[kudu-CR] [metrics] Avoid string allocations in metric filter matching
Yan-Daojiang has uploaded this change for review. ( http://gerrit.cloudera.org:8080/24789
Change subject: [metrics] Avoid string allocations in metric filter matching
......................................................................
[metrics] Avoid string allocations in metric filter matching
Metric filtering (the ?types=/?ids=/?attributes=/?metrics= query
parameters on the /metrics and /metrics_prometheus endpoints) is
implemented via MatchName(), a case-insensitive substring match. The
previous implementation allocated two uppercased std::string copies on
every single comparison. Because the metric-name filter runs once per
metric per entity per filter term, a scrape of a cluster with many
tablets could trigger hundreds of thousands of short-lived heap
allocations per request.
This patch rewrites MatchName() to perform the case-insensitive
substring search in place with std::search() and ascii_toupper(),
allocating nothing. The attribute-value filter is also switched from
MatchNameInList() with a single-element initializer list to a direct
MatchName() call, removing a per-attribute temporary std::vector.
The change is behavior-preserving: an empty pattern still matches
everything (mirroring string::find("")), and matching remains a
case-insensitive ASCII substring test. A new TestFilterMatchNameSemantics
covers exact/substring/mixed-case/multi-term/empty-pattern metric-name
matching and case-insensitive attribute-value matching.
Change-Id: Id283467cd9e1b6ea992f7acbe9b5f9e3ae6693d8
---
M src/kudu/util/metrics-test.cc
M src/kudu/util/metrics.cc
2 files changed, 101 insertions(+), 10 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/89/24789/1
--
To view, visit http://gerrit.cloudera.org:8080/24789
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id283467cd9e1b6ea992f7acbe9b5f9e3ae6693d8
Gerrit-Change-Number: 24789
Gerrit-PatchSet: 1
Gerrit-Owner: Yan-Daojiang <ya...@163.com>
[kudu-CR] [metrics] Avoid string allocations in metric filter matching
Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( http://gerrit.cloudera.org:8080/24789 )
Change subject: [metrics] Avoid string allocations in metric filter matching
......................................................................
Patch Set 1: Verified+1
unrelated test failures:
tsan: org.apache.kudu.client.TestSecurity, org.apache.kudu.client.TestScanToken
--
To view, visit http://gerrit.cloudera.org:8080/24789
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id283467cd9e1b6ea992f7acbe9b5f9e3ae6693d8
Gerrit-Change-Number: 24789
Gerrit-PatchSet: 1
Gerrit-Owner: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Comment-Date: Fri, 04 Sep 2026 09:40:20 +0000
Gerrit-HasComments: No
[kudu-CR] [metrics] Avoid string allocations in metric filter matching
Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24789 )
Change subject: [metrics] Avoid string allocations in metric filter matching
......................................................................
Patch Set 1:
Build Started http://jenkins.kudu.apache.org/job/pre_commit/2939/
--
To view, visit http://gerrit.cloudera.org:8080/24789
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id283467cd9e1b6ea992f7acbe9b5f9e3ae6693d8
Gerrit-Change-Number: 24789
Gerrit-PatchSet: 1
Gerrit-Owner: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Fri, 04 Sep 2026 07:51:07 +0000
Gerrit-HasComments: No
[kudu-CR] [metrics] Avoid string allocations in metric filter matching
Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( http://gerrit.cloudera.org:8080/24789 )
Change subject: [metrics] Avoid string allocations in metric filter matching
......................................................................
Patch Set 1: Code-Review+2
LGTM!
--
To view, visit http://gerrit.cloudera.org:8080/24789
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id283467cd9e1b6ea992f7acbe9b5f9e3ae6693d8
Gerrit-Change-Number: 24789
Gerrit-PatchSet: 1
Gerrit-Owner: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Comment-Date: Fri, 04 Sep 2026 08:45:28 +0000
Gerrit-HasComments: No
[kudu-CR] [metrics] Avoid string allocations in metric filter matching
Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has removed a vote on this change.
Change subject: [metrics] Avoid string allocations in metric filter matching
......................................................................
Removed Verified-1 by Kudu Jenkins (120)
--
To view, visit http://gerrit.cloudera.org:8080/24789
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: deleteVote
Gerrit-Change-Id: Id283467cd9e1b6ea992f7acbe9b5f9e3ae6693d8
Gerrit-Change-Number: 24789
Gerrit-PatchSet: 1
Gerrit-Owner: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
[kudu-CR] [metrics] Avoid string allocations in metric filter matching
Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/24789 )
Change subject: [metrics] Avoid string allocations in metric filter matching
......................................................................
[metrics] Avoid string allocations in metric filter matching
Metric filtering (the ?types=/?ids=/?attributes=/?metrics= query
parameters on the /metrics and /metrics_prometheus endpoints) is
implemented via MatchName(), a case-insensitive substring match. The
previous implementation allocated two uppercased std::string copies on
every single comparison. Because the metric-name filter runs once per
metric per entity per filter term, a scrape of a cluster with many
tablets could trigger hundreds of thousands of short-lived heap
allocations per request.
This patch rewrites MatchName() to perform the case-insensitive
substring search in place with std::search() and ascii_toupper(),
allocating nothing. The attribute-value filter is also switched from
MatchNameInList() with a single-element initializer list to a direct
MatchName() call, removing a per-attribute temporary std::vector.
The change is behavior-preserving: an empty pattern still matches
everything (mirroring string::find("")), and matching remains a
case-insensitive ASCII substring test. A new TestFilterMatchNameSemantics
covers exact/substring/mixed-case/multi-term/empty-pattern metric-name
matching and case-insensitive attribute-value matching.
Change-Id: Id283467cd9e1b6ea992f7acbe9b5f9e3ae6693d8
Reviewed-on: http://gerrit.cloudera.org:8080/24789
Reviewed-by: Marton Greber <gr...@gmail.com>
Tested-by: Marton Greber <gr...@gmail.com>
Reviewed-by: Alexey Serbin <al...@apache.org>
---
M src/kudu/util/metrics-test.cc
M src/kudu/util/metrics.cc
2 files changed, 101 insertions(+), 10 deletions(-)
Approvals:
Marton Greber: Looks good to me, approved; Verified
Alexey Serbin: Looks good to me, approved
--
To view, visit http://gerrit.cloudera.org:8080/24789
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id283467cd9e1b6ea992f7acbe9b5f9e3ae6693d8
Gerrit-Change-Number: 24789
Gerrit-PatchSet: 2
Gerrit-Owner: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
[kudu-CR] [metrics] Avoid string allocations in metric filter matching
Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/24789 )
Change subject: [metrics] Avoid string allocations in metric filter matching
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.cloudera.org:8080/24789
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id283467cd9e1b6ea992f7acbe9b5f9e3ae6693d8
Gerrit-Change-Number: 24789
Gerrit-PatchSet: 1
Gerrit-Owner: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Comment-Date: Fri, 04 Sep 2026 14:26:54 +0000
Gerrit-HasComments: No
[kudu-CR] [metrics] Avoid string allocations in metric filter matching
Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24789 )
Change subject: [metrics] Avoid string allocations in metric filter matching
......................................................................
Patch Set 1: Verified-1
Build Failed
http://jenkins.kudu.apache.org/job/pre_commit/2939/ : FAILURE
--
To view, visit http://gerrit.cloudera.org:8080/24789
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id283467cd9e1b6ea992f7acbe9b5f9e3ae6693d8
Gerrit-Change-Number: 24789
Gerrit-PatchSet: 1
Gerrit-Owner: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Comment-Date: Fri, 04 Sep 2026 09:05:13 +0000
Gerrit-HasComments: No