iovisor / iovisor/bcc

funclatency does not show all stats for interested functions

Open
#2,968 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
22.7k
Forks
4.1k
Avg merge
10d 4h
Merged PRs (30d)
3

Description

```
// main.c
#include
#include

void funcB() {
printf("B\n");
}

void funcD() {
printf("D\n");
}

void funcC() {
printf("C\n");
funcD();
funcD();
}

void funcA() {
printf("A\n");
funcB();
funcB();
funcB();
funcB();
funcC();
funcB();
}

int main(void)
{
funcA();
return 0;
}
```
compile it with `gcc -o main main.c -O0 -g3`

```
[root@centos7 ~]# /usr/share/bcc/tools/funclatency -u -F ~/main:func*
Tracing 4 functions for "/root/main:func*"... Hit Ctrl-C to end.
^C

Function = [unknown] [25721]
usecs : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 1 |****************************************|
8 -> 15 : 1 |****************************************|

Function = [unknown] [25721]
usecs : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 4 |****************************************|
8 -> 15 : 1 |********** |
Detaching...
```
I try to get the latency for all function calls in this program with pattern `func*`, but the output only print out `funcB` (called 5 times) and `funcD` (called 2 times). Notice they happen to be the function without further nested calls.

If I just trace `funcC`, it does show stats for `funcC`
```
[root@centos7 ~]# /usr/share/bcc/tools/funclatency -u -F ~/main:funcC
Tracing 1 functions for "/root/main:funcC"... Hit Ctrl-C to end.
^C

Function = [unknown] [25785]
usecs : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 0 | |
8 -> 15 : 0 | |
16 -> 31 : 1 |****************************************|
Detaching...
```

Q: **Why `funcA` and `funcC`'s latency stats are missing for the first run? Is this a defect of bcc?**

---
funccount does show the count of each func on pattern `func*`
```
[root@centos7 ~]# /usr/share/bcc/tools/funccount ~/main:func*
Tracing 4 functions for "/root/main:func*"... Hit Ctrl-C to end.
^C
FUNC COUNT
funcA 1
funcC 1
funcD 2
funcB 5
Detaching...
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the report with the supplied main.c program and the funclatency commands using func* and funcC, then compare the output with funccount. Start at /usr/share/bcc/tools/funclatency and trace how matched functions are reported. Done means explaining the missing nested-function statistics and verifying the expected output for the supplied example.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.