Better HN
topnewbestaskshowjobs
Log inSign up

algorithmsRcool

1,521 karma · joined May 25, 2012 (14y ago) · 286 submissions

https://github.com/AlgorithmsAreCool
Submissions

151.

Why is string.GetHashCode() different each time I run my program in .NET Core?(andrewlock.net ↗)

1 points · by algorithmsRcool · 7y ago · discuss

comment 7y ago · link · parent

I gave the paper a full read through last night.

Essentially this is a language agnostic framework for building data processing systems that are highly-avalible, distributed, topologically static (no dynamic scaling), and features exactly once processing.

You define a message handler that will always produce the same output sequence given the same input sequence and the framework provides delivery, serialization, buffering, durability and transparent recovery. They even provide a nice way of wrapping non deterministic behavior so that you can seamlessly continue even if you fail in the middle of processing a message.

That being said, the really are sloppy with their performance numbers, the comparison to gRPC isn't really fair at all due to their dynamic batching. And the code examples in the paper have some really silly errors.

But the paper is still a great introduction to reliable stream processing and basic strategies for delivering exactly once delivery.

Also, there is some interesting code that the paper glosses over in this repo: https://github.com/Microsoft/CRA

comment 8y ago · link · parent

Enthusiasm?

comment 8y ago · link · parent

Research Paper: https://www.microsoft.com/en-us/research/uploads/prod/2018/1...

Basic intro: https://github.com/Microsoft/AMBROSIA/blob/master/docs/Ambro...

155.

Ambrosia: Robust Distributed Programming Made Easy and Efficient(github.com ↗)

24 points · by algorithmsRcool · 8y ago · 8 comments

comment 8y ago · link · parent

Well, I think it is an engineering problem. WPF is basically cemented to DirectX which only exists on Windows.

comment 8y ago · link · parent

Nope, it will be a windows only capability.

-Edit-

I should add that the purpose of them adding this capability isn't to set up a new cross-platform UI suite. It is just to lure enterprise shops to .NET core by supporting more of their .NET Framework workloads

comment 8y ago · link · parent

SignalR Core is what i meant.

It is alive an under active development on .NET Core

https://github.com/aspnet/SignalR

comment 8y ago · link · parent

Since the entire design of Pipelines is 0-copy, I figure you would have to manually pull from one pipe, operate on it and push the resulting data into another pipe.

Im sure there is an example of connecting pipes together like this somewhere. Maybe in Kestrel or SignalR (Core)?

comment 8y ago · link · parent

David Fowler (The architect of this API) is brilliant! The Pipelines API turned out better than I ever expected.

comment 8y ago · link · parent

Not directly related to the article, but there is an experimental effort to develop a userland TCP stack in .NET right now.

It's interesting to see how this looks in a higher level language.

https://github.com/ProjectMagma/Magma

comment 8y ago · link · parent

Yes, this is what I had to do because of .Net core. I still had some trouble getting the cluster to deploy smoothly.

But honestly, K8s has first class support from MS, Google, AWS. Has major buy-in from the community, good docs, plenty of recorded talks, presentations and war stories and a very active community.

SF has basically none of that. At the end of the day, SF isn't massively better than K8s for my use case and It would have to be to make up for all those disadvantages.

comment 8y ago · link · parent

I'll add another voice on this exact same situation.

Trying to get .net core app running on SF was extremely frustrating and confusing. K8s was a MUCH more natural experience.

I was really disappointed in the tooling. The sfproj files were this incomprehensible mess. If the ui didn't quite work you are hosed.

I would go on but I'm on mobile

comment 8y ago · link · parent

There are scattered few. Leppie has maintained IronScheme for years now and the good folks as Peachpie have PHP running on CoreClr(via Roslyn even!)

comment 8y ago · link · parent

Good question. BlockingCollection is actually a wrapper around a ConcurrentQueue. It provides some nice things like....blocking so the queue can be used in a producer/consumer manner.

Channels does this but has 2 advantages.

1. It is built on the most up-to-date threading primatives (ValueTask) which gives it a perf advantage.

2. It's internal design is very simple and lightweight. BlockingCollection was designed to have swappable guts. Channels are single purpose.

The other nice thing is the channels API is really no nonsense super simple to get GREAT performance out of normal async/await. No tuning really needed. I got >300Krps out of a sequence of chained channels with a buffer size of 1.

comment 8y ago · link · parent

I responded elsewhere in this thread.

https://news.ycombinator.com/item?id=17190877

comment 8y ago · link · parent

This guy works on dotnet his answer is much better than mine.

comment 8y ago · link · parent

I feel your pain. F# has effectively been punished for being so innovative.

They had tuples, async/await, and match statements a decade ago and every time C# adopts one of their feature they change the implementation and make F# retool. It's kinda awful.

At this point I want F# to do a hard reset, rebuild on top of Roslyn, natively adopt ValueTuple and Task/ValueTask then grow alongside C# like VB tried to.

comment 8y ago · link · parent

Yeah, our clients are on Framework I feel your pain.

...But reading between the lines, you probably still have clients on XP (.NET 4.0). That's gotta sting. We made a fuss about TLS1.2 support being required and forced them to upgrade to Win7/.NET 4.5.2 at least.

I have gotten gotten a smallish winforms app to work with the new .csproj format. But it's painful. WPF is probably a nightmare.

As an aside if you make it to .NET 4.5+ and get async/await. It works great with winforms and presumably WPF!

comment 8y ago · link · parent

Here is the example code. Comments and Questions are welcome.

https://gist.github.com/AlgorithmsAreCool/b0960ce8a3400305e4...

comment 8y ago · link · parent

You are very correct, I'll try to temper my enthusiasm.

comment 8y ago · link · parent

Uhh, Span/Memory support is coming soon https://github.com/fsharp/fslang-suggestions/issues/648

Channel<T> uses ValueTask<T> which is kinda painful in F# for now.

https://github.com/fsharp/fslang-suggestions/issues/581

comment 8y ago · link · parent

Yes, but the Channel<T> i am referring to is a separate project from Stephen Toub that came from CoreFxLab

comment 8y ago · link · parent

The Docs on Channel<T> are currently lacking :(

But it is pretty simple to use. It is in nuget package "System.Threading.Channels".

You basically call Channel.CreateBounded<T>(int) to create a channel that will buffer a limited number of T objects.

A Channel has a ChannelReader and ChannelWriter which are two ends of the same channel. The reader is the output side, the writer is the input side.

Each side exposes methods to synchronously try to Read or Write or asynchronously Read or Write (respectively).

It supports "Completion" meaning that the Writer can signal the Reader(s) that it is done writing forever. For example imagine you had a channel that was for Log Messages. A bunch of readers might be listening, but then the App shuts down. The writer can call "Complete()" on the channel and the Readers will get wake up and get a message that there is no more messages and flush themselves and shut down.

As a note you will need to run your own processing thread to await messages from the channel. Unlike Dataflow which will span it's own taks to handle messages.

I will write up an example Gist and reply to this thread in a little bit.

Other notes: - The API is very similar to Dataflow since Stephen Toub wrote them both. - It is extremely fast. I have seen > 1.25M messages per second in my benchmarks. - It is mostly allocation free due to using the new ValueTask<T> which is a struct

Futher Reading: https://www.nuget.org/packages/System.Threading.Channels/ https://apisof.net/catalog/System.Threading.Channels

comment 8y ago · link · parent

Right now I wouldn't expect much. I did some very very rudimentary benchmarks and saw a slight drop in perf using Tiered Compilation.

But now that it exists we can expect regular improvements with every point release.

comment 8y ago · link · parent

I'm flattered, but unfortunately I'm not a mac person.

VSCode and Rider are the two standouts. I love VSCode on windows and Linux, but I have heard nothing but good things about Rider.

comment 8y ago · link · parent

If you are at the application level then you can use whatever, but Span<T> is pretty handy. If you are calling an method that has both Span and Array overloads, prefer the Span version since it is less likely to copy or allocate.

The real selling point is that Span is much more flexible than an Array. Both Managed and Unmanged memory can work with it. If you load a big string and need to get each line from it, you can slice into the middle of the string safely and get a ReadOnlySpan<char> that supports most 'string' operations without allocating any memory.

Or imagine you need to process some huge file, typically you would read it chunk by chunk copying the data from the Stream into some byte[]. But with Span you could open a Memory Mapped File and work on segments of the file without copying into temp buffers.

You gain a lot by avoiding memory copies and by allocating fewer objects (less work for the GC). For some workloads then can be a huge speedup.

comment 8y ago · link · parent

So the .NET Core SDK and command line tools do not require VS at all. VSCode works fine or whatever editor you like that supports omnisharp.

But if you are using VS you will need to update to 15.7 to take advantage of some of the features/

comment 8y ago · link · parent

I've been moving some libraries over from T[] to Memory<T> and Span<T>.

I've found it's a little tricky to get used to calling Slice() all the time. But it opens up so many doors for allocation reduction and perf improvement.

Also, it is so nice to not have to pass (array, offset, length) around everywhere

comment 8y ago · link · parent

This is a landmark release for .NET.

The most important since at least framework 4.0 maybe even 3.0.

We are getting:

- Span<T>/Memory<T> : A 0-copy, unified way of accessing Managed or Unmanaged memory.

- Channel<T> : High performance thread-safe queues (like go channels)

- Pipelines : an async, 0-copy version of Stream

- In-box support for Array/Buffer pooling (finally!) (MemoryPool, ArrayPool)

- Better primitives for pointer manipulation and memory marshaling. (MemoryMarshal)

- New primitives for high performance parsers and formatters (System.Buffers.Binary and System.Buffers.Text)

- Improved support for SSE/NEON via Vector<T>

- Microsoft.Windows.Compatibility : Windows specific APIs on .NET Core (Registry, EventLog, NamedPipes...)

- Tiered Compilation

- Faster tooling

- Wider Platform support

If you write code on .NET, you should [Edit] evaluate this release with to see if it fits your business needs [/Edit]

Doubly so if you care about runtime performance.

1
567
10