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

why counter is very big? #825

Closed
lslhcqy123 opened this issue Oct 12, 2023 · 5 comments
Closed

why counter is very big? #825

lslhcqy123 opened this issue Oct 12, 2023 · 5 comments
Labels

Comments

@lslhcqy123
Copy link

lslhcqy123 commented Oct 12, 2023

Hey.i want to ask a question about the value of cpu counter.
First,what's the meaning of cpu counter?
Second,why the cpu counter is so big?
the command like: ./profiler.sh -e cpu xxx
I use async-profiler v2.8.3 to monitor a simple java program of cpu event,and i got very big counter.
So i add logs in code like follow in perfEvents_linux.cpp:

void PerfEvents::signalHandler(int signo, siginfo_t* siginfo, void* ucontext) {
    if (siginfo->si_code <= 0) {
        // Looks like an external signal; don't treat as a profiling event
        return;
    }

    if (_enabled) {
        u64 counter = readCounter(siginfo, ucontext);
        ExecutionEvent event;
        printf("enter PerfEvents::signalHandler,counter:%ld\n",counter);
        Profiler::instance()->recordSample(ucontext, counter, PERF_SAMPLE, &event);
    } else {
        resetBuffer(OS::threadId());
    }

    ioctl(siginfo->si_fd, PERF_EVENT_IOC_RESET, 0);
    ioctl(siginfo->si_fd, PERF_EVENT_IOC_REFRESH, 1);
}

And i got the log like follows:
"enter PerfEvents::signalHandler,counter:10140865".
I am really confused why the counter is so big when the siginfo is 0.
Any reply is grateful.

@apangin
Copy link
Collaborator

apangin commented Oct 12, 2023

what's the meaning of cpu counter

CPU time in nanoseconds

why the cpu counter is so big?

10140865 nanoseconds = 10.14 milliseconds.

The default profiling interval is 10 ms; this means, one CPU sample is generated approximately for every 10 ms of CPU time spent in one thread. The counter value reflects the time spent since the last sample - in your example, it expectedly matches the default profiling interval.

@lslhcqy123
Copy link
Author

Thank you,I got it !

@lslhcqy123
Copy link
Author

One more question please:
If i choose --alloc 32k, what's the unit of counter,byte or kbyte? @apangin

@apangin
Copy link
Collaborator

apangin commented Oct 13, 2023

In allocation profile, counter is always in bytes.

@lslhcqy123
Copy link
Author

ok,thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants