mirror of https://github.com/apache/activemq.git
Instead of locking on the PList iterator which forces a lock on every access to hasNext we should lock down at the PageFile level in readPage making the seek and read an atomic operation. Since many reads on a single already loaded page don't need to be synchronized we pay a higher price for locking in the specific PList case than we do buy creating this atomic read operation in PageFile. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1375852 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ba9037ca65
commit
4bace216b9
|
@ -202,9 +202,7 @@ public class PList extends ListIndex<String, Location> {
|
|||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
synchronized (indexLock) {
|
||||
return iterator.hasNext();
|
||||
}
|
||||
return iterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,16 @@
|
|||
*/
|
||||
package org.apache.kahadb.page;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -862,7 +871,7 @@ public class PageFile {
|
|||
return nextTxid.incrementAndGet();
|
||||
}
|
||||
|
||||
void readPage(long pageId, byte[] data) throws IOException {
|
||||
synchronized void readPage(long pageId, byte[] data) throws IOException {
|
||||
readFile.seek(toOffset(pageId));
|
||||
readFile.readFully(data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue