Don't use ByteWindows when checking pack file headers/footers
PATCH 1/2 Don't use ByteWindows when checking pack file headers/footers
Its highly unlikely we need the 8 KiB surrounding the pack file header or footer immediately after opening the pack file. Reading those as full blocks and registering them in the WindowCache is probably just churning garbage through the cache. Instead, read the header with a single 12 byte read, and the footer with a single 20 byte read, and bypass the cache altogether.
This nicely removes a deadlock condition we had previously where the WindowCache was recursively calling itself during the pack file open, and got stuck on its own locks.
---
This I think can be applied as-is.
We could quibble about whether or not caching the header and footer window is worthwhile during the pack open event. But really I wrote this to remove a deadlock in the next patch. Its just soooo much simpler to not make PackFile rely on WindowCache.
.../src/org/spearce/jgit/lib/PackFile.java | 5 +-- org.spearce.jgit/src/org/spearce/jgit/util/NB.java | 32 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-)
org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java +2 -3
@@ -389,10 +389,9 @@ void allocWindow(final WindowCursor curs, final int windowId, private void onOpenPack() throws IOException { final PackIndex idx = idx(); - final WindowCursor curs = new WindowCursor(); final byte[] buf = new byte[20]; - readFully(0, buf, 0, 12, curs); + NB.readFully(fd.getChannel(), 0, buf, 0, 12); if (RawParseUtils.match(buf, 0, Constants.PACK_SIGNATURE) != 4) throw new IOException("Not a PACK file."); final long vers = NB.decodeUInt32(buf, 4);
@@ -406,7 +405,7 @@ private void onOpenPack() throws IOException { + " index " + idx.getObjectCount() + ": " + getPackFile()); - readFully(length - 20, buf, 0, 20, curs); + NB.readFully(fd.getChannel(), length - 20, buf, 0, 20); if (!Arrays.equals(buf, idx.packChecksum)) throw new PackMismatchException("Pack checksum mismatch:" + " pack " + ObjectId.fromRaw(buf).name()
org.spearce.jgit/src/org/spearce/jgit/util/NB.java +32 -0
@@ -40,6 +40,8 @@ import java.io.EOFException; import java.io.IOException; import java.io.InputStream; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; /** Conversion utilities for network byte order handling. */ public final class NB {
@@ -71,6 +73,36 @@ public static void readFully(final InputStream fd, final byte[] dst, } /** + * Read the entire byte array into memory, or throw an exception. + * + * @param fd + * file to read the data from. + * @param pos + * position to read from the file at. + * @param dst + * buffer that must be fully populated, [off, off+len). + * @param off + * position within the buffer to start writing to. + * @param len + * number of bytes that must be read. + * @throws EOFException + * the stream ended before dst was fully populated. + * @throws IOException + * there was an error reading from the stream. + */ + public static void readFully(final FileChannel fd, long pos, + final byte[] dst, int off, int len) throws IOException { + while (len > 0) { + final int r = fd.read(ByteBuffer.wrap(dst, off, len), pos); + if (r <= 0) + throw new EOFException("Short read of block."); + pos += r; + off += r; + len -= r; + } + } + + /** * Skip an entire region of an input stream. * <p> * The input stream's position is moved forward by the number of requested
Signature · 1 line
1.6.3.rc1.205.g37f8
RFC PATCH 2/2 Rewrite WindowCache to be easier to follow and maintain
The integration of WindowCache, ByteWindow, PackFile and WindowCursor was a spaghetti of code that was impossible for even the original author (me) to follow. Due to the way the responsibility for the PackFile's open RandomAccessFile "fd" was distributed between these four classes I could no longer prove to myself that the fd wouldn't be closed while it was being accessed by another thread.
This rewrite generalizes most of the cache logic into a new class, OffsetCache. The hope is that we can later reuse this code to make a rewrite of UnpackedObjectCache, which uses similiar caching rules as the WindowCache, but applies a different hash function. That rewrite is deferred to another change, but is anticipated by this one.
The new OffsetCache class uses the Java 5 atomic APIs to create a much more concurrent hash table than we had before. We can now perform no-miss reads without taking any locks. Reads that do miss acquire a lock in order to prevent concurrent threads from performing duplicate work loading the same window from disk, however concurrent reads of different windows is still permitted.
Due to the more concurrent nature of the OffsetCache, it is now possible for the cache to temporarily overshoot its resource limits. This is a small temporary overshoot that is roughly bounded by the number of concurrent threads operating against the same cache.
The API of the ByteWindow subclasses is now simplified by removing the base class of SoftReference. It was a horrible idea to pass the byte[] or MappedByteBuffer down through the call stack when the implementation knew what type it should be operating on. We now instead use a more traditional OO pattern of allowing the subclass to directly specify its referent.
Responsibility for the RandomAccessFile "fd" within PackFile is now strictly within PackFile. Two open reference counts track how the callers are using the fd, ensuring that the fd remains open, so long as the caller has made the appropriate begin*() invocation prior to data access. One counter, beginWindowCache() is exclusively for the ByteWindows created by WindowCache. Another counter, beginCopyRawData(), is exclusively for PackWriter's need to lock the PackFile open while it performs object reuse.
To keep the code simple a WindowCache.reconfigure() now discards the entire current cache, and creates a new one. That invalidates every open file, and every open ByteWindow, and forces them to load again.
reconfigure is no longer a thread safe operation, as there is no easy way to lock out other threads while the cache change is taking place. I don't think cache reconfigurations occur frequently enough in application code that we can justify the additional overhead required by a multi-reader/single-writer lock around every cache access. Instead, the Javadoc is updated to warn application authors against changing this on the fly.
---
I'm tossing this out there for tonight. Please don't apply until I give a final yay or nay.
I think the code is easier to follow once this patch is applied due to the scope of responsibilities being restored back to their proper OO-theory suggested classes. The re-write of WindowCache is horrible to read as a diff, sorry.
At present, it passes all of the unit tests. It passes my minimal concurrent clone test. At first glance, it runs within the same performance bounds as the prior code on a single thread clone test.
I have not yet done any performance tests with more than one concurrent clone client. I don't yet have hard performance test results to give you to back up my claims that its no worse in single thread usage, or that it should perform better in server environments.
I'm going to burn this in tonight for about 12 hours by pounding a whole bunch of clients against it. If that load test goes well tomorrow morning, I'll try to work up more concrete performance test data to at least show we're no worse off than before in that department, and ask you to apply it.
.../org/spearce/jgit/lib/ConcurrentRepackTest.java | 4 - .../src/org/spearce/jgit/lib/ByteArrayWindow.java | 57 +-- .../src/org/spearce/jgit/lib/ByteBufferWindow.java | 41 +- .../src/org/spearce/jgit/lib/ByteWindow.java | 91 +--- .../src/org/spearce/jgit/lib/OffsetCache.java | 522 ++++++++++++++++++++ .../src/org/spearce/jgit/lib/PackFile.java | 123 +++-- .../org/spearce/jgit/lib/PackedObjectLoader.java | 4 +- .../src/org/spearce/jgit/lib/WindowCache.java | 408 ++++------------ .../src/org/spearce/jgit/lib/WindowCursor.java | 42 +- 9 files changed, 763 insertions(+), 529 deletions(-) create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java
org.spearce.jgit.test/tst/org/spearce/jgit/lib/ConcurrentRepackTest.java +0 -4
@@ -170,10 +170,6 @@ public void testObjectMovedToNewPack2() private static void whackCache() { final WindowCacheConfig config = new WindowCacheConfig(); - - config.setPackedGitOpenFiles(0); - WindowCache.reconfigure(config); - config.setPackedGitOpenFiles(1); WindowCache.reconfigure(config); }
org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java +12 -45
87 lines not on this page · raw message
org.spearce.jgit/src/org/spearce/jgit/lib/ByteBufferWindow.java +15 -26
65 lines not on this page · raw message
org.spearce.jgit/src/org/spearce/jgit/lib/ByteWindow.java +24 -67
161 lines not on this page · raw message
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java new file +522 -0
522 lines not on this page · raw message
org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java +70 -53
157 lines not on this page · raw message
org.spearce.jgit/src/org/spearce/jgit/lib/PackedObjectLoader.java +2 -2
@@ -126,7 +126,7 @@ public final long getDataOffset() { * deleted, and the object has moved to another pack file. */ public void beginCopyRawData() throws IOException { - WindowCache.pin(pack); + pack.beginCopyRawData(); } /**
@@ -154,7 +154,7 @@ public void copyRawData(OutputStream out, byte buf[], WindowCursor curs) /** Release resources after {@link #beginCopyRawData()}. */ public void endCopyRawData() { - WindowCache.unpin(pack); + pack.endCopyRawData(); } /**
org.spearce.jgit/src/org/spearce/jgit/lib/WindowCache.java +95 -313
473 lines not on this page · raw message
org.spearce.jgit/src/org/spearce/jgit/lib/WindowCursor.java +23 -19
104 lines not on this page · raw message
Signature · 1 line
1.6.3.rc1.205.g37f8
Re: [JGIT RFC PATCH 2/2] Rewrite WindowCache to be easier to follow and maintain
Quoted 2 lines · Shawn O. Pearce
This rewrite generalizes most of the cache logic into a new class,
...
Quoted 2 lines
I'm tossing this out there for tonight. Please don't apply until I give a final yay or nay.
...
Quoted 2 lines
I'm going to burn this in tonight for about 12 hours by pounding a whole bunch of clients against it.
Yay.
This patch looks solid to me.
I ran it overnight for 12 hours on a test rig. 4-way Intel(R) Xeon(R) CPU 5148 @ 2.33GHz with 32 GiB physical memory. The git://
server process was launched with:
java -Xmx8192m -classpath jgit \
org.spearce.jgit.pgm.Main daemon
--port 8853 --export-all baseNote that is the default WindowCacheConfig.
I ran 8 concurrent clone clients on two 2-way systems, 4 clients per host. The clone clients randomly selected between three repositories on each clone attempt:
linux-2.6 fork (322M on disk)
repo.git (1.6M on disk)
gerrit.git (9.3M on disk)
I used C git git clone --bare ... for the clients to try and speed up the client side of the test.
In 12 hours the clients successfully completed a total of 2,456 clones, and appear to have been averaging 10,999 KiB/s at peak on one test host and 4,969 KiB/s on the other. So JGit was pushing somewhere around 63,872 KiB/s. I'm not sure what the network can really do here; the test clients are in my office and the server is in a data center somewhere in the same state.
At peak (when all clients picked the linux-2.6 fork roughly around the same time) I saw the server JVM approaching 380% CPU utilization. Not too bad giving that the WindowCacheConfig's default settings are woefully inadequate for 8 concurrent PackWriters on linux-2.6.
Unfortunately, this quad is largest SMP box I have available. I'm sure we're wasting CPU spinning through cache entries under load. I still need to do throughput testing, and that may lead to some tuning changes. But the code is cleaner and didn't fall over, so I say we move ahead and apply this rewrite.
Signature · 1 line
Shawn.
Re: [JGIT RFC PATCH 2/2] Rewrite WindowCache to be easier to follow and maintain
In reply to Shawn O. Pearcetisdag 28 april 2009 04:26:12 skrev "Shawn O. Pearce" <[email protected]>:
Quoted 11 lines
To keep the code simple a
WindowCache.reconfigure()now discards the entire current cache, and creates a new one. That invalidates every open file, and every open ByteWindow, and forces them to load again.reconfigure is no longer a thread safe operation, as there is no easy way to lock out other threads while the cache change is taking place. I don't think cache reconfigurations occur frequently enough in application code that we can justify the additional overhead required by a multi-reader/single-writer lock around every cache access. Instead, the Javadoc is updated to warn application authors against changing this on the fly.
As for non-thread-safe reconfigure, we have to solve it somehow since I'd expect to be able to reconfigure the cache in Eclipse. Forcing a restart might be an ok workaround for that particular case. Could one somehow, thread safely, let the old cache live on until no-one uses it and the GC takes care of it, and redirect new accesses to the new cache.
Quoted 4 lines
org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java +0
-0
...
Quoted 11 lines
org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java +2
-1@@ -86,7 +74,8 @@ int inflate(final byte[] array, final int pos, final byte[] b, int o, return o; } - void inflateVerify(final byte[] array, final int pos, final Inflater inf) + @Override + protected void inflateVerify(final int pos, final Inflater inf) throws DataFormatException { while (!inf.finished()) { if (inf.needsInput()) {
org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java void inflateVerify(final byte[] array, final int pos, final Inflater inf) · line 89
Quoted 3 lines
org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java +0
-0@@ -98,26 +87,4 @@ void inflateVerify(final byte[] array, final int pos, final Inflater inf) while (!inf.finished() && !inf.needsInput()) inf.inflate(verifyGarbageBuffer, 0, verifyGarbageBuffer.length); }
Not related to this patche really, but the static buffer makes a but nervous, I don't think your test massaged that part since it did not enable memory mapping.
Quoted 2 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +1
-0+ OffsetCache(final int tSize, final int lockCount) {
...
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 170
Quoted 5 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +5
-0+ int eb = (int) (tableSize * .1); + if (64 < eb) + eb = 64; + else if (eb < 4) + eb = 4;
^no coverage in unit testt
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 172
Quoted 2 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +2
-0+ if (tableSize < eb) + eb = tableSize;
^no coverage in unit testt
Quoted 3 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +3
-0+ evictBatch = eb; + } +
...
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 197
Quoted 10 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +10
-0+ V getOrLoad(final PackFile pack, final long position) throws IOException { + final int slot = slot(pack, position); + final Entry<V> e1 = table.get(slot); + V v = scan(e1, pack, position); + if (v != null) + return v; + + synchronized (lock(pack, position)) { + Entry<V> e2 = table.get(slot); + if (e2 != e1) {
-- this block not coverred
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 210
Quoted 13 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +13
-0+ v = scan(e2, pack, position); + if (v != null) + return v; + } + + v = load(pack, position); + final Ref<V> ref = createRef(pack, position, v); + hit(ref); + for (;;) { + final Entry<V> n = new Entry<V>(clean(e2), ref); + if (table.compareAndSet(slot, e2, n)) + break; + e2 = table.get(slot);
-- ^not covered
Quoted 16 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +16
-0+ } + } + + if (evictLock.tryLock()) { + try { + gc(); + evict(); + } finally { + evictLock.unlock(); + } + } + + return v; + } + + private V scan(Entry<V> n, final PackFile pack, final long position) {
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 236
Quoted 10 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +10
-0+ for (; n != null; n = n.next) { + final Ref<V> r = n.ref; + if (r.pack == pack && r.position == position) { + final V v = r.get(); + if (v != null) { + hit(r); + return v; + } + n.dead = true; + break;
these two lines not covered^
...
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 258
Quoted 4 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +4
-0+ private void evict() { + final int start = rng.nextInt(tableSize); + int ptr = start; + while (isFull()) {
The whole body of the loop not covered. It could be that RepositoryTestCase should set a very low limit on some parameters, such as maximum number of opened files.
...
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 326
Quoted 10 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +10
-0+ void removeAll(final PackFile pack) { + for (int s = 0; s < tableSize; s++) { + final Entry<V> e1 = table.get(s); + boolean hasDead = false; + for (Entry<V> e = e1; e != null; e = e.next) { + if (e.ref.pack == pack) { + e.kill(); + hasDead = true; + } else if (e.dead) + hasDead = true;
uncovered statement ^
Quoted 4 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +4
-0+ } + if (hasDead) + table.compareAndSet(s, e1, clean(e1)); + }
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 415
Quoted 10 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +9
-0+ gc(); + } + @SuppressWarnings("unchecked") + private void gc() { + R r; + while ((r = (R) queue.poll()) != null) { + // Sun's Java 5 and 6 implementation have a bug where a Reference + // can be enqueued and dequeued twice on the same reference queue + // due to a race condition within ReferenceQueue.enqueue(Reference).
Reference to the official Sun bug? Might help if someone wants to implement a flag to avoid this (if necessary...)
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 441
Quoted 3 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +3
-0+ protected int hash(final int packHash, final long position) { + return (packHash + (int) (position >>> 4)) >>> 1; + }
Since we never use the baselass this one isn't covered... ok anyway I think.
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 459
Quoted 9 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +9
-0+ private static <V> Entry<V> clean(Entry<V> top) { + while (top != null && top.dead) { + top.ref.enqueue(); + top = top.next; + } + if (top == null) + return null; + final Entry<V> n = clean(top.next); + return n == top.next ? top : new Entry<V>(n, top.ref);
two last lines uncovered.
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 513
Quoted 3 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +3
-0+ final synchronized boolean canClear() { + if (cleared) + return false;
uncovered return ^
This is a huge patch... I might comment on more later. As you may see, I think we need to lessen our dependence on faith based testing. (The MoveDeleteHook doesn't work
well either and it depends on code not covererd in unit tests at all, though
I'm not sure that will reveal the problem yet).
-- robin
Re: [JGIT RFC PATCH 2/2] Rewrite WindowCache to be easier to follow and maintain
Quoted 13 lines · Robin Rosenberg
tisdag 28 april 2009 04:26:12 skrev "Shawn O. Pearce" <[email protected]>:
Quoted 11 lines
To keep the code simple a
WindowCache.reconfigure()now discards the entire current cache, and creates a new one. That invalidates every open file, and every open ByteWindow, and forces them to load again.reconfigure is no longer a thread safe operation, as there is no easy way to lock out other threads while the cache change is taking place. I don't think cache reconfigurations occur frequently enough in application code that we can justify the additional overhead required by a multi-reader/single-writer lock around every cache access. Instead, the Javadoc is updated to warn application authors against changing this on the fly.
Quoted 5 lines
As for non-thread-safe reconfigure, we have to solve it somehow since I'd expect to be able to reconfigure the cache in Eclipse. Forcing a restart might be an ok workaround for that particular case. Could one somehow, thread safely, let the old cache live on until no-one uses it and the GC takes care of it, and redirect new accesses to the new cache.
I think I've fixed it with a subsequent patch, see "Better handle concurrent reads during a WindowCache reconfiguration" sent out a few hours ago.
Quoted 5 lines
Quoted 4 lines
org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java +0
-0...
Quoted 7 lines
org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java void inflateVerify(final byte[] array, final int pos, final Inflater inf) · line 89
Quoted 4 lines
org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java +0
-0@@ -98,26 +87,4 @@ void inflateVerify(final byte[] array, final int pos, final Inflater inf) while (!inf.finished() && !inf.needsInput()) inf.inflate(verifyGarbageBuffer, 0, verifyGarbageBuffer.length); }Not related to this patche really, but the static buffer makes a but nervous, I don't think your test massaged that part since it did not enable memory mapping.
This is old code, and isn't changed either way.
It isn't just memory mapping vs. not memory mapping, this same sort of code is in ByteBufferWindow too.
Though now that you mention it, I'm recalling something about how libz might try to read the output buffer when producing more output, in which case this code is not thread safe. I wish I could remember.
We may want to just do a follow-up patch that creates a temporary byte[] within the WindowCursor for this verifyGarbageBuffer and pass that down through here instead.
I'll consider it.
Quoted 9 lines
Quoted 2 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +1
-0+ OffsetCache(final int tSize, final int lockCount) {...
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 170
Quoted 5 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +5
-0+ int eb = (int) (tableSize * .1); + if (64 < eb) + eb = 64; + else if (eb < 4) + eb = 4;^no coverage in unit testt
Quoted 3 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 172
Quoted 2 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +2
-0+ if (tableSize < eb) + eb = tableSize;^no coverage in unit testt
Blargh. My EclEmma installation is busted so I couldn't run it through coverage. I just beat the tar out of it for 12 hours.
I'll try to fix EclEmma tomorrow and increase coverage around the new code.
Signature · 1 line
Shawn.
Re: [JGIT RFC PATCH 2/2] Rewrite WindowCache to be easier to follow and maintain
In reply to Robin RosenbergQuoted 10 lines · Robin Rosenberg
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 415
Quoted 7 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +6
-0+ private void gc() { + R r; + while ((r = (R) queue.poll()) != null) { + // Sun's Java 5 and 6 implementation have a bug where a Reference + // can be enqueued and dequeued twice on the same reference queue + // due to a race condition within ReferenceQueue.enqueue(Reference).Reference to the official Sun bug? Might help if someone wants to implement a flag to avoid this (if necessary...)
Actually, this is a new bug. I tried looking through BugParade but nobody has mentioned or discovered this before.
I submitted a bug report yesterday, but they have yet to publish it.
So, no link.
Quoted 5 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 441
Quoted 3 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +3
-0+ protected int hash(final int packHash, final long position) { + return (packHash + (int) (position >>> 4)) >>> 1; + }Since we never use the baselass this one isn't covered... ok anyway I think.
This particular implementation I planned on using in UnpackedObjectCache if I rewrote it using OffsetCache.
But I could also just make it abstract here. Maybe that is the better approach. I'll amend that into the series.
Signature · 1 line
Shawn.
Re: [JGIT RFC PATCH 2/2] Rewrite WindowCache to be easier to follow and maintain
Quoted 11 lines · Shawn O. Pearce
Quoted 9 lines · Robin Rosenberg
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java line 415
Quoted 7 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +6
-0+ private void gc() { + R r; + while ((r = (R) queue.poll()) != null) { + // Sun's Java 5 and 6 implementation have a bug where a Reference + // can be enqueued and dequeued twice on the same reference queue + // due to a race condition within ReferenceQueue.enqueue(Reference).Reference to the official Sun bug? Might help if someone wants to implement a flag to avoid this (if necessary...)
Quoted 5 lines
Actually, this is a new bug. I tried looking through BugParade but nobody has mentioned or discovered this before.
I submitted a bug report yesterday, but they have yet to publish it.
maybe you can also submit it to the OpenJDK folks? I have very bad experiences with reporting java bugs to sun. I reported a few and _never_ heard back from them, no publish of the bug, no reject, nothing.
Great work on rewriting this!
PS. still need your input on ignores :-)
PATCH 1/1 Link to the Sun JVM bug mentioned in OffsetCache
In reply to Shawn O. PearceThis bug has now been published by Sun. We should link to the database entry so we can find more detail later.
---
Quoted 12 lines · Shawn O. Pearce
Quoted 10 lines · Robin Rosenberg
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java
Quoted 7 lines
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +6
-0+ private void gc() { + R r; + while ((r = (R) queue.poll()) != null) { + // Sun's Java 5 and 6 implementation have a bug where a Reference + // can be enqueued and dequeued twice on the same reference queue + // due to a race condition within ReferenceQueue.enqueue(Reference).Reference to the official Sun bug? Might help if someone wants to implement a flag to avoid this (if necessary...)
Quoted 4 lines
Actually, this is a new bug. I tried looking through BugParade but nobody has mentioned or discovered this before.
I submitted a bug report yesterday, but they have yet to publish it.
And here it is.
.../src/org/spearce/jgit/lib/OffsetCache.java | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java +2 -0
@@ -414,6 +414,8 @@ private void gc() { // can be enqueued and dequeued twice on the same reference queue // due to a race condition within ReferenceQueue.enqueue(Reference). // + // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6837858 + // // We CANNOT permit a Reference to come through us twice, as it will // skew the resource counters we maintain. Our canClear() check here // provides a way to skip the redundant dequeues, if any.
Signature · 1 line
1.6.3.rc4.206.g03e16