Page MenuHomeFreeBSD

Reduce the number of calls to reset the keepalive timer
ClosedPublic

Authored by jtl on Oct 13 2016, 6:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 22 2024, 3:35 PM
Unknown Object (File)
Oct 3 2024, 8:47 AM
Unknown Object (File)
Oct 2 2024, 6:13 PM
Unknown Object (File)
Oct 1 2024, 8:27 PM
Unknown Object (File)
Sep 30 2024, 2:00 AM
Unknown Object (File)
Sep 28 2024, 12:24 PM
Unknown Object (File)
Sep 28 2024, 4:16 AM
Unknown Object (File)
Sep 26 2024, 5:22 AM
Subscribers

Details

Summary

The code currently resets the keepalive timer each time a packet is received on a TCP session that has entered the ESTABLISHED state. This results in a lot of calls to reset the keepalive timer.

This patch changes the behavior so we set the keepalive timer for the keepalive idle time (TP_KEEPIDLE). When the keepalive timer fires, it will first check to see if the session has been idle for TP_KEEPIDLE ticks. If not, it will reschedule the keepalive timer for the time the session will have been idle for TP_KEEPALIVE ticks.

For a session with regular communication, the keepalive timer should fire approximately once every TP_KEEPIDLE ticks. For sessions with irregular communication, the keepalive timer might fire more often. But, the disruption from a periodic keepalive timer should be less than the regular cost of resetting the keepalive timer on every packet.

MFC after: 2 weeks

Test Plan

(Not done yet.) Grab performance metrics from a live system.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 5596
Build 5857: arc lint + arc unit

Event Timeline

jtl retitled this revision from to Reduce the number of calls to reset the keepalive timer.
jtl updated this object.
jtl edited the test plan for this revision. (Show Details)
jtl added reviewers: gallatin, rrs.
rrs edited edge metadata.

I think that a grand idea :)

This revision is now accepted and ready to land.Oct 14 2016, 2:08 PM
gallatin edited edge metadata.

This seems like a great idea. I don't see any downside.

This revision was automatically updated to reflect the committed changes.

Like.

head/sys/netinet/tcp_timer.c
473 ↗(On Diff #21390)

I'd suggest comment change. It should explain not only why we do this check, rather than why we don't reset.

Suggested text to be checked by native speaker:
"We don't reschedule the keepalive callout on every packet, because that costs a lot of CPU cycles. Cheaper to actually
execute the callout once it expires and check against tp->t_rcvtime. If the check doesn't pass, schedule next keepalive
and return."