GithubHelp home page GithubHelp logo

Comments (8)

rogeralsing avatar rogeralsing commented on June 10, 2024 1

Ok, I found the issue, we lacked handling for valuetypes when creating new objects so it fell back onto the FormattingServices.GetEmptyObject.

Still slower than NetSerializer here but I'd say that is expected as we carry more state around.

from wire.

rogeralsing avatar rogeralsing commented on June 10, 2024

Twice as slow might have been over exaggerated, 1.5 times slower is more correct.
400 ms vs 600 ms.

Changing it to a class brings it down to 550, but still significantly slower than NetSerializer.
also, it is only the serialize step that is slower, deserialize is actually faster.

from wire.

Scooletz avatar Scooletz commented on June 10, 2024

Nice finding. Will take a look at it.
Just to be specific:

  • there are 4 virtual calls
  • bit converter calll should look like NoAllocBitConverter.GetBytes(x.field1,buffer)

from wire.

rogeralsing avatar rogeralsing commented on June 10, 2024

4?
The primitives are inlined into the ICompiler pipeline arnt they? EmitWrite.
That leaves just the outer function to write the entire struct, or am I missing something now?

from wire.

Scooletz avatar Scooletz commented on June 10, 2024

4 calls to Stream.Write which is virtual.

from wire.

tomba avatar tomba commented on June 10, 2024

Are there any specific tricks NetSerializer uses in terms of structs?

No, I don't think so (well, there's "direct serialization", but that's not relevant here).

You can actually make NetSerializer emit an assembly dll file containing all the generated code, by doing a debug build and uncommenting the "GenerateDebugAssembly" line in Test/Tester.cs. That assembly can't be used as such, but you can dissassemble it, which I've found a great way to understand issues.

from wire.

rogeralsing avatar rogeralsing commented on June 10, 2024

I've got it down to only differ with some 50ms.
I realized that we do not need to lookup known types while serializing to determine if we need to write manifest or not.
We can simply create an object serializer that never writes the manifest if the type is known when the serializer is generated and register that into our serializer lookup.
This made known type serialization a lot faster.

from wire.

rogeralsing avatar rogeralsing commented on June 10, 2024

Closing this one, the perf is good enough in the current code

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.