mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-15 03:35:52 +00:00
Log slow reads in BOBS.
This commit is contained in:
parent
168a5a40e1
commit
c8e76a8f9b
@ -27,6 +27,7 @@ import java.io.RandomAccessFile;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -263,12 +264,18 @@ public class BoundedOverheadBlockStore implements BlockStore {
|
|||||||
// Use our own file pointer within the tight loop as updating channel positions is really expensive.
|
// Use our own file pointer within the tight loop as updating channel positions is really expensive.
|
||||||
long pos = startPos;
|
long pos = startPos;
|
||||||
Record record = new Record();
|
Record record = new Record();
|
||||||
|
int numMoves = 0;
|
||||||
|
long startTime = new Date().getTime();
|
||||||
do {
|
do {
|
||||||
if (!record.read(channel, pos, buf))
|
if (!record.read(channel, pos, buf))
|
||||||
throw new IOException("Failed to read buffer");
|
throw new IOException("Failed to read buffer");
|
||||||
if (record.getHeader(params).getHash().equals(hash)) {
|
if (record.getHeader(params).getHash().equals(hash)) {
|
||||||
// Found it. Update file position for next time.
|
// Found it. Update file position for next time.
|
||||||
channel.position(pos);
|
channel.position(pos);
|
||||||
|
long endTime = new Date().getTime();
|
||||||
|
if (endTime - startTime > 100) {
|
||||||
|
log.info("Spent {} seconds doing {} backwards seeks", (endTime - startTime) / 1000.0, numMoves);
|
||||||
|
}
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
// Did not find it.
|
// Did not find it.
|
||||||
@ -280,13 +287,19 @@ public class BoundedOverheadBlockStore implements BlockStore {
|
|||||||
pos = pos - Record.SIZE;
|
pos = pos - Record.SIZE;
|
||||||
assert pos >= 1 + 32 : pos;
|
assert pos >= 1 + 32 : pos;
|
||||||
}
|
}
|
||||||
|
numMoves++;
|
||||||
} while (pos != startPos);
|
} while (pos != startPos);
|
||||||
// Was never stored.
|
// Was never stored.
|
||||||
channel.position(pos);
|
channel.position(pos);
|
||||||
|
long endTime = new Date().getTime();
|
||||||
|
if (endTime - startTime > 1000) {
|
||||||
|
log.info("Spent {} seconds doing {} backwards seeks", (endTime - startTime) / 1000.0, numMoves);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized StoredBlock getChainHead() throws BlockStoreException {
|
public synchronized StoredBlock getChainHead() throws BlockStoreException {
|
||||||
|
// This will hit the cache
|
||||||
StoredBlock head = get(chainHead);
|
StoredBlock head = get(chainHead);
|
||||||
if (head == null)
|
if (head == null)
|
||||||
throw new BlockStoreException("Corrupted block store: chain head not found");
|
throw new BlockStoreException("Corrupted block store: chain head not found");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user