RevenantX / LiteNetLib

Lite reliable UDP library for Mono and .NET
https://revenantx.github.io/LiteNetLib/index.html
MIT License
3k stars 489 forks source link

ECS, Jobs, and Unity 2018 #185

Closed NVentimiglia closed 5 years ago

NVentimiglia commented 6 years ago

I was going over the Unity GDC materials on the new unity architecture. Specifically the jobs and entity-component systems. I like the new struct based system and think any future systems need to utilize them, this includes networking. That said, do you plan to incorporate ECS into LiteNet ?

Some additional thoughts

this is a bunch of work, let me know your thoughts.

RevenantX commented 6 years ago

That said, do you plan to incorporate ECS into LiteNet ? NativeCollections replaces DNC slices and byte arrays. NetDataWritter and Reader should be a struct using the native collection.

No. LiteNetLib is multiframework transport library without unity3d specific code.

Unity.Collections contains a concurrent que

This is not bottleneck of library. For now library is fast enough without this. Concurrent queue can give more speed if you use it in many threads. (but in library with ipv6 enabled only 3 threads)

NVentimiglia commented 6 years ago

I would disagree that it is a bottleneck. If we have many threads reading, for instance. This is something that will be happening, more and more.

Moreover, It looks like Unity.Collections and NativeContainers can be added into the library in an agnostic way because they are utilities that do not touch the engine. Something that can maintain the cross-platform greatness of this library.

Perhaps this is something I can add ontop of litnet by turning off thread safty mode.

Raised the issue on the official forums. https://forum.unity.com/threads/unity-collections-nativecontainers-and-dotnetstandard-dotnetcore.528999/

RevenantX commented 6 years ago

@NVentimiglia you can try replace Queue to ConcurrentQueue and check performance using some benchmarks (Benchmark.NET for example). If it drastically increase performance then I'll probably add them as option.

boonkerz commented 5 years ago

it should be independently from unity because it's used for other projects as well

MichalPetryka commented 5 years ago

What about scripting defines which would enable unity only code?

miketheprogrammer commented 5 years ago

Unity will be releasing their own networking library for use with ECS. I recommend letting that be the ECS networking library. The library will be open source, and can be improved with techniques from LiteNetLib. However this library should not change for ECS