Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,20 @@ matrix:
- os: linux # Ubuntu 14.04
dist: trusty
sudo: required
- os: linux # Ubuntu 14.04
dist: trusty
env: BUILD_DOCKER=true
- os: osx # OSX 10.12
osx_image: xcode8.3

before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$BUILD_DOCKER" != true ]]; then sudo ./scripts/ubuntu-prereqs.sh ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./scripts/ubuntu-prereqs.sh ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./scripts/mac-prereqs.sh ; fi

install:
- if [[ "$BUILD_DOCKER" != true ]]; then ./scripts/dotnet-install.sh ; fi
- if [[ "$BUILD_DOCKER" != true ]]; then PATH=$PATH:$HOME/.dotnet && export PATH ; fi
- ./scripts/dotnet-install.sh
- PATH=$PATH:$HOME/.dotnet && export PATH
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then docker-compose -f docker-compose.yml up -d ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tarantool tarantool/tarantool.lua ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then redis-server --daemonize yes ; fi

script:
- if [[ "$BUILD_DOCKER" != true ]]; then ./scripts/build-netcore.sh ; fi
- if [[ "$BUILD_DOCKER" != true ]]; then ./scripts/test-netcore.sh ; fi
- if [[ "$BUILD_DOCKER" == true ]]; then docker-compose -f docker-compose.yml -f docker-compose.tests.yml up --build tarantool-client ; fi
- ./scripts/build-netcore.sh
- ./scripts/test-netcore.sh
34 changes: 0 additions & 34 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "1.0.0"
"version": "2.0.0"
}
}
24 changes: 23 additions & 1 deletion progaudi.tarantool.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
VisualStudioVersion = 15.0.26730.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "progaudi.tarantool", "src\progaudi.tarantool\progaudi.tarantool.csproj", "{DD007E9F-FB2D-4351-AAB7-F2D367B295C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "progaudi.tarantool.tests", "tests\progaudi.tarantool.tests\progaudi.tarantool.tests.csproj", "{4C681801-9A6B-4CE9-8EAA-23F80917F046}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{14BAEDF1-BEFC-4FB2-AAC9-08D397191216}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "progaudi.tarantool.benchmark", "src\progaudi.tarantool.benchmark\progaudi.tarantool.benchmark.csproj", "{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -41,8 +48,23 @@ Global
{4C681801-9A6B-4CE9-8EAA-23F80917F046}.Release|x64.Build.0 = Release|Any CPU
{4C681801-9A6B-4CE9-8EAA-23F80917F046}.Release|x86.ActiveCfg = Release|Any CPU
{4C681801-9A6B-4CE9-8EAA-23F80917F046}.Release|x86.Build.0 = Release|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x64.ActiveCfg = Debug|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x64.Build.0 = Debug|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x86.ActiveCfg = Debug|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x86.Build.0 = Debug|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|Any CPU.Build.0 = Release|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x64.ActiveCfg = Release|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x64.Build.0 = Release|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x86.ActiveCfg = Release|Any CPU
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ADF03192-56BA-4020-9654-59533D08C629}
EndGlobalSection
EndGlobal
8 changes: 4 additions & 4 deletions samples/docker-compose/dotnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM progaudi/dotnet:1.0.1-xenial
FROM microsoft/dotnet:2.0.0-sdk

WORKDIR /app
ADD dotnet.csproj /app/dotnet.csproj
RUN /root/.dotnet/dotnet restore
RUN dotnet restore

ADD . /app
RUN /root/.dotnet/dotnet build -c Release -f netcoreapp1.1 /app/dotnet.csproj
RUN dotnet build -c Release -f netcoreapp2.0 /app/dotnet.csproj

EXPOSE 5000/tcp

CMD ["/root/.dotnet/dotnet", "run", "--server.urls", "http://*:5000"]
CMD ["dotnet", "run", "--server.urls", "http://*:5000"]
9 changes: 4 additions & 5 deletions samples/docker-compose/dotnet/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.IO;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;

Expand All @@ -10,13 +10,12 @@ public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddCommandLine(args)
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
.AddEnvironmentVariables("ASPNETCORE_")
.Build();

var host = new WebHostBuilder()
var host = WebHost
.CreateDefaultBuilder(args)
.UseConfiguration(config)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</tbody>
<tfoot>
<tr>
<td colspan="3">@Model.Dogs.Count dogs total</td>
<td colspan="4">@Model.Dogs.Count dogs total</td>
</tr>
</tfoot>
</table>
Expand Down
2 changes: 2 additions & 0 deletions samples/docker-compose/dotnet/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
ViewData["Title"] = "Tarantool demo page";
}

<h1>Render time is @DateTimeOffset.Now.ToString("F")</h1>

@Html.Partial("DogTablePartial", new DogTable(Model[0], "All dogs in Tarantool"))

@Html.Partial("DogTablePartial", new DogTable(Model[1], "Senior dogs in Tarantool"))
Expand Down
22 changes: 6 additions & 16 deletions samples/docker-compose/dotnet/dotnet.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="progaudi.tarantool" Version="0.9.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
<PackageReference Include="msgpack.light" Version="1.3.0" />
<PackageReference Include="progaudi.tarantool" Version="0.8.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
</Project>
2 changes: 2 additions & 0 deletions scripts/build-netcore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ cd ..

dotnet restore
dotnet build -c Release -f netstandard1.4 src/progaudi.tarantool/progaudi.tarantool.csproj
dotnet build -c Release -f netstandard2.0 src/progaudi.tarantool/progaudi.tarantool.csproj
dotnet build -c Release -f netcoreapp1.0 tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj
dotnet build -c Release -f netcoreapp1.1 tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj
dotnet build -c Release -f netcoreapp2.0 tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj

popd
4 changes: 2 additions & 2 deletions scripts/dotnet-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ set -ev

curl -o ./dotnet-install.sh -fL https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh
chmod +x ./dotnet-install.sh
version=$(jq -r .sdk.version global.json)
./dotnet-install.sh --version $version
./dotnet-install.sh --version 1.0.4
./dotnet-install.sh --version 2.0.0
36 changes: 36 additions & 0 deletions src/progaudi.tarantool.benchmark/BenchmarkConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Exporters.Csv;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Toolchains.CsProj;

namespace progaudi.tarantool.benchmark
{
internal class BenchmarkConfig : ManualConfig
{
public BenchmarkConfig()
{
Add(StatisticColumn.P95);

Add(MemoryDiagnoser.Default);

// https://github.com/dotnet/BenchmarkDotNet/issues/500
//Add(Job.ShortRun.With(Jit.LegacyJit).With(Platform.X86).With(Runtime.Clr));
//Add(Job.ShortRun.With(Jit.LegacyJit).With(Platform.X64).With(Runtime.Clr));

//Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Clr));

// RyuJit for .NET Core 1.1
Add(Job.Default.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp11).WithId("netcore1.1"));

// RyuJit for .NET Core 2.0
Add(Job.Default.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp20).WithId("netcore2.0"));

Add(MarkdownExporter.GitHub);
Add(CsvMeasurementsExporter.Default);
}
}
}
27 changes: 27 additions & 0 deletions src/progaudi.tarantool.benchmark/IncrementBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using ProGaudi.Tarantool.Client;
using ProGaudi.Tarantool.Client.Model.Responses;
using StackExchange.Redis;

namespace progaudi.tarantool.benchmark
{
[Config(typeof(BenchmarkConfig))]
public class IncrementBenchmark
{
private readonly Box _box;
private readonly IDatabaseAsync _redis;

public IncrementBenchmark()
{
_box = Box.Connect("localhost", 3301).GetAwaiter().GetResult();
_redis = ConnectionMultiplexer.Connect("localhost:6379").GetDatabase();
}

[Benchmark(Baseline = true)]
public async Task<long> Redis() => await _redis.StringIncrementAsync("test_for_benchmarking");

[Benchmark]
public async Task<DataResponse<int[]>> Tarantool() => await _box.Call<int>("test_for_benchmarking");
}
}
9 changes: 9 additions & 0 deletions src/progaudi.tarantool.benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using BenchmarkDotNet.Running;

namespace progaudi.tarantool.benchmark
{
public static class Program
{
public static void Main() => BenchmarkRunner.Run<IncrementBenchmark>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
<WarningsAsErrors>true</WarningsAsErrors>

<AssemblyName>progaudi.tarantool.benchmark</AssemblyName>
<RootNamespace>ProGaudi.Tarantool.Benchmark</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.10.9" />
<PackageReference Include="StackExchange.Redis" Version="1.2.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\progaudi.tarantool\progaudi.tarantool.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/progaudi.tarantool/IRequestWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ internal interface IRequestWriter : IDisposable

bool IsConnected { get; }

Task Write(ArraySegment<byte> header, ArraySegment<byte> body);
void Write(ArraySegment<byte> header, ArraySegment<byte> body);
}
}
21 changes: 13 additions & 8 deletions src/progaudi.tarantool/LogicalConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ private async Task<TResponse> SendRequestImpl<TRequest, TResponse>(TRequest requ
var requestId = _requestIdCounter.GetRequestId();
var responseTask = _responseReader.GetResponseTask(requestId);

var headerBuffer = CreateAndSerializeBuffer(request, requestId, bodyBuffer, out var headerLength);
await _requestWriter.Write(
new ArraySegment<byte>(headerBuffer, 0, Constants.PacketSizeBufferSize + (int) headerLength),
var headerBuffer = CreateAndSerializeHeader(request, requestId, bodyBuffer);
_requestWriter.Write(
headerBuffer,
new ArraySegment<byte>(bodyBuffer, 0, bodyBuffer.Length));

try
Expand Down Expand Up @@ -175,11 +175,15 @@ private static string ToReadableString(byte[] bytes)
return string.Join(" ", bytes.Select(b => b.ToString("X2")));
}

private byte[] CreateAndSerializeBuffer<TRequest>(
private static string ToReadableString(ArraySegment<byte> bytes)
{
return string.Join(" ", bytes.Select(b => b.ToString("X2")));
}

private ArraySegment<byte> CreateAndSerializeHeader<TRequest>(
TRequest request,
RequestId requestId,
byte[] serializedRequest,
out long headerLength) where TRequest : IRequest
byte[] serializedRequest) where TRequest : IRequest
{
var packetSizeBuffer = new byte[Constants.PacketSizeBufferSize + Constants.MaxHeaderLength];
var stream = new MemoryStream(packetSizeBuffer);
Expand All @@ -188,11 +192,12 @@ private byte[] CreateAndSerializeBuffer<TRequest>(
stream.Seek(Constants.PacketSizeBufferSize, SeekOrigin.Begin);
MsgPackSerializer.Serialize(requestHeader, stream, _msgPackContext);

headerLength = stream.Position - Constants.PacketSizeBufferSize;
var lengthAndHeaderLengthByteCount = (int)stream.Position;
var headerLength = lengthAndHeaderLengthByteCount - Constants.PacketSizeBufferSize;
var packetLength = new PacketSize((uint) (headerLength + serializedRequest.Length));
stream.Seek(0, SeekOrigin.Begin);
MsgPackSerializer.Serialize(packetLength, stream, _msgPackContext);
return packetSizeBuffer;
return new ArraySegment<byte>(packetSizeBuffer, 0, lengthAndHeaderLengthByteCount);
}
}
}
Loading