Skip to content
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

Refine collect scope function and reduce system call overhead #21

Closed
wants to merge 0 commits into from

Conversation

zhochi01
Copy link
Contributor

  1. Fix main thread counter, only reserve main thread cpu cycles event.
  2. Replace read syscall with PMEVCNTR2_EL0 to reduce extra overhead.
  3. Add PMU validation related check.

mSet = mConfig.get("set", -1).asInt();
mInherit = mConfig.get("inherit", 1).asInt();
mInherit = mConfig.get("inherit", 0).asInt();
Copy link
Collaborator

@kexia01 kexia01 Dec 16, 2024

Choose a reason for hiding this comment

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

Keep default value as 1, as most test cases, especially the ST tests, use "1" by default.
For perAPI, setting "inherit" in input json file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has been changed in new commit.

@@ -698,6 +617,7 @@ void PerfCollector::summarize()
bool event_context::init(std::vector<struct event> &events, int tid, int cpu)
{
struct counter grp;
grp.name = "CPUCycleCount";
Copy link
Collaborator

Choose a reason for hiding this comment

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

grp.name is overridden later by events.name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed this in new commit.

interface.cpp Outdated Show resolved Hide resolved
test.cpp Outdated
@@ -348,16 +348,18 @@ class Test8 {
tmp *= rand();
};

pid_t tid = syscall(SYS_gettid);

Copy link
Collaborator

Choose a reason for hiding this comment

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

in test8, Collection is created without enablePerapiPerf enabled. (see Line 322)
collect_scope_start/stop for per API performance does work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have refactored the test case and have made it worked. But I removed all of background threads since we really don't want to capture any background threads cycles for per api. It's only designed for profiling main thread performance.

{
t.eventCtx.collect_scope(now, func_id, false);
}
mReplayThreads[tid].eventCtx.collect_scope(func_id, false, get_pmu_bits());
Copy link
Collaborator

@kexia01 kexia01 Dec 16, 2024

Choose a reason for hiding this comment

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

  1. consider multiple pmus
  2. mReplayThreads is vector, and tid is not the index of mReplayThreads.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your advice. But the per api new function only want to focus on the CPU cycles. And it will only read cycles event counter register. So I wonder if it is not necessary to support multi-events in this case?

volatile uint64_t pmcr_el0;
asm volatile("mrs %0, PMCR_EL0" : "=r"(pmcr_el0));
pmu_counter_bits = ((pmcr_el0 & 0x80) == 0x80 ? 64 : 32);
if (!mConfig.isMember("type")) exit(EXIT_FAILURE);
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a "type" field in mConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I found this type is different for different platforms. And if the type is wrong, PMEVCNTR2_EL0 register will read nothing. So I wonder if it's possible to set by json file.

collectors/perf.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants