time-control problem for function perf_buffer_poll
- Dominant language
- C
- Stars
- 22.7k
- Forks
- 4.1k
- Avg merge
- 10d 4h
- Merged PRs (30d)
- 3
Description
I try to use bcc to monitor kernel level context switch in a fixed period of time. However, I find it hard to make perf_buffer_poll() work just for a fixed period of time. It would process for a much longer time than I want. I am wondering why this happen.
Here is part of my code.
```python
def collect_event(self, cpu, data, size):
event = b["events"].event(data)
event_list.append(event)
b = BPF(text=bpf_text)
b["events"].open_perf_buffer(collect_event, 32768)
print("begin "+str(time.time()))
cur = time.time()
while time.time() - cur < 10:
try:
b.perf_buffer_poll(1000)
except KeyboardInterrupt:
exit()
print("end "+str(time.time()))
```
a sample output just like this:
**begin 1652253042.23
end 1652253119.77**
it runs for more than 70 seconds but I want it stop after 10 seconds.
The experiment environment is a physical machine with multiple busy containers. I can get about 50MB data in 10 seconds by using bcc.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.