Fasjeit / DiscoNet

.Net core implementation of libdisco

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimization

Fasjeit opened this issue · comments

Here is some ideas for optimization:

  • Optimize TCP connetion, implement streaming api #5
  • Use 12 rounds in keccak instead of 24 (see keccak-f[400, kangarootwelve])
  • Use native Strobe implementation, create wrapper

Rewrite all byte logic with spans. (or pipes?)
Rewrite keccak-f with intrinsics.

Can you leverage XKCP? They have implementations of keccak-f with intrinsics.

I'll definitely take a look.

The possible idea is not to use wrapper around native (c or asm) implementation, but to use intrinsics inside managed (c# code). Using wrapper can cause a little bit more time consumption for every native call, but using intrinsics tells the compiler just used the specified assembly code.

Example link for me - sha256

Spans\pipes have more priority, as using these allow to use stack instead of heap for all transformations and get rid of all GC time waste.

Links to read - 1, 2

Pipes and TCP

spans and readonly

General plan is:

  • Create Pipe methods using sync Strobe - how to return message?
  • Create async Strobe api consuming PipeReader. Inside is just readAsync Pipe method.
  • Create WritePipe method in Disco using Strobe Async Api
  • Deal with buffer size in Pipe methods

Looks like C# 8.0 have the exactly feature we need - yield async.
Unfortunately it is available only in preview version of VS 2019, and it;s quite buggy, at least until preview 2. Proposed fix works, but I still get other errors during FlushAsync in pipeWriter. Not sure is this the same problem of not.

link

Now I have to just wait until preview 2 and try again.

Current changes are in pipleline branch.

Also we have to switch to .net core 3.0. Looks like both travis and appveyor does not support it right now.