Opened 11 months ago

Last modified 11 months ago

#2259 new enhancement

UDP Packet Pusher optimization 2

Reported by: zab Owned by: zzz
Priority: trivial Milestone: 0.9.36
Component: router/transport Version: 0.9.34
Keywords: ssu Cc: slumlord
Parent Tickets:


Another 12% of the CPU time spent in "UDP Packet Pusher" is spent traversing and the list of PeerState._outboundMessages in finishMessages(). This is because removing elements from an ArrayList is expensive and it happens a lot in that block of code (see attached YourKit snapshot).

I'll try replacing it with LinkedList, but there is a downside - that list is already a CachedIteratorArrayList which means it must have been identified as an allocation hotspot during earlier profiling. However, as it stands now "UDP Packet Pusher" is the thread using most CPU time so maybe it's a worthy tradeoff.

Subtickets (add)

Attachments (1)

PeerState.png (157.3 KB) - added by zab 11 months ago.
Yourkit screenshot

Download all attachments as: .zip

Change History (3)

Changed 11 months ago by zab

Yourkit screenshot

comment:1 Changed 11 months ago by zzz

  • Milestone changed from undecided to 0.9.36

to be looked at mid-July after NTCP2 is checked in

comment:2 Changed 11 months ago by zab

  • Cc slumlord added

Changing to a LinkedList reduces the time spent in that method by a 3rd - to 8% of total thread time. However, as expected, hundreds of megabytes of garbage LinkedList$ListItr objects are created.

So it makes sense to implement a LinkedList with a cached Iterator.

Note: See TracTickets for help on using tickets.