Opened 9 months ago

Closed 9 months ago

#2258 closed enhancement (fixed)

UDP Packet Pusher optimization

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

Description

About 10% of the cpu time used by "UDP Packet Pusher" thread is spent checking if the list of remaining acks contains a given id (see attached image).

Should be trivial to change to a HashSet.

Subtickets

Attachments (1)

OutboundMessageFragments.png (175.6 KB) - added by zab 9 months ago.
Yourkit screenshot

Download all attachments as: .zip

Change History (4)

Changed 9 months ago by zab

Yourkit screenshot

comment:1 Changed 9 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 9 months ago by zzz

  • Status changed from new to accepted

proposed change:

#
# old_revision [6c6a7520cad38845cee83103c323782b426b3ff5]
#
# patch "router/java/src/net/i2p/router/transport/udp/OutboundMessageFragments.java"
#  from [fbe71bbd3763539e5af537056d99751080464bca]
#    to [c8785d0564c1d7450824de5ce9bba0bfc04a9be9]
# 
# patch "router/java/src/net/i2p/router/transport/udp/PacketBuilder.java"
#  from [ed86402c5b9c7fa60ea45a7d3b2ea35fd8d67393]
#    to [56fa5f7a938cf3794a148b33e7995f0ce54e502b]
#
============================================================
--- router/java/src/net/i2p/router/transport/udp/OutboundMessageFragments.java	fbe71bbd3763539e5af537056d99751080464bca
+++ router/java/src/net/i2p/router/transport/udp/OutboundMessageFragments.java	c8785d0564c1d7450824de5ce9bba0bfc04a9be9
@@ -4,6 +4,7 @@ import java.util.Comparator;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -386,7 +387,7 @@ class OutboundMessageFragments {
         int piggybackedPartialACK = partialACKBitfields.size();
         // getCurrentFullACKs() already makes a copy, do we need to copy again?
         // YES because buildPacket() now removes them (maybe)
-        List<Long> remaining = new ArrayList<Long>(msgIds);
+        Set<Long> remaining = new HashSet<Long>(msgIds);
 
         // build the list of fragments to send
         List<Fragment> toSend = new ArrayList<Fragment>(8);
============================================================
--- router/java/src/net/i2p/router/transport/udp/PacketBuilder.java	ed86402c5b9c7fa60ea45a7d3b2ea35fd8d67393
+++ router/java/src/net/i2p/router/transport/udp/PacketBuilder.java	56fa5f7a938cf3794a148b33e7995f0ce54e502b
@@ -5,6 +5,7 @@ import java.util.Arrays;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -290,7 +291,7 @@ class PacketBuilder {
      * @return null on error
      */
     public UDPPacket buildPacket(OutboundMessageState state, int fragment, PeerState peer,
-                                 List<Long> ackIdsRemaining, int newAckCount,
+                                 Collection<Long> ackIdsRemaining, int newAckCount,
                                  List<ACKBitfield> partialACKsRemaining) {
         List<Fragment> frags = Collections.singletonList(new Fragment(state, fragment));
         return buildPacket(frags, peer, ackIdsRemaining, newAckCount, partialACKsRemaining);
@@ -302,7 +303,7 @@ class PacketBuilder {
      *  @since 0.9.16
      */
     public UDPPacket buildPacket(List<Fragment> fragments, PeerState peer,
-                                 List<Long> ackIdsRemaining, int newAckCount,
+                                 Collection<Long> ackIdsRemaining, int newAckCount,
                                  List<ACKBitfield> partialACKsRemaining) {
         StringBuilder msg = null;
         if (_log.shouldLog(Log.INFO)) {

comment:3 Changed 9 months ago by zzz

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

In a5433906f6ccaffd1147f349a57996d0c5be931f to be 0.9.35-6

Note: See TracTickets for help on using tickets.