You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2023/03/15 21:49:39 UTC
[trafficserver] branch 9.2.x updated: Slight performance improvements before calling APIHooks::clear (#9480)
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.2.x by this push:
new 782fbfdd1 Slight performance improvements before calling APIHooks::clear (#9480)
782fbfdd1 is described below
commit 782fbfdd1a0a557c19e09ef0d2972007cd2cba9c
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Wed Mar 15 15:48:37 2023 -0600
Slight performance improvements before calling APIHooks::clear (#9480)
(cherry picked from commit c54a2e2b77151869ff014fbdc4c82cec0afcbb8c)
---
proxy/InkAPIInternal.h | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/proxy/InkAPIInternal.h b/proxy/InkAPIInternal.h
index d140996af..9cad0eb0f 100644
--- a/proxy/InkAPIInternal.h
+++ b/proxy/InkAPIInternal.h
@@ -197,14 +197,24 @@ template <typename ID, int N> FeatureAPIHooks<ID, N>::~FeatureAPIHooks()
this->clear();
}
+// The APIHooks::clear() method can't be inlined (easily), and we end up calling
+// clear() very frequently (it's used in a number of features). A rough estimate
+// is that we may call APIHooks::clear() as much as 230x per transaction (there's
+// 180 additional APIHooks that should be eliminated in a different PR). This
+// code at least avoids calling this function for a majority of the cases.
+// Before this code, APIHooks::clear() would show up as top 5 in perf top.
template <typename ID, int N>
void
FeatureAPIHooks<ID, N>::clear()
{
- for (auto &h : m_hooks) {
- h.clear();
+ if (m_hooks_p) {
+ for (auto &h : m_hooks) {
+ if (!h.is_empty()) {
+ h.clear();
+ }
+ }
+ m_hooks_p = false;
}
- m_hooks_p = false;
}
template <typename ID, int N>