GithubHelp home page GithubHelp logo

Compiler abstraction about wire HOT 9 CLOSED

asynkron avatar asynkron commented on June 10, 2024
Compiler abstraction

from wire.

Comments (9)

rogeralsing avatar rogeralsing commented on June 10, 2024 1

btw. offtopic but still related :-)
AFAIK NetSerializer is the fastest binary serializer in the world for .NET.
Using the POCO class in the perf test, Wire actually out performs it, and all the other serializers too.

Results change if the serialized object is smaller though.

from wire.

rogeralsing avatar rogeralsing commented on June 10, 2024

Any feedback on how we can improve this is welcome.

One thing that I am not sure how to solve is the concept of "Constant" in expressions, where you can bind an expression to an already existing object.
How would one go about to make the generated IL code get access to the external object?
it needs to be stored somewhere so the IL code can get to it I suppose.

from wire.

rogeralsing avatar rogeralsing commented on June 10, 2024

Related to #42

from wire.

rogeralsing avatar rogeralsing commented on June 10, 2024

cc @Scooletz I am working on an IL implementation of the ICompiler abstraction.
it can emit methods and some code already. but far from complete.
please have a look and see
https://github.com/akkadotnet/Wire/blob/dev/Wire/Compilation/IlExpression.cs
https://github.com/akkadotnet/Wire/blob/dev/Wire/Compilation/IlCompiler.cs
https://github.com/akkadotnet/Wire/blob/dev/Wire.Tests/IlCompilerTests.cs

Do you think this is something we can work with? at least as a start to get going?

I'm hesitant to bring in Sigil as that will bring more dependencies. I would like to stay clean and lightweight. and the code we need to generate is not that complex.

from wire.

Scooletz avatar Scooletz commented on June 10, 2024

I took a quick look. It looks promising and yes, I wouldn't bring in Sigil. I was referring to it only as a good approach towards emitting. Another one would be the EmitContext from protobuf-net. Your proposal looks very good as well.
I'm taking a few days off but will try to catch up either today in the evening (GMT+2) or tomorrow (evening as well).

from wire.

rogeralsing avatar rogeralsing commented on June 10, 2024

IlCompiler is now complete enough that it can compile the _read and _write in the session aware/unaware serializers.

it still causes "destabilize runtime" if used on the read and write generators in DefaultCodeGenerator.
I guess there is some issue with boxing/unboxing.

from wire.

Scooletz avatar Scooletz commented on June 10, 2024

I've got a few questions after reading the code more carefully:

  1. Is IlCompiler<Del> is meant to replace Compiler<Del> at the end?
  2. Does is suffer from the "destabilize runtime" still? Tests on dev are all green.
  3. Have you checked if the static calls for the primitive value serializered are inlined? If not, I'll check it with BenchmarkDotNet. It seems to me that it's the last thing we could improve for primitive serializers.

from wire.

rogeralsing avatar rogeralsing commented on June 10, 2024
  1. That was the idea, but I'm not sure if the effort is worth it (?)
  2. There seems to be some strangeness still going on, it actually makes the testrunner stop before all tests are done. not sure exactly what makes it blow up yet. (when using the IlCompiler instead of Combiler inside DefaultCodeGenerator)
  3. I'm not sure how to check that they are inlined as inlining only affects the Jitter (afaik). adding aggressive inlining to the the static methods seems to do nothing for the perf.

If the inlining does not occur, I think it would be possible to do it in the Emit phase, right?

from wire.

Scooletz avatar Scooletz commented on June 10, 2024

I'm mostly offline this week but will take a look next week and try to finalize this approach. I think that JIL optimization, ordering properties by type to get a better memory alignment could bump up the perf again.

from wire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.