Skip to content

Commit

Permalink
Few performance fixes/optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
anakryiko committed Nov 12, 2012
1 parent 0824116 commit 852ec4e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/EventStore/EventStore.Core/Index/HashListMemTable.cs
Expand Up @@ -82,10 +82,14 @@ public void Add(uint stream, int version, long position)
try
{
var tuple = new Tuple<int, long>(version, position);
if (!list.ContainsKey(tuple))
// TODO AN: why do we need to check for existing value?..
//if (!list.ContainsKey(tuple))
{
list.Add(tuple, 1);
_latestPosition = Math.Max(_latestPosition, position);

// TODO AN: positions should be strictly increasing, no need for Max
//_latestPosition = Math.Max(_latestPosition, position);
_latestPosition = position;
}
}
finally
Expand Down
Expand Up @@ -27,7 +27,7 @@
//

#if DEBUG
#define CHECK_COMMIT_DUPLICATES
//#define CHECK_COMMIT_DUPLICATES
#endif

using System;
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class StorageWriter : IDisposable,
IHandle<StorageMessage.WriteTransactionPrepare>,
IHandle<StorageMessage.WriteCommit>
{
private static readonly decimal MsPerTick = 1000.0M / Stopwatch.Frequency;
private static readonly long TicksPerMs = Stopwatch.Frequency / 1000;

protected readonly TFChunkWriter Writer;
protected readonly IReadIndex ReadIndex;
Expand Down Expand Up @@ -432,7 +432,7 @@ private bool ShouldCreateStreamFor(StorageMessage.IPreconditionedWriteMessage me
protected bool Flush()
{
var start = _watch.ElapsedTicks;
if (start - _lastFlush >= _flushDelay + 2 * MsPerTick || FlushMessagesInQueue == 0)
if (start - _lastFlush >= _flushDelay + 2 * TicksPerMs || FlushMessagesInQueue == 0)
{
Writer.Flush();
var end = _watch.ElapsedTicks;
Expand Down

0 comments on commit 852ec4e

Please sign in to comment.