Opened 12 years ago

Closed 12 years ago

#3662 closed Enhancement (fixed)

libtransmission cpu optimization: fewer calls to tr_time_msec()

Reported by: charles Owned by: charles
Priority: Normal Milestone: 2.12
Component: libtransmission Version: 2.11
Severity: Minor Keywords:
Cc:

Description

tr_time_msec() is fairly expensive for the number of times we call it. Its implementation is probably as cheap as we can make it, but there are several times where we call it inefficiently, such calling it twice within a few lines of code.

Change History (3)

comment:1 Changed 12 years ago by charles

  • updateDesiredRequestCount() takes time_msec as an argument, but it's only used in one branch and not others. However every caller invokes tr_time_msec() solely for using it as an argument for the call. So, we can reduce the number of calls to tr_time_msec() by removing it as an argument here.
  • peer-io's didWriteWrapper() calls tr_time_msec() twice within a couple of lines. We could call it once and remember the value.
  • peer-io's canReadWrapper() does the same.
  • fdlimit.c calls tr_time_msec() for the open files' timestamp field. This is overkill -- a time_t will suffice.
  • peer-mgr.c's getPeersToClose() calls tr_time_msec() for each torrent. If we were to pass this as an argument to closeBadPeers() that would be unnecessary.

comment:2 Changed 12 years ago by charles

  • Status changed from new to assigned

comment:3 Changed 12 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in trunk by r11349

Note: See TracTickets for help on using tickets.