On Thursday 15 May 2008 06:11, Daniel Cheng wrote:
> On Thu, May 15, 2008 at 7:08 AM, Matthew Toseland
> <[EMAIL PROTECTED]> wrote:
> > On Sunday 11 May 2008 11:24, [EMAIL PROTECTED] wrote:
> >> Author: j16sdiz
> >> Date: 2008-05-11 10:24:22 +0000 (Sun, 11 May 2008)
> >> New Revision: 19891
> >>
> >> Modified:
> >>
> > 
branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java
> >> Log:
> >> Quadratic Probing (datastore resize disabled)
> >
> > Cool! Any test results yet?
> 
> It is working better then the previous code..
> The store can grow ~70% full with no much resistant.

That's good... after that it significantly slows down? Can we have a rough 
idea of how long it takes to get to 50%, 60%, 70%, 80%, 90%?
> 
> >> Modified:
> > 
branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java
> >> ===================================================================
> >> ---
> > 
branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java
> > 2008-05-11 09:08:40 UTC (rev 19890)
> >> +++
> > 
branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java
> > 2008-05-11 10:24:22 UTC (rev 19891)
> >> @@ -126,22 +126,29 @@
> >>
> >>       private Entry probeEntry0(byte[] routingKey, long probeStoreSize) 
throws
> > IOException {
> >>               Entry entry;
> >> -             long offset = getOffsetFromPlainKey(routingKey, 
probeStoreSize);
> >> +             long[] offset = getOffsetFromPlainKey(routingKey, 
probeStoreSize);
> >>
> >> -             if (!lockEntry(offset)) {
> >> -                     Logger.error(this, "can't lock entry: " + offset);
> >> -                     return null;
> >> +             for (int i = 0; i < offset.length; i++) {
> >> +                     if (logDEBUG)
> >> +                             Logger.debug(this, "probing for i=" + i 
+ ", offset=" + offset[i]);
> >> +
> >> +                     if (!lockEntry(offset[i])) {
> >> +                             Logger.error(this, "can't lock entry: " + 
offset[i]);
> >> +                             continue;
> >> +                     }
> >> +                     try {
> >> +                             entry = readEntry(offset[i], routingKey);
> >> +                     } catch (EOFException e) {
> >> +                             // may occur on resize, silent it a bit
> >> +                             Logger.error(this, "EOFException on 
probeEntry", e);
> >> +                             return null;
> >
> > Shouldn't we go around the loop here? Or are the offsets strictly 
increasing?
> 
> Fixed in my local repository.
> 
> >> +                     } finally {
> >> +                             unlockEntry(offset[i]);
> >> +                     }
> >> +                     if (entry != null)
> >> +                             return entry;
> >>               }
> >> -             try {
> >> -                     entry = readEntry(offset, routingKey);
> >> -             } catch (EOFException e) {
> >> -                     // may occur on resize, silent it a bit
> >> -                     Logger.error(this, "EOFException on probeEntry", 
e);
> >> -                     return null;
> >> -             } finally {
> >> -                     unlockEntry(offset);
> >> -             }
> >> -             return entry;
> >> +             return null;
> >>       }
> >>
> >>       public void put(StorableBlock block, byte[] routingKey, byte[] 
fullKey,
> > byte[] data, byte[] header,
> >> @@ -163,16 +170,39 @@
> >>               }
> >>
> >>               Entry entry = new Entry(routingKey, header, data);
> >> -             if (!lockEntry(entry.getOffset())) {
> >> +             long[] offset = entry.getOffset();
> >> +
> >> +             for (int i = 0; i < offset.length; i++) {
> >> +                     if (!lockEntry(offset[i])) {
> >> +                             Logger.error(this, "can't lock entry: " + 
offset[i]);
> >> +                             return;
> >> +                     }
> >> +                     try {
> >> +                             if (isFree(offset[i], entry)) {
> >> +                                     if (logDEBUG)
> >> +                                             
Logger.debug(this, "probing, write to i=" + i + ", offset=" +
> > offset[i]);
> >> +                                     writeEntry(entry, offset[i]);
> >> +                                     incWrites();
> >> +                                     return;
> >> +                             }
> >> +                     } finally {
> >> +                             unlockEntry(offset[i]);
> >> +                     }
> >> +             }
> >> +
> >> +             // no free blocks?
> >> +             int i = random.nextInt(offset.length);
> >
> > You should try to write to an empty slot, of course... if all are full, is 
it
> > better to overwrite an empty slot rather than the first one?
> 
> All slot in offset[] are occupied when we reach this code.

Ok.

> Have to pick a random one to overwrite

Is it better to overwrite a random one or the first one?

Attachment: pgp4M2yJuEGvX.pgp
Description: PGP signature

_______________________________________________
Devl mailing list
Devl@freenetproject.org
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to