Opened 3 years ago

Last modified 3 years ago

#2259 new enhancement

UDP Packet Pusher optimization 2

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


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.


Attachments (1)

PeerState.png (157.3 KB) - added by Zlatin Balevsky 3 years ago.
Yourkit screenshot

Download all attachments as: .zip

Change History (3)

Changed 3 years ago by Zlatin Balevsky

Attachment: PeerState.png added

Yourkit screenshot

comment:1 Changed 3 years ago by zzz

Milestone: undecided0.9.36

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

comment:2 Changed 3 years ago by Zlatin Balevsky

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.