Changeset 8a1f02aa


Ignore:
Timestamp:
Nov 13, 2015 9:18:21 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
e664423
Parents:
a028bba
Message:

Console: Fix lifetime participating bandwidth display (ticket #1706)
Add locking to HopConfig? counts
Split participatingMessageCount stat into two stats,
participatingMessageCountAvgPerTunnel for throttle (same as old participatingMessagecount)
and participatingMessageCount for console (straight total)
Fix calculation of stat for throttle by adjusting for new
stat coalesce time (50 not 20 seconds)

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/TunnelRenderer.java

    ra028bba r8a1f02aa  
    8282        for (int i = 0; i < participating.size(); i++) {
    8383            HopConfig cfg = participating.get(i);
    84             long count = cfg.getProcessedMessagesCount();
     84            int count = cfg.getProcessedMessagesCount();
    8585            if (count <= 0) {
    8686                inactive++;
    8787                continue;
    8888            }
    89             processed += count;
     89            // everything that isn't 'recent' is already in the tunnel.participatingMessageCount stat
     90            processed += cfg.getRecentMessagesCount();
    9091            if (++displayed > DISPLAY_LIMIT)
    9192                continue;
     
    112113            else
    113114                out.write("<td class=\"cells\" align=\"center\">(" + _t("grace period") + ")</td>");
    114             out.write("<td class=\"cells\" align=\"center\">" + cfg.getProcessedMessagesCount() + " KB</td>");
     115            out.write("<td class=\"cells\" align=\"center\">" + count + " KB</td>");
    115116            int lifetime = (int) ((_context.clock().now() - cfg.getCreation()) / 1000);
    116117            if (lifetime <= 0)
     
    118119            if (lifetime > 10*60)
    119120                lifetime = 10*60;
    120             int bps = 1024 * cfg.getProcessedMessagesCount() / lifetime;
     121            int bps = 1024 * count / lifetime;
    121122            out.write("<td class=\"cells\" align=\"center\">" + bps + " Bps</td>");
    122123            if (cfg.getSendTo() == null)
     
    189190                out.write("<tr> <td class=\"cells\" align=\"center\"><img src=\"/themes/console/images/outbound.png\" alt=\"Outbound\" title=\"Outbound\"></td>");
    190191            out.write(" <td class=\"cells\" align=\"center\">" + DataHelper.formatDuration2(timeLeft) + "</td>\n");
    191             out.write(" <td class=\"cells\" align=\"center\">" + info.getProcessedMessagesCount() + " KB</td>\n");
     192            int count = info.getProcessedMessagesCount();
     193            out.write(" <td class=\"cells\" align=\"center\">" + count + " KB</td>\n");
    192194            for (int j = 0; j < info.getLength(); j++) {
    193195                Hash peer = info.getPeer(j);
     
    207209           
    208210            if (info.isInbound())
    209                 processedIn += info.getProcessedMessagesCount();
    210             else
    211                 processedOut += info.getProcessedMessagesCount();
     211                processedIn += count;
     212            else
     213                processedOut += count;
    212214        }
    213215        out.write("</table>\n");
  • history.txt

    ra028bba r8a1f02aa  
     12015-11-13 zzz
     2 * Console: Fix lifetime participating bandwidth display (ticket #1706)
     3
    142015-11-12 zzz
    25 * Console /configclients:
  • router/java/src/net/i2p/router/RouterThrottleImpl.java

    ra028bba r8a1f02aa  
    277277        // ok, we're not hosed, but can we handle the bandwidth requirements
    278278        // of another tunnel?
    279         rs = _context.statManager().getRate("tunnel.participatingMessageCount");
     279        rs = _context.statManager().getRate("tunnel.participatingMessageCountAvgPerTunnel");
    280280        r = null;
    281281        double messagesPerTunnel = DEFAULT_MESSAGES_PER_TUNNEL_ESTIMATE;
  • router/java/src/net/i2p/router/RouterVersion.java

    ra028bba r8a1f02aa  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 26;
     21    public final static long BUILD = 27;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/tunnel/HopConfig.java

    ra028bba r8a1f02aa  
    2727    // these 4 were longs, let's save some space
    2828    // 2 billion * 1KB / 10 minutes = 3 GBps in a single tunnel
     29    // we use synchronization instead of an AtomicInteger here to save space
    2930    private int _messagesProcessed;
    3031    private int _oldMessagesProcessed;
     
    126127     *  Take note of a message being pumped through this tunnel.
    127128     *  "processed" is for incoming and "sent" is for outgoing (could be dropped in between)
     129     *  We use synchronization instead of an AtomicInteger here to save space.
    128130     */
    129     public void incrementProcessedMessages() { _messagesProcessed++; }
     131    public synchronized void incrementProcessedMessages() { _messagesProcessed++; }
    130132
    131     public int getProcessedMessagesCount() { return _messagesProcessed; }
     133    public synchronized int getProcessedMessagesCount() { return _messagesProcessed; }
    132134
    133     public int getRecentMessagesCount() {
     135    /**
     136     *  This returns the number of processed messages since
     137     *  the last time getAndResetRecentMessagesCount() was called.
     138     *  As of 0.9.23, does NOT reset the count, see getAndResetRecentMessagesCount().
     139     */
     140    public synchronized int getRecentMessagesCount() {
     141        return _messagesProcessed - _oldMessagesProcessed;
     142    }
     143
     144    /**
     145     *  This returns the number of processed messages since the last time this was called,
     146     *  and resets the count. It should only be called by code that updates the router stats.
     147     *  See TunnelDispatcher.updateParticipatingStats().
     148     *
     149     *  @since 0.9.23
     150     */
     151    synchronized int getAndResetRecentMessagesCount() {
    134152        int rv = _messagesProcessed - _oldMessagesProcessed;
    135153        _oldMessagesProcessed = _messagesProcessed;
     
    170188       
    171189        buf.append(" exp. ").append(TunnelCreatorConfig.format(_expiration));
    172         if (_messagesProcessed > 0)
    173             buf.append(" used ").append(_messagesProcessed).append("KB");
     190        int messagesProcessed = getProcessedMessagesCount();
     191        if (messagesProcessed > 0)
     192            buf.append(" used ").append(messagesProcessed).append("KB");
    174193        return buf.toString();
    175194    }
  • router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java

    ra028bba r8a1f02aa  
    164164                                         "Dropped for exceeding share limit", "Tunnels",
    165165                                         new long[] { 60*1000l, 60*10*1000l });
     166        // count for console
    166167        ctx.statManager().createRequiredRateStat("tunnel.participatingMessageCount",
    167168                                         "Number of 1KB participating messages", "Tunnels",
    168169                                         new long[] { 60*1000l, 60*10*1000l, 60*60*1000l });
     170        // estimate for RouterThrottleImpl
     171        ctx.statManager().createRequiredRateStat("tunnel.participatingMessageCountAvgPerTunnel",
     172                                         "Estimate of participating messages per tunnel lifetime", "Tunnels",
     173                                         new long[] { 60*1000l });
    169174        ctx.statManager().createRateStat("tunnel.ownedMessageCount",
    170175                                         "How many messages are sent through a tunnel we created (period == failures)?", "Tunnels",
     
    712717        long tooOld = tooYoung - 9*60*1000;
    713718        for (HopConfig cfg : _participatingConfig.values()) {
    714             long c = cfg.getRecentMessagesCount();
     719            long c = cfg.getAndResetRecentMessagesCount();
    715720            bw += c;
    716721            //bwOut += cfg.getRecentSentMessagesCount();
     
    721726            count += c;
    722727        }
     728        // This is an estimate of the average number of participating messages per tunnel
     729        // in a tunnel lifetime, used only by RouterThrottleImpl
     730        // 10 minutes / 50 seconds = 12
    723731        if (tcount > 0)
    724             count = count * 30 / tcount;
    725         _context.statManager().addRateData("tunnel.participatingMessageCount", count, ms);
     732            count = count * (10*60*1000 / ms) / tcount;
     733        _context.statManager().addRateData("tunnel.participatingMessageCountAvgPerTunnel", count, ms);
     734        // This is a straight count of the total participating messages, used in the router console
     735        _context.statManager().addRateData("tunnel.participatingMessageCount", bw, ms);
     736        // Bandwidth in bits per second
    726737        _context.statManager().addRateData("tunnel.participatingBandwidth", bw*1024/(ms/1000), ms);
    727738        // moved to FIFOBandwidthRefiller
Note: See TracChangeset for help on using the changeset viewer.