On Tue, 8 Sep 2026 18:13:13 +0000
Martin Schitter
--- netlink.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/netlink.c b/netlink.c index 650a6fd..65cc5d7 100644 --- a/netlink.c +++ b/netlink.c @@ -18,6 +18,7 @@ #include
#include #include +#include #include #include #include @@ -604,6 +605,7 @@ int nl_route_dup(int s_src, unsigned int ifi_src, char buf[NLBUFSIZ * 8]; uint32_t seq; unsigned i; + struct timespec start, now; seq = nl_send(s_src, &req, RTM_GETROUTE, NLM_F_DUMP, sizeof(req));
@@ -706,6 +708,7 @@ int nl_route_dup(int s_src, unsigned int ifi_src, * can safely ignore that and repeat the requests. This avoids the need * to calculate dependencies: let the kernel do that. */ + clock_gettime(CLOCK_MONOTONIC, &start);
This adds overhead (even if minimal) in a general case, but it's only used for debug() messages.
for (i = 0; i < dup_routes; i++) { for (nh = (struct nlmsghdr *)buf, left = nlmsgs_size; NLMSG_OK(nh, left); @@ -724,6 +727,9 @@ int nl_route_dup(int s_src, unsigned int ifi_src, return rc; } } + clock_gettime(CLOCK_MONOTONIC, &now); + debug("route dependency handling time: %f s", + (now.tv_sec - start.tv_sec) + (now.tv_nsec - start.tv_nsec)/1.0e9);
And anyway, I'm not sure I see the value of this. Which other functions should we profile? Does it help at all to do this once you're done developing it? I would suggest to simply drop this patch. I understand you needed that for development but you already explain in the commit message for 3/3 how it improves thing, and that's all the documentation we possibly need for the future, I think.
return 0; }
-- Stefano