Changeset a4546e1


Ignore:
Timestamp:
Dec 21, 2015 5:19:40 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
8da3257
Parents:
3bce2f5
Message:

SSU: Hand all messages pending after establishment to the
outbound queue at once, for efficiency.
This allows more aggressive combining of fragments in packets,
and ensures the priority queue works as designed.
Don't sort outbound messages by size, keep priority order instead.
Log tweaks

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r3bce2f5 ra4546e1  
     12015-12-21 zzz
     2 * SSU: Hand all messages pending after establishment to the
     3   outbound queue at once, for efficiency.
     4   Don't sort outbound messages by size, keep priority order instead.
     5
    162015-12-20 zzz
    27 * BuildHandler: Additional fixes (ticket #1738)
  • router/java/src/net/i2p/router/RouterVersion.java

    r3bce2f5 ra4546e1  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 17;
     21    public final static long BUILD = 18;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java

    r3bce2f5 ra4546e1  
    771771        dsm.setMessageExpiration(_context.clock().now() + DATA_MESSAGE_TIMEOUT);
    772772        dsm.setMessageId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
    773         _transport.send(dsm, peer);
     773        // sent below
    774774
    775775        // just do this inline
     
    781781                //if (_log.shouldLog(Log.INFO))
    782782                //    _log.info("Publishing to the peer after confirm plus delay (without banlist): " + peer);
    783                 sendOurInfo(peer, true);
     783                // bundle the two messages together for efficiency
     784                DatabaseStoreMessage dbsm = getOurInfo();
     785                List<I2NPMessage> msgs = new ArrayList<I2NPMessage>(2);
     786                msgs.add(dsm);
     787                msgs.add(dbsm);
     788                _transport.send(msgs, peer);
    784789            } else {
     790                _transport.send(dsm, peer);
    785791                // nuh uh.
    786792                if (_log.shouldLog(Log.WARN))
     
    829835       
    830836        _context.statManager().addRateData("udp.outboundEstablishTime", state.getLifetime(), 0);
     837        DatabaseStoreMessage dbsm = null;
    831838        if (!state.isFirstMessageOurDSM()) {
    832             sendOurInfo(peer, false);
     839            dbsm = getOurInfo();
    833840        } else if (_log.shouldLog(Log.INFO)) {
    834841            _log.info("Skipping publish: " + state);
    835842        }
    836843       
     844        List<OutNetMessage> msgs = new ArrayList<OutNetMessage>(8);
    837845        OutNetMessage msg;
    838846        while ((msg = state.getNextQueuedMessage()) != null) {
     
    842850            } else {
    843851                msg.timestamp("session fully established and sent");
    844                 _transport.send(msg);
    845             }
    846         }
     852                msgs.add(msg);
     853            }
     854        }
     855        _transport.send(dbsm, msgs, peer);
    847856        return peer;
    848857    }
    849858   
     859/****
    850860    private void sendOurInfo(PeerState peer, boolean isInbound) {
    851861        if (_log.shouldLog(Log.INFO))
    852862            _log.info("Publishing to the peer after confirm: " +
    853863                      (isInbound ? " inbound con from " + peer : "outbound con to " + peer));
    854        
     864        DatabaseStoreMessage m = getOurInfo();
     865        _transport.send(m, peer);
     866    }
     867****/
     868   
     869    /**
     870     *  A database store message with our router info
     871     *  @return non-null
     872     *  @since 0.9.24 split from sendOurInfo()
     873     */
     874    private DatabaseStoreMessage getOurInfo() {
    855875        DatabaseStoreMessage m = new DatabaseStoreMessage(_context);
    856876        m.setEntry(_context.router().getRouterInfo());
    857877        m.setMessageExpiration(_context.clock().now() + DATA_MESSAGE_TIMEOUT);
    858         _transport.send(m, peer);
     878        return m;
    859879    }
    860880   
  • router/java/src/net/i2p/router/transport/udp/OutboundMessageFragments.java

    r3bce2f5 ra4546e1  
    173173
    174174    /**
    175      * short circuit the OutNetMessage, letting us send the establish
    176      * complete message reliably
    177      */
    178     public void add(OutboundMessageState state) {
    179         PeerState peer = state.getPeer();
     175     *  Short circuit the OutNetMessage, letting us send the establish
     176     *  complete message reliably.
     177     *  If you have multiple messages, use the list variant,
     178     *  so the messages may be bundled efficiently.
     179     */
     180    public void add(OutboundMessageState state, PeerState peer) {
    180181        if (peer == null)
    181182            throw new RuntimeException("null peer for " + state);
    182183        peer.add(state);
     184        add(peer);
     185        //_context.statManager().addRateData("udp.outboundActiveCount", active, 0);
     186    }
     187
     188    /**
     189     *  Short circuit the OutNetMessage, letting us send multiple messages
     190     *  reliably and efficiently.
     191     *  @since 0.9.24
     192     */
     193    public void add(List<OutboundMessageState> states, PeerState peer) {
     194        if (peer == null)
     195            throw new RuntimeException("null peer");
     196        int sz = states.size();
     197        for (int i = 0; i < sz; i++) {
     198            peer.add(states.get(i));
     199        }
    183200        add(peer);
    184201        //_context.statManager().addRateData("udp.outboundActiveCount", active, 0);
     
    401418        // sort by size, biggest first
    402419        // don't bother unless more than one state (fragments are already sorted within a state)
    403         if (fragmentsToSend > 1 && states.size() > 1)
    404             Collections.sort(toSend, new FragmentComparator());
     420        // This puts the DeliveryStatusMessage after the DatabaseStoreMessage, don't do it for now.
     421        // It also undoes the ordering of the priority queue in PeerState.
     422        //if (fragmentsToSend > 1 && states.size() > 1)
     423        //    Collections.sort(toSend, new FragmentComparator());
    405424
    406425        List<Fragment> sendNext = new ArrayList<Fragment>(Math.min(toSend.size(), 4));
     
    491510     *  @since 0.9.16
    492511     */
     512/****
    493513    private static class FragmentComparator implements Comparator<Fragment>, Serializable {
    494514
     
    498518        }
    499519    }
    500 
     520****/
     521
     522    /** throttle */
    501523    public interface ActiveThrottle {
    502524        public void choke(Hash peer);
  • router/java/src/net/i2p/router/transport/udp/OutboundMessageState.java

    r3bce2f5 ra4546e1  
    306306            }
    307307        }
    308         buf.append(" to: ").append(_peer.toString());
     308        //buf.append(" to: ").append(_peer.toString());
    309309        return buf.toString();
    310310    }
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r3bce2f5 ra4546e1  
    18291829
    18301830    /**
    1831      *  "injected" message from the EstablishmentManager
     1831     *  "injected" message from the EstablishmentManager.
     1832     *  If you have multiple messages, use the list variant,
     1833     *  so the messages may be bundled efficiently.
     1834     *
     1835     *  @param peer all messages MUST be going to this peer
    18321836     */
    18331837    void send(I2NPMessage msg, PeerState peer) {
     
    18361840            if (_log.shouldLog(Log.DEBUG))
    18371841                _log.debug("Injecting a data message to a new peer: " + peer);
    1838             _fragments.add(state);
     1842            _fragments.add(state, peer);
     1843        } catch (IllegalArgumentException iae) {
     1844            if (_log.shouldLog(Log.WARN))
     1845                _log.warn("Shouldnt happen", new Exception("I did it"));
     1846        }
     1847    }
     1848
     1849    /**
     1850     *  "injected" message from the EstablishmentManager,
     1851     *  plus pending messages to send,
     1852     *  so the messages may be bundled efficiently.
     1853     *  Called at end of outbound establishment.
     1854     *
     1855     *  @param msg may be null if nothing to inject
     1856     *  @param msgs non-null, may be empty
     1857     *  @param peer all messages MUST be going to this peer
     1858     *  @since 0.9.24
     1859     */
     1860    void send(I2NPMessage msg, List<OutNetMessage> msgs, PeerState peer) {
     1861        try {
     1862            int sz = msgs.size();
     1863            List<OutboundMessageState> states = new ArrayList<OutboundMessageState>(sz + 1);
     1864            if (msg != null) {
     1865                OutboundMessageState state = new OutboundMessageState(_context, msg, peer);
     1866                states.add(state);
     1867            }
     1868            for (int i = 0; i < sz; i++) {
     1869                OutboundMessageState state = new OutboundMessageState(_context, msgs.get(i), peer);
     1870                states.add(state);
     1871            }
     1872            if (_log.shouldLog(Log.DEBUG))
     1873                _log.debug("Injecting " + states.size() + " data messages to a new peer: " + peer);
     1874            _fragments.add(states, peer);
     1875        } catch (IllegalArgumentException iae) {
     1876            if (_log.shouldLog(Log.WARN))
     1877                _log.warn("Shouldnt happen", new Exception("I did it"));
     1878        }
     1879    }
     1880
     1881    /**
     1882     *  "injected" messages from the EstablishmentManager.
     1883     *  Called at end of inbound establishment.
     1884     *
     1885     *  @param peer all messages MUST be going to this peer
     1886     *  @since 0.9.24
     1887     */
     1888    void send(List<I2NPMessage> msgs, PeerState peer) {
     1889        try {
     1890            int sz = msgs.size();
     1891            List<OutboundMessageState> states = new ArrayList<OutboundMessageState>(sz);
     1892            for (int i = 0; i < sz; i++) {
     1893                OutboundMessageState state = new OutboundMessageState(_context, msgs.get(i), peer);
     1894                states.add(state);
     1895            }
     1896            if (_log.shouldLog(Log.DEBUG))
     1897                _log.debug("Injecting " + sz + " data messages to a new peer: " + peer);
     1898            _fragments.add(states, peer);
    18391899        } catch (IllegalArgumentException iae) {
    18401900            if (_log.shouldLog(Log.WARN))
Note: See TracChangeset for help on using the changeset viewer.