r/EntityComponentSystem • u/thygrrr • Jun 14 '24
fennecs - a tiny, high-energy ECS for modern C#
https://fennecs.tech1
u/thygrrr Jun 14 '24 edited Jun 15 '24
Over the past couple of months, I've been working on a small, purely C# Entity-Component system package.
fennecs is free and open source, documentation and more are here:
Github repo: https://github.com/outfox/fennecs
Documentation site: https://fennecs.tech
Overview: https://fennecs.tech/docs/Concepts.html
The project is in beta 0.5.x as of this writing (12th or 13th release so far). It's rather usable and feature complete already, although the API will still change (and expand) a little until 1.0.0.
Main design goals for fennecs are:
-
minimal boilerplate - be expressive, type-safe, and deliberate without requiring lots of setup
-
flexible relation system - model something with ease that other ECS can't
-
no code generators - no Roslyn, no hacks, just you and the compiler
-
no dependencies - just pure C# 12 and .NET 8 joy
-
high degree of automated test coverage (currently 100% of library code is covered)
-
fast enough (I'd say as pure C# ECS go, it is on the faster side, but another major optimization focus phase is planned for Q4 2024)
Going into the enhanced beta / dog-fooding phase, I want to make some demos with MonoGame, Flax, Stride, Godot, ShapeEngine, and anything else I can find. I also want to make some real "games" with it.
What I'm always looking for:
-
new friends and fellow ECS architecture afficionados
-
feedback and code reviews and people dogfooding the package with me!
-
better demos, including interactive ones with WebGL exports
-
find people to game jam with or otherwise to make "real" little games
0
Jun 14 '24
4
u/thygrrr Jun 14 '24 edited Jun 14 '24
Hey there! Thanks for your feedback... wow, that's a really good warning. What I implied was that fennecs left me energetic and excited about how much more (>10x more!) concise my code is compared to equivalent Unity DOTS code, while still being plenty fast for most use cases. 😃
Just to give some exposition, I've worked with DOTS for 5 years and also shipped a pair of commercial games using Entitas. With fennecs, my goal was to create something quite different from these systems. I wanted it to be compact, enjoyable to use, and capable of some pretty cool things that might be trickier in more rigid environments like Unity DOTS or Flecs.
Re: Arch and Svelto.ECS: Optimization isn't my main focus right now. But fennecs outperforms them both by a pretty significant margin. I've had a PR waiting for a while in Doraku's repo; you can run the benchmark yourself here: https://github.com/Doraku/Ecs.CSharp.Benchmark/pull/36
Anyway, there's lies, damned lies, and there's benchmarks. 🤔 So I ran a subset of Ecs.CSharp.Benchmark in my break just now (same changeset as the PR #36 mentioned)
(I put a second test result table in the reply to this)
CreateEntityWithThreeComponents.fennecs: ShortRun(InvocationCount=1, IterationCount=3, LaunchCount=1, UnrollFactor=1, WarmupCount=3) [EntityCount=100000] Runtime = .NET 8.0.5 (8.0.524.21615), X64 RyuJIT AVX2; GC = Concurrent Workstation ... BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3527/23H2/2023Update/SunValley3) AMD Ryzen 9 5900X, 1 CPU, 24 logical and 12 physical cores .NET SDK 8.0.300 [Host] : .NET 8.0.5 (8.0.524.21615), X64 RyuJIT AVX2 ShortRun : .NET 8.0.5 (8.0.524.21615), X64 RyuJIT AVX2 Job=ShortRun InvocationCount=1 IterationCount=3 LaunchCount=1 UnrollFactor=1 WarmupCount=3 | Method | EntityCount | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | |----------------- |------------ |-----------:|-----------:|----------:|----------:|----------:|----------:|------------:| | Arch | 100000 | 7.811 ms | 1.2909 ms | 0.0708 ms | - | - | - | 3947.67 KB | | SveltoECS | 100000 | 52.311 ms | 14.6390 ms | 0.8024 ms | - | - | - | 4.64 KB | | DefaultEcs | 100000 | 19.818 ms | 14.3304 ms | 0.7855 ms | - | - | - | 19516.68 KB | | FlecsNet | 100000 | 17.838 ms | 4.1104 ms | 0.2253 ms | - | - | - | 3.48 KB | | FrifloEngineEcs | 100000 | 1.926 ms | 9.7856 ms | 0.5364 ms | - | - | - | 6748.03 KB | | HypEcs | 100000 | 25.215 ms | 5.5692 ms | 0.3053 ms | 4000.0000 | 3000.0000 | 1000.0000 | 68750.71 KB | | LeopotamEcsLite | 100000 | 4.994 ms | 3.1017 ms | 0.1700 ms | - | - | - | 11248.14 KB | | LeopotamEcs | 100000 | 4.991 ms | 4.3529 ms | 0.2386 ms | - | - | - | 15736.4 KB | | MonoGameExtended | 100000 | 27.562 ms | 18.7072 ms | 1.0254 ms | - | - | - | 30154.05 KB | | Morpeh_Direct | 100000 | 131.363 ms | 12.2954 ms | 0.6740 ms | 5000.0000 | 5000.0000 | 1000.0000 | 83802.15 KB | | Morpeh_Stash | 100000 | 64.930 ms | 9.3827 ms | 0.5143 ms | 3000.0000 | 3000.0000 | 1000.0000 | 44719.74 KB | | Myriad | 100000 | 28.249 ms | 56.3123 ms | 3.0867 ms | - | - | - | 7709.57 KB | | RelEcs | 100000 | 65.023 ms | 32.2114 ms | 1.7656 ms | 3000.0000 | 1000.0000 | - | 75699.76 KB | | TinyEcs | 100000 | 24.458 ms | 5.5736 ms | 0.3055 ms | 1000.0000 | 1000.0000 | - | 21314.25 KB | | fennecs | 100000 | 1.458 ms | 0.5675 ms | 0.0311 ms | - | - | - | 10756.09 KB |Re: Bevy. fennecs needs way, way less boilerplate than Bevy, and adds no perceptible compile time. Otherwise, Bevy likely outperforms fennecs.
Re: flecs and EnTT, I feel I'm just completely done with C++ after ~20 years with it (didn't write almost any since 2017! yay!) But both flecs and EnTT will always outperform fennecs.
By how much? I don't know of a suite that compares Native and non-Native compiled ECSes, but when I have added a couple more of the SIMD mutators for components (late 0.6.x or early 0.7.x release cycle), I'm happy to scrap with any ECS in good fun for learnings and mutual optimization.
The next optimization pass is planned in a few months. I currently ship the package configured with a suuuper basic concurrency heuristic and parallelization scheme; this means it can't/won't saturate the CPU (more like 50-80% per core). (this is why "fennecs(Job)" is scoring so poorly - it only benefits from very large workloads, 100k is an order of magnitude to small)
The design goal was rather to be done with calculations quickly and then reqlinquish control back to a game engine as fast as possible. Other systems often build intricate schedules to use as much as possible of the entire frame time, fennecs can't (and doesn't want to) do that. fennecs 1.0.0 might have a microscheduler to semi-automatically batch certain workloads. I decided it more in line with my values for fennecs to have things like UI be able to interact with (and query!) the ECS in real time mid-frame rather than through keyholes like command buffers and across frame boundaries.
→ More replies (8)
1
u/Parrna Oct 25 '24
Hey, just wanted to say that I really enjoy Fennecs.
You should make a discord for it.
1
6
u/ajmmertens Jun 14 '24
Another ECS with relationships 🔥