polycube icon indicating copy to clipboard operation
polycube copied to clipboard

Implement pcn_time_get_sec()

Open mauriciovasquezbernal opened this issue 6 years ago • 2 comments

Some services need to get a timestamp to implement an aging mechanism. eBPF provides the bpf_ktime_get_ns helper, however we identified this function is slow in different benchmarks.

pcn-simplebride [1] and pcn-iptables [2] implement this by having a map that stores a timestamp that is updated by a thread in user-space, this solution is not ideal as each cube instance has a different thread just to update the timestamp.

This feature should be implemented directly in polycube, having a single thread for all the system to update that counter.

[1] https://github.com/polycube-network/polycube/pull/56/commits/9a58dd347ae6f991b2f3b191eafae2c83d1e5a45 [2] https://github.com/polycube-network/polycube/blob/master/src/services/pcn-iptables/src/modules/ConntrackTableUpdate.cpp#L110

mauriciovasquezbernal avatar Feb 07 '19 14:02 mauriciovasquezbernal

@mauriciovasquezbernal do we get some benchmark for bpf_ktime_get_ns() performance? I see related discussion in the thread https://github.com/iovisor/bcc/issues/578, but it was closed without clear conclusion.

goldenrye avatar Apr 01 '19 00:04 goldenrye

@goldenrye no, unfortunately, we do not have numbers to show but we did some experiments in the past and we noticed a slow down in the performance when that function is used.

As a consequence, we decided on some services (e.g., pcn-iptables), which do not need a nanoseconds granularity, to use a different approach with a thread that updates a counter every second (as explained in this issue) and read that counter from the eBPF program itself.

sebymiano avatar Apr 04 '19 14:04 sebymiano