Skip to content

Commit

Permalink
Marten is using FastExpressionCompiler
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed May 3, 2017
1 parent 2a5d574 commit 7e7cb17
Show file tree
Hide file tree
Showing 24 changed files with 263 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0

WarmupCount=2 Gen 0=1014.4231 Allocated=7.74 MB

Method | Mean | StdDev |
-------------------- |------------ |---------- |
BulkInsertDocuments | 188.1269 ms | 8.5848 ms |
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
``` ini

BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0

WarmupCount=2 Gen 0=1014.4231 Allocated=7.74 MB

```
Method | Mean | StdDev |
-------------------- |------------ |---------- |
BulkInsertDocuments | 188.1269 ms | 8.5848 ms |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxStdErrRelative,MinInvokeCount,MinIterationTime,RemoveOutliers,Affinity,Jit,Platform,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,Server,Clock,EngineFactory,Toolchain,InvocationCount,IterationTime,LaunchCount,RunStrategy,TargetCount,UnrollFactor,WarmupCount,Mean,StdDev,Gen 0,Allocated
BulkInsertDocuments,Default,False,Default,Default,Default,Default,Default,15,RyuJit,X64,Clr,False,True,False,True,False,Default,Default,Default,1,Default,Default,Default,Default,16,2,188.1269 ms,8.5848 ms,1014.4231,7.74 MB
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>BulkLoading</title>

<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
</code></pre>
<pre><code>WarmupCount=2 Gen 0=1014.4231 Allocated=7.74 MB
</code></pre>

<table>
<thead><tr><th> Method</th><th> Mean</th><th>StdDev</th>
</tr>
</thead><tbody><tr><td>BulkInsertDocuments</td><td>188.1269 ms</td><td>8.5848 ms</td>
</tr></tbody></table>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0

WarmupCount=2 Gen 0=187.5000 Allocated=4.48 MB

Method | Mean | StdDev |
---------------- |----------- |---------- |
InsertDocuments | 43.6080 ms | 0.8464 ms |
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
``` ini

BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0

WarmupCount=2 Gen 0=187.5000 Allocated=4.48 MB

```
Method | Mean | StdDev |
---------------- |----------- |---------- |
InsertDocuments | 43.6080 ms | 0.8464 ms |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxStdErrRelative,MinInvokeCount,MinIterationTime,RemoveOutliers,Affinity,Jit,Platform,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,Server,Clock,EngineFactory,Toolchain,InvocationCount,IterationTime,LaunchCount,RunStrategy,TargetCount,UnrollFactor,WarmupCount,Mean,StdDev,Gen 0,Allocated
InsertDocuments,Default,False,Default,Default,Default,Default,Default,15,RyuJit,X64,Clr,False,True,False,True,False,Default,Default,Default,1,Default,Default,Default,Default,16,2,43.6080 ms,0.8464 ms,187.5000,4.48 MB
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>DocumentActions</title>

<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
</code></pre>
<pre><code>WarmupCount=2 Gen 0=187.5000 Allocated=4.48 MB
</code></pre>

<table>
<thead><tr><th> Method</th><th>Mean</th><th>StdDev</th>
</tr>
</thead><tbody><tr><td>InsertDocuments</td><td>43.6080 ms</td><td>0.8464 ms</td>
</tr></tbody></table>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0

WarmupCount=2 Allocated=1.88 MB

Method | Mean | StdDev |
------------- |----------- |---------- |
AppendEvents | 44.7526 ms | 1.0882 ms |
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
``` ini

BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0

WarmupCount=2 Allocated=1.88 MB

```
Method | Mean | StdDev |
------------- |----------- |---------- |
AppendEvents | 44.7526 ms | 1.0882 ms |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxStdErrRelative,MinInvokeCount,MinIterationTime,RemoveOutliers,Affinity,Jit,Platform,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,Server,Clock,EngineFactory,Toolchain,InvocationCount,IterationTime,LaunchCount,RunStrategy,TargetCount,UnrollFactor,WarmupCount,Mean,StdDev,Allocated
AppendEvents,Default,False,Default,Default,Default,Default,Default,15,RyuJit,X64,Clr,False,True,False,True,False,Default,Default,Default,1,Default,Default,Default,Default,16,2,44.7526 ms,1.0882 ms,1.88 MB
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>EventActions</title>

<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
</code></pre>
<pre><code>WarmupCount=2 Allocated=1.88 MB
</code></pre>

<table>
<thead><tr><th>Method</th><th>Mean</th><th>StdDev</th>
</tr>
</thead><tbody><tr><td>AppendEvents</td><td>44.7526 ms</td><td>1.0882 ms</td>
</tr></tbody></table>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0

WarmupCount=2

Method | Mean | StdErr | StdDev | Gen 0 | Allocated |
------------------ |---------------- |-------------- |-------------- |---------- |---------- |
CreateLinqCommand | 197.4190 us | 1.9695 us | 13.9265 us | - | 42.45 kB |
RunLinqQuery | 121,335.7528 us | 1,200.0957 us | 4,800.3829 us | 4986.4130 | 33.68 MB |
CompiledQueries | 30,801.5613 us | 309.4860 us | 3,079.3465 us | 812.5000 | 8.59 MB |
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
``` ini

BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0

WarmupCount=2

```
Method | Mean | StdErr | StdDev | Gen 0 | Allocated |
------------------ |---------------- |-------------- |-------------- |---------- |---------- |
CreateLinqCommand | 197.4190 us | 1.9695 us | 13.9265 us | - | 42.45 kB |
RunLinqQuery | 121,335.7528 us | 1,200.0957 us | 4,800.3829 us | 4986.4130 | 33.68 MB |
CompiledQueries | 30,801.5613 us | 309.4860 us | 3,079.3465 us | 812.5000 | 8.59 MB |
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxStdErrRelative,MinInvokeCount,MinIterationTime,RemoveOutliers,Affinity,Jit,Platform,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,Server,Clock,EngineFactory,Toolchain,InvocationCount,IterationTime,LaunchCount,RunStrategy,TargetCount,UnrollFactor,WarmupCount,Mean,StdErr,StdDev,Gen 0,Allocated
CreateLinqCommand,Default,False,Default,Default,Default,Default,Default,15,RyuJit,X64,Clr,False,True,False,True,False,Default,Default,Default,1,Default,Default,Default,Default,16,2,197.4190 us,1.9695 us,13.9265 us,-,42.45 kB
RunLinqQuery,Default,False,Default,Default,Default,Default,Default,15,RyuJit,X64,Clr,False,True,False,True,False,Default,Default,Default,1,Default,Default,Default,Default,16,2,"121,335.7528 us","1,200.0957 us","4,800.3829 us",4986.4130,33.68 MB
CompiledQueries,Default,False,Default,Default,Default,Default,Default,15,RyuJit,X64,Clr,False,True,False,True,False,Default,Default,Default,1,Default,Default,Default,Default,16,2,"30,801.5613 us",309.4860 us,"3,079.3465 us",812.5000,8.59 MB
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>LinqActions</title>

<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4980HQ CPU 2.80GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
Job-DNINOD : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1076.0
</code></pre>
<pre><code>WarmupCount=2
</code></pre>

<table>
<thead><tr><th> Method</th><th> Mean</th><th> StdErr</th><th> StdDev</th><th>Gen 0</th><th>Allocated</th>
</tr>
</thead><tbody><tr><td>CreateLinqCommand</td><td>197.4190 us</td><td>1.9695 us</td><td>13.9265 us</td><td> -</td><td>42.45 kB</td>
</tr><tr><td>RunLinqQuery</td><td>121,335.7528 us</td><td>1,200.0957 us</td><td>4,800.3829 us</td><td>4986.4130</td><td>33.68 MB</td>
</tr><tr><td>CompiledQueries</td><td>30,801.5613 us</td><td>309.4860 us</td><td>3,079.3465 us</td><td>812.5000</td><td>8.59 MB</td>
</tr></tbody></table>
</body>
</html>
4 changes: 2 additions & 2 deletions src/Marten/Events/Projections/AggregateFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using FastExpressionCompiler;
using Marten.Schema;

namespace Marten.Events.Projections
Expand All @@ -29,7 +29,7 @@ public AggregateFinder()

var lambda = Expression.Lambda<Action<T, Guid>>(assign, docParam, idParam);

_setId = lambda.Compile();
_setId = ExpressionCompiler.Compile<Action<T, Guid>>(lambda);
}

public T Find(EventStream stream, IDocumentSession session)
Expand Down
3 changes: 2 additions & 1 deletion src/Marten/Events/Projections/AggregationStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using FastExpressionCompiler;

namespace Marten.Events.Projections
{
Expand All @@ -25,7 +26,7 @@ public AggregationStep(MethodInfo method)

var lambda = Expression.Lambda<Action<T, TEvent>>(body, aggregateParameter, eventParameter);

_apply = lambda.Compile();
_apply = ExpressionCompiler.Compile<Action<T, TEvent>>(lambda);
}

public AggregationStep(Action<T, TEvent> apply)
Expand Down
3 changes: 2 additions & 1 deletion src/Marten/Events/Projections/EventAggregationStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using FastExpressionCompiler;

namespace Marten.Events.Projections
{
Expand All @@ -25,7 +26,7 @@ public EventAggregationStep(MethodInfo method)

var lambda = Expression.Lambda<Action<T, Event<TEvent>>>(body, aggregateParameter, eventParameter);

_apply = lambda.Compile();
_apply = ExpressionCompiler.Compile<Action<T, Event<TEvent>>>(lambda);
}

public EventAggregationStep(Action<T, Event<TEvent>> apply)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Linq.Expressions;
using System.Reflection;
using FastExpressionCompiler;

namespace Marten.Linq.QueryHandlers.CompiledInclude
{
Expand All @@ -21,7 +22,7 @@ protected static PropertyInfo GetPropertyInfo(PropertyInfo property, IncludeResu

var lambda = Expression.Lambda<Func<IncludeResultOperator, LambdaExpression>>(callGetMethod, target);

var compiledLambda = lambda.Compile();
var compiledLambda = ExpressionCompiler.Compile<Func<IncludeResultOperator, LambdaExpression>>(lambda);
var callback = compiledLambda.Invoke(@operator);
var mi = (PropertyInfo)((MemberExpression)callback.Body).Member;
return mi;
Expand Down
3 changes: 2 additions & 1 deletion src/Marten/Schema/BulkLoading/BulkLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Linq.Expressions;
using Baseline;
using FastExpressionCompiler;
using Marten.Schema.Arguments;
using Marten.Schema.Identity;
using Marten.Services;
Expand Down Expand Up @@ -52,7 +53,7 @@ public BulkLoader(ISerializer serializer, DocumentMapping mapping, IdAssignment<
var lambda = Expression.Lambda<Action<T, string, ISerializer, NpgsqlBinaryImporter, CharArrayTextWriter>>(block, document, alias,
serializerParam, writer, textWriter);

_transferData = lambda.Compile();
_transferData = ExpressionCompiler.Compile<Action<T, string, ISerializer, NpgsqlBinaryImporter, CharArrayTextWriter>>(lambda);
}

public void Load(ISerializer serializer, NpgsqlConnection conn, IEnumerable<T> documents, CharArrayTextWriter textWriter)
Expand Down
4 changes: 2 additions & 2 deletions src/Marten/Schema/Resolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;
using System.Threading.Tasks;
using Baseline;
using FastExpressionCompiler;
using Marten.Linq;
using Marten.Schema.Identity;
using Marten.Services;
Expand Down Expand Up @@ -88,8 +89,7 @@ public Resolver(ISerializer serializer, DocumentMapping mapping, bool useCharBuf
call, doc, batch, mappingParam, currentVersion, newVersion
});


return lambda.Compile();
return ExpressionCompiler.Compile<Action<SprocCall, T, UpdateBatch, DocumentMapping, Guid?, Guid>>(lambda);
}

public Type DocumentType => _mapping.DocumentType;
Expand Down
Loading

0 comments on commit 7e7cb17

Please sign in to comment.