Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions proxy/InkAPIInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,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()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you check this in APIHooks::clear()? I guess clean() could just return without doing anything if it's empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the "problem" is that APIHOoks as we did it can not be inlined, so it calls it 28 times for no good reason :/

h.clear();
}
}
m_hooks_p = false;
}
m_hooks_p = false;
}

template <typename ID, int N>
Expand Down