Changeset 6e2583a


Ignore:
Timestamp:
Dec 13, 2013 5:50:39 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
efff25a
Parents:
af84bcf
Message:

NetDB:

  • Increase new kad size to K=24, B=4
  • Fix router count by counting in the data store, not the kbuckets
  • Randomize the order we load router infos at startup so we don't bias the kbuckets
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    raf84bcf r6e2583a  
     12013-12-13 zzz
     2 * i2ptunnel: Show destination for persistent client key only if available;
     3              show b32 for the key as well
     4 * NetDB:
     5   - Increase new kad size to K=24, B=4
     6   - Fix router count by counting in the data store, not the kbuckets
     7   - Randomize the order we load router infos at startup so we
     8     don't bias the kbuckets
     9
    1102013-12-10 zzz
    211Prop from i2p.i2p.zzz.test2:
  • router/java/src/net/i2p/router/RouterVersion.java

    raf84bcf r6e2583a  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 1;
     21    public final static long BUILD = 2;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    raf84bcf r6e2583a  
    144144     *  Was 500 in old implementation but that was with B ~= -8!
    145145     */
    146     private static final int BUCKET_SIZE = 16;
    147     private static final int KAD_B = 3;
     146    private static final int BUCKET_SIZE = 24;
     147    private static final int KAD_B = 4;
    148148
    149149    public KademliaNetworkDatabaseFacade(RouterContext context) {
     
    374374    }
    375375   
     376    /**
     377     *  This used to return the number of routers that were in
     378     *  both the kbuckets AND the data store, which was fine when the kbuckets held everything.
     379     *  But now that is probably not what you want.
     380     *  Just return the count in the data store.
     381     */
    376382    @Override
    377383    public int getKnownRouters() {
     384/****
    378385        if (_kb == null) return 0;
    379386        CountRouters count = new CountRouters();
    380387        _kb.getAll(count);
    381388        return count.size();
    382     }
    383    
     389****/
     390        if (_ds == null) return 0;
     391        int rv = 0;
     392        for (DatabaseEntry ds : _ds.getEntries()) {
     393            if (ds.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO)
     394                rv++;
     395        }
     396        return rv;
     397    }
     398   
     399/****
    384400    private class CountRouters implements SelectionCollector<Hash> {
    385401        private int _count;
     
    392408        }
    393409    }
     410****/
    394411   
    395412    /**
     
    417434     *  but it includes both routerinfos and leasesets.
    418435     *  Use it to avoid deadlocks.
     436     *  No - not true - the KBS contains RIs only.
    419437     */
    420438    protected int getKBucketSetSize() { 
  • router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java

    raf84bcf r6e2583a  
    1717import java.io.InputStream;
    1818import java.io.OutputStream;
     19import java.util.ArrayList;
     20import java.util.Collections;
    1921import java.util.Iterator;
     22import java.util.List;
    2023import java.util.Locale;
    2124import java.util.Map;
     
    399402                if (routerInfoFiles != null)
    400403                    migrate(_dbDir, routerInfoFiles);
     404                // Loading the files in-order causes clumping in the kbuckets,
     405                // and bias on early peer selection, so first collect all the files,
     406                // then shuffle and load.
     407                List<File> toRead = new ArrayList<File>(2048);
    401408                for (int j = 0; j < B64.length(); j++) {
    402409                    File subdir = new File(_dbDir, DIR_PREFIX + B64.charAt(j));
     
    411418                        continue;
    412419                    for (int i = 0; i < files.length; i++) {
    413                         Hash key = getRouterInfoHash(files[i].getName());
    414                         if (key != null && !isKnown(key))
    415                             (new ReadRouterJob(files[i], key)).runJob();
     420                        toRead.add(files[i]);
    416421                    }
     422                }
     423                Collections.shuffle(toRead, _context.random());
     424                for (File file : toRead) {
     425                    Hash key = getRouterInfoHash(file.getName());
     426                    if (key != null && !isKnown(key))
     427                        (new ReadRouterJob(file, key)).runJob();
    417428                }
    418429            }
Note: See TracChangeset for help on using the changeset viewer.