-
-
Save stuarthillary/f3e03cfd321d41b91d42656d575ed46a to your computer and use it in GitHub Desktop.
Revisions
-
abdullin revised this gist
Jul 26, 2018 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,4 +14,9 @@ This naive implementation is a start for building up a deterministic simulation # Questions * How would you implement a ring benchmark in golang? * This .NET Core implementation is way faster than Erlang. What does Erlang spend time on? * Why is this implementation faster than FoundationDB Flow? What extra work could the Flow do? # I want to learn more! What is next? Next, we'll plug into .NET Core async/await to simulate processes running in parallel. [Check it out](https://github.com/abdullin/simasync). -
abdullin revised this gist
Jul 26, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ MIT License 2018 Rinat Abdullin -
abdullin revised this gist
Feb 14, 2018 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,6 +9,9 @@ Given `N=1000` and `M=1000`, the result on my machine is: 00:00:00.0260680 ``` This naive implementation is a start for building up a deterministic simulation of a cluster in a world full of failures. Another building block is the time simulation: https://github.com/abdullin/simcpu # Questions * How would you implement a ring benchmark in golang? * This .NET Core implementation is way faster than Erlang. What does Erlang spend time on? * Why is this implementation faster than FoundationDB Flow? What extra work could the Flow do? -
abdullin revised this gist
Feb 13, 2018 . No changes.There are no files selected for viewing
-
abdullin revised this gist
Feb 13, 2018 . 2 changed files with 14 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ This is a naive (see for yourself!) implementation that explores the idea of simulating a ring of `N` actors that send the messages to each over `M` times. Concept of the ring benchmark and simulated actors is taken from the gist by Preetam Jinka: https://gist.github.com/Preetam/98e80cd17ecb8748c72b Given `N=1000` and `M=1000`, the result on my machine is: ``` /usr/local/share/dotnet/dotnet /Users/rinat/proj/core/SimRing/bin/Release/netcoreapp2.0/SimRing.dll 00:00:00.0260680 ``` Any real-world implementation would be engineered to handle various edge cases, inherently slowing things down. Erlang is a nice example of that. This naive implementation is a start for building up a deterministic simulation of a cluster in a world full of failures. Another building block is the time simulation: https://github.com/abdullin/simcpu This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +0,0 @@ -
abdullin created this gist
Feb 13, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ using System; using System.Collections.Generic; using System.Diagnostics; namespace SimRing { class Program { static void Main(string[] args) { const int n = 1000; const int m = 1000; var actors = new List<Actor>(); var sim = new Sim(); for (int i = 0; i < n; i++) { var next = (i + 1) % n; actors.Add(new Actor(next, sim, m)); } sim.Send(0, new {hello = "world"}); var watch = Stopwatch.StartNew(); while (sim.GetNextMessage(out var msg)) { actors[msg.Recipient].HandleMessage(msg.Body); } Console.WriteLine(watch.Elapsed); } } public class Actor { readonly int NextActor; int _counter; readonly Sim _sim; readonly int _m; public Actor(int nextActor, Sim sim, int m) { NextActor = nextActor; _sim = sim; _m = m; } public void HandleMessage(object message) { _counter++; if (_counter <= _m) { _sim.Send(NextActor, message); } } } public struct Message { public readonly int Recipient; public readonly object Body; public Message(int recipient, object body) { Recipient = recipient; Body = body; } } public sealed class Sim { readonly Queue<Message> _messages = new Queue<Message>(); public void Send(int recipient, object message) { _messages.Enqueue(new Message(recipient, message)); ; } public bool GetNextMessage(out Message msg) { return _messages.TryDequeue(out msg); } } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ /usr/local/share/dotnet/dotnet /Users/rinat/proj/core/SimRing/bin/Release/netcoreapp2.0/SimRing.dll 00:00:00.0260680