Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#3678 closed Enhancement (fixed)

benc walking could be more efficient

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

Description

benc walking shows up surprisingly high in profiling, especially when loading a lot of torrents at startup.

One place where this can be made more efficient is the memory allocation of the stack variable in bencWalk(). We can avoid a lot of malloc/free calls by using an array of SaveNodes? instead of an array of SaveNode? pointers.

Valgrind log of bencode-test before this change:

==4001== HEAP SUMMARY:
==4001==     in use at exit: 0 bytes in 0 blocks
==4001==   total heap usage: 5,000,420 allocs, 5,000,420 frees, 185,829,682 bytes allocated
==4001== 
==4001== All heap blocks were freed -- no leaks are possible

After:

==5335== HEAP SUMMARY:
==5335==     in use at exit: 0 bytes in 0 blocks
==5335==   total heap usage: 3,000,311 allocs, 3,000,311 frees, 204,590,798 bytes allocated
==5335== 
==5335== All heap blocks were freed -- no leaks are possible

Attachments (1)

benc.diff (6.4 KB) - added by charles 11 years ago.

Download all attachments as: .zip

Change History (7)

Changed 11 years ago by charles

comment:1 Changed 11 years ago by charles

Added to trunk by r11356.

comment:2 Changed 11 years ago by charles

  • Owner set to charles
  • Status changed from new to assigned

comment:3 Changed 11 years ago by charles

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

comment:4 Changed 11 years ago by charles

  • Keywords backport-2.0x added

comment:5 Changed 11 years ago by charles

  • Component changed from Transmission to libtransmission

comment:6 Changed 11 years ago by charles

backported to 2.0x by r11482

Note: See TracTickets for help on using tickets.