From 429c364e8c9e33eef8edab0c144c10105efac3f8 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Tue, 5 Oct 2010 21:21:38 +0100 Subject: [PATCH] rx: Don't call gettimeofday for every packet ack Every time we receive an ACK packet, we call gettimeofday() for every entry in the transmit queue that's permanently ack'd by that packet. Instead, just make a note of the time when we start processing the packet queue, and use it for every packet in the queue. This shaves around 5% off rxperf's runtime with a window size of 128. Reviewed-on: http://gerrit.openafs.org/2956 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman (cherry picked from commit e16d7b7d6a6980fbda3186a578fb7e26fc334194) Change-Id: Ib77ea09f2b2334ccae269a5e24519cd8b0f0875a Reviewed-on: http://gerrit.openafs.org/3059 Tested-by: Derrick Brashear --- src/rx/rx.c | 29 ++++++++++++++++++----------- src/rx/rx_prototypes.h | 3 --- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/rx/rx.c b/src/rx/rx.c index bceda5cad..6a4737096 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -123,6 +123,9 @@ int (*swapNameProgram) (PROCESS, const char *, char *) = 0; /* Local static routines */ static void rxi_DestroyConnectionNoLock(struct rx_connection *conn); +static void rxi_ComputeRoundTripTime(struct rx_packet *, struct clock *, + struct rx_peer *, struct clock *); + #ifdef RX_ENABLE_LOCKS static void rxi_SetAcksInTransmitQueue(struct rx_call *call); #endif @@ -3807,7 +3810,8 @@ rx_ack_reason(int reason) */ static void rxi_ComputePeerNetStats(struct rx_call *call, struct rx_packet *p, - struct rx_ackPacket *ap, struct rx_packet *np) + struct rx_ackPacket *ap, struct rx_packet *np, + struct clock *now) { struct rx_peer *peer = call->conn->peer; @@ -3816,7 +3820,7 @@ rxi_ComputePeerNetStats(struct rx_call *call, struct rx_packet *p, if (!(p->flags & RX_PKTFLAG_ACKED) && ap->reason != RX_ACK_DELAY && clock_Eq(&p->timeSent, &p->firstSent)) - rxi_ComputeRoundTripTime(p, &p->timeSent, peer); + rxi_ComputeRoundTripTime(p, &p->timeSent, peer, now); #ifdef ADAPT_WINDOW rxi_ComputeRate(peer, call, p, np, ap->reason); #endif @@ -3833,6 +3837,7 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np, struct rx_packet *nxp; /* Next packet pointer for queue_Scan */ struct rx_connection *conn = call->conn; struct rx_peer *peer = conn->peer; + struct clock now; /* Current time, for RTT calculations */ afs_uint32 first; afs_uint32 serial; /* because there are CM's that are bogus, sending weird values for this. */ @@ -3966,11 +3971,14 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np, * acknowledged as having been sent to the peer's upper level. * All other packets must be retained. So only packets with * sequence numbers < ap->firstPacket are candidates. */ + + clock_GetTime(&now); + for (queue_Scan(&call->tq, tp, nxp, rx_packet)) { if (tp->header.seq >= first) break; call->tfirst = tp->header.seq + 1; - rxi_ComputePeerNetStats(call, tp, ap, np); + rxi_ComputePeerNetStats(call, tp, ap, np, &now); if (!(tp->flags & RX_PKTFLAG_ACKED)) { newAckCount++; } @@ -4032,7 +4040,7 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np, if (tp->header.seq >= first) #endif /* RX_ENABLE_LOCKS */ #endif /* AFS_GLOBAL_RXLOCK_KERNEL */ - rxi_ComputePeerNetStats(call, tp, ap, np); + rxi_ComputePeerNetStats(call, tp, ap, np, &now); /* Set the acknowledge flag per packet based on the * information in the ack packet. An acknowlegded packet can @@ -6379,21 +6387,20 @@ rxi_ChallengeOn(struct rx_connection *conn) /* rxi_ComputeRoundTripTime is called with peer locked. */ /* sentp and/or peer may be null */ -void +static void rxi_ComputeRoundTripTime(struct rx_packet *p, struct clock *sentp, - struct rx_peer *peer) + struct rx_peer *peer, + struct clock *now) { struct clock thisRtt, *rttp = &thisRtt; - int rtt_timeout; - clock_GetTime(rttp); + thisRtt = *now; - if (clock_Lt(rttp, sentp)) { - clock_Zero(rttp); + if (clock_Lt(rttp, sentp)) return; /* somebody set the clock back, don't count this time. */ - } + clock_Sub(rttp, sentp); dpf(("rxi_ComputeRoundTripTime(call=%d packet=%"AFS_PTR_FMT" rttp=%d.%06d sec)\n", p->header.callNumber, p, rttp->sec, rttp->usec)); diff --git a/src/rx/rx_prototypes.h b/src/rx/rx_prototypes.h index 383d2ed23..2d8adc85a 100644 --- a/src/rx/rx_prototypes.h +++ b/src/rx/rx_prototypes.h @@ -188,9 +188,6 @@ extern void rxi_ChallengeEvent(struct rxevent *event, void *conn, /* struct rx_connection *conn */ void *arg1, int atries); extern void rxi_ChallengeOn(struct rx_connection *conn); -extern void rxi_ComputeRoundTripTime(struct rx_packet *p, - struct clock *sentp, - struct rx_peer *peer); extern void rxi_ReapConnections(struct rxevent *unused, void *unused1, void *unused2); extern int rxs_Release(struct rx_securityClass *aobj); -- 2.39.5