-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Created CompilationOptions.cs to be able to turn off ParallelizationMode.cs 2. Tests specific order fixes 3. Add a benchmark project to measure whether parallelization does something meaningfull. Parallelization p.1 turn on parallelization for simple case "select ... from whatever where ..."
- Loading branch information
Showing
61 changed files
with
97,190 additions
and
2,173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,4 +263,6 @@ __pycache__/ | |
merged-test-results.xml | ||
|
||
_site/ | ||
.jekyll-cache/ | ||
.jekyll-cache/ | ||
|
||
**/BenchmarkDotNet.Artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Musoq.Benchmarks.Schema; | ||
using Musoq.Benchmarks.Schema.Country; | ||
using Musoq.Benchmarks.Schema.Profiles; | ||
using Musoq.Converter; | ||
using Musoq.Evaluator; | ||
using Musoq.Plugins; | ||
using Musoq.Tests.Common; | ||
|
||
namespace Musoq.Benchmarks.Components; | ||
|
||
public class BenchmarkBase | ||
{ | ||
static BenchmarkBase() | ||
{ | ||
new Plugins.Environment().SetValue(Constants.NetStandardDllEnvironmentVariableName, EnvironmentUtils.GetOrCreateEnvironmentVariable()); | ||
|
||
Culture.ApplyWithDefaultCulture(); | ||
} | ||
|
||
protected CancellationTokenSource TokenSource { get; } = new(); | ||
|
||
protected CompiledQuery CreateForCountryWithOptions( | ||
string script, | ||
IDictionary<string, IEnumerable<CountryEntity>> sources, | ||
CompilationOptions compilationOptions) | ||
{ | ||
return InstanceCreator.CompileForExecution( | ||
script, | ||
Guid.NewGuid().ToString(), | ||
new GenericSchemaProvider<CountryEntity, CountryEntityTable>(sources, CountryEntity.KNameToIndexMap, CountryEntity.KIndexToObjectAccessMap), compilationOptions); | ||
} | ||
|
||
protected CompiledQuery CreateForProfilesWithOptions( | ||
string script, | ||
IDictionary<string, IEnumerable<ProfileEntity>> sources, | ||
CompilationOptions compilationOptions) | ||
{ | ||
return InstanceCreator.CompileForExecution( | ||
script, | ||
Guid.NewGuid().ToString(), | ||
new GenericSchemaProvider<ProfileEntity, ProfileEntityTable>(sources, ProfileEntity.KNameToIndexMap, ProfileEntity.KIndexToObjectAccessMap), compilationOptions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Musoq.Benchmarks.Helpers; | ||
using Musoq.Benchmarks.Schema.Country; | ||
using Musoq.Benchmarks.Schema.Profiles; | ||
using Musoq.Evaluator; | ||
using Musoq.Evaluator.Tables; | ||
|
||
namespace Musoq.Benchmarks.Components; | ||
|
||
public class ExecutionBenchmark : BenchmarkBase | ||
{ | ||
private readonly CompiledQuery _queryForComputeCountriesWithParallelization; | ||
private readonly CompiledQuery _queryForComputeCountriesWithoutParallelization; | ||
private readonly CompiledQuery _queryForComputeProfilesWithParallelization; | ||
private readonly CompiledQuery _queryForComputeProfilesWithoutParallelization; | ||
|
||
public ExecutionBenchmark() | ||
{ | ||
_queryForComputeCountriesWithParallelization = CreateCompiledQueryWithOptions(new CompilationOptions(ParallelizationMode.Full)); | ||
_queryForComputeCountriesWithoutParallelization = CreateCompiledQueryWithOptions(new CompilationOptions(ParallelizationMode.None)); | ||
_queryForComputeProfilesWithParallelization = ComputeProfilesWithOptions(new CompilationOptions(ParallelizationMode.Full)); | ||
_queryForComputeProfilesWithoutParallelization = ComputeProfilesWithOptions(new CompilationOptions(ParallelizationMode.None)); | ||
} | ||
|
||
// [Benchmark] | ||
// public Table ComputeSimpleSelect_WithParallelization_1MbOfData_Countries() | ||
// { | ||
// return _queryForComputeCountriesWithParallelization.Run(); | ||
// } | ||
// | ||
// [Benchmark] | ||
// public Table ComputeSimpleSelect_WithoutParallelization_1MbOfData_Countries() | ||
// { | ||
// return _queryForComputeCountriesWithoutParallelization.Run(); | ||
// } | ||
|
||
[Benchmark] | ||
public Table ComputeSimpleSelect_WithParallelization_10MbOfData_Profiles() | ||
{ | ||
return _queryForComputeProfilesWithParallelization.Run(); | ||
} | ||
|
||
[Benchmark] | ||
public Table ComputeSimpleSelect_WithoutParallelization_10MbOfData_Profiles() | ||
{ | ||
return _queryForComputeProfilesWithoutParallelization.Run(); | ||
} | ||
|
||
[GlobalCleanup] | ||
public void Cleanup() | ||
{ | ||
} | ||
|
||
private CompiledQuery CreateCompiledQueryWithOptions(CompilationOptions compilationOptions) | ||
{ | ||
var script = "select City, Country, Population from #A.Entities() where Population > 500000"; | ||
var contentPath = Path.Combine(AppContext.BaseDirectory, "Data", "countries.json"); | ||
var data = DataHelpers.ParseCountryData(contentPath); | ||
var sources = new Dictionary<string, IEnumerable<CountryEntity>> | ||
{ | ||
{"#A", data} | ||
}; | ||
|
||
return CreateForCountryWithOptions(script, sources, compilationOptions); | ||
} | ||
|
||
private CompiledQuery ComputeProfilesWithOptions(CompilationOptions compilationOptions) | ||
{ | ||
const string script = "select FirstName, LastName, Email, Gender, IpAddress, Date, Image, Animal, Avatar from #A.Entities() where Email like '%.co.uk'"; | ||
var contentPath = Path.Combine(AppContext.BaseDirectory, "Data", "profiles.csv"); | ||
var data = DataHelpers.ReadProfiles(contentPath); | ||
var sources = new Dictionary<string, IEnumerable<ProfileEntity>> | ||
{ | ||
{"#A", data} | ||
}; | ||
|
||
return CreateForProfilesWithOptions(script, sources, compilationOptions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
profiles.csv taken from https://github.com/frictionlessdata/datasets | ||
license: MIT: | ||
|
||
MIT License | ||
|
||
Copyright (c) 2018 Frictionless Data | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
|
||
countries.json taken from https://github.com/russ666/all-countries-and-cities-json | ||
license: MIT: | ||
|
||
MIT License | ||
|
||
Copyright (c) 2016 Egor Usoltcev | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.