Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

... the little C# ECS that loves you back!

License

NotificationsYou must be signed in to change notification settings

outfox/fennecs

Repository files navigation

fennecs logofennecs logo

... the tiny, tiny, high-energy Entity-Component System!

dotnet add package fennecs
to use the beta versions, append--prerelease

a box of fennecs, 8-color pixel art

Okay, what the fox!
Another ECS?!

We know... oh,we know. 😩

But in a nutshell,fennecs is...

🐾 zero codegen
🐾 minimal boilerplate
🐾 archetype-based
🐾 intuitively relational
🐾 lithe and fast

DiscordNugetDownloadsGitHub Actions Workflow StatusOpen Bugs

Quickstart

Brand new? Try thecookbook for a quick & tasty intro, ordive into the docs!
Familiar with ECS architectures? Get anoverview of new & unique concepts!

At the basic level, all you need is a 🧩component type, a number ofsmall foxes 🦊entities, and a query to ⚙️iterate and modify components, occasionally passing in some uniform 💾data.

// Declare a component record. (we can also use most existing value & reference types)recordstructVelocity(Vector3Value);// Create a world. (fyi, World implements IDisposable)varworld=newfennecs.World();// Spawn an entity into the world with a choice of components. (or add/remove them later)varentity=world.Spawn().Add<Velocity>();// Queries are cached & we use ultra-lightweight Stream Views to feed data to our code!varstream=world.Query<Velocity>().Stream();// Run code on all entities in the query. (exchange 'For' with 'Job' for parallel processing)stream.For(uniform:DeltaTime*9.81f*Vector3.UnitZ,action:(Vector3uniform,refVelocityvelocity)=>{velocity.Value-=uniform;});

💢... when we said minimal boilerplate,we meant it.

By any measure, we're talking just a couple of lines to get this gravity feature up and running. Creating the world and query is the only setup – the real slam dunk is how cleanly we built the full actor/gravity logic with barely any ceremonial code in sight.

And there's more: all that simplicity doesn't force any performance trade-offs! You get to have your cake and eat it too with zero confusion or fluff!


💡Highlights / Design Goals

  • Modern C# 12 codebase, targeting .NET 8.
  • Full Unit Test coverage.
  • Powerfully intuitive ways to access data...fast!
  • Workloads can be easily parallelized acrossand within Archetypes
  • Expressive, queryable relations among Entities themselves & between Entities and Objects
  • No code generation and no reflection required.

📕 DOCUMENTATION:fennecs.tech (official website)

Grab a cup of coffee toget started, trythe Cookbook, viewthe Demos , and more!
coffee cup


⏩ Nimble:fennecs benchmarks

Preliminary (WIP) benchmarks suggest you can expect to process over 2 million components per millisecond on a 2020 CPU without even customizing your logic.

Using Doraku's syntheticEcs.CSharp.Benchmark, fennecs scores among the faster ECS in the benchmark suite.
(link goes to PR #36 to reproduce)

Warning

These are synthetic benchmarks, using aBETA BUILD offennecs. Real-world performance will vary wildly.If you need a production-ready ECStoday, 9 out of 10 foxes endorseFriflo.Engine.ECS👍 andFlecs.NET👍

Another optimization pass forfennecs ison the Roadmap.

Benchmark: CreateEntityWithThreeComponents

// Benchmark Process Environment Information:// BenchmarkDotNet v0.13.12// Runtime=.NET 8.0.5 (8.0.524.21615), X64 RyuJIT AVX2// GC=Concurrent Workstation// HardwareIntrinsics=AVX2,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256// Job: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)// [EntityCount=100_000]
ECS & MethodDuration
(less=better)
🦊 fennecs1.458 ms
FrifloEngineEcs1.926 ms
LeopotamEcs4.991 ms
LeopotamEcsLite4.994 ms
Arch7.811 ms
FlecsNet17.838 ms
DefaultEcs19.818 ms
TinyEcs24.458 ms
HypEcs25.215 ms
MonoGameExtended27.562 ms
Myriad28.249 ms
SveltoECS52.311 ms
Morpeh_Stash64.930 ms
RelEcs65.023 ms
Morpeh_Direct131.363 ms

Benchmark: SystemWithThreeComponents

// Benchmark Process Environment Information:// BenchmarkDotNet v0.13.12// Runtime=.NET 8.0.5 (8.0.524.21615), X64 RyuJIT AVX2// GC=Concurrent Workstation// HardwareIntrinsics=AVX2,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256// Job: ShortRun(IterationCount=3, LaunchCount=1, WarmupCount=3)// [EntityCount=100_000, EntityPadding=10]
ECS & MethodDuration
(less=better)
Comment
🦊 fennecs(AVX2)10.43 µsoptimized Stream<>.Raw using AVX2 Intrinsics
🦊 fennecs(SSE2)11.41 µsoptimized Stream<>.Raw using SSE2 Intrinsics
FrifloEngineEcs_MultiThread13.45 µs
FrifloEngineEcs_SIMD_MonoThread16.92 µs
TinyEcs_EachJob20.51 µs
Myriad_MultiThreadChunk20.73 µs
TinyEcs_Each40.84 µs
FrifloEngineEcs_MonoThread43.41 µs
HypEcs_MonoThread43.86 µs
🦊 fennecs(Raw)46.36 µsstraightforward loop over Stream<>.Raw
HypEcs_MultiThread46.80 µs
Myriad_SingleThreadChunk48.56 µs
Arch_MonoThread51.08 µs
Myriad_SingleThread55.65 µs
🦊 fennecs(For)56.32 µsyour typical bread & butterfennecs workload
Arch_MultiThread59.84 µs
FlecsNet_Iter77.47 µs
🦊 fennecs(Job)97.70 µsunoptimized in beta, ineffective <1M entities
DefaultEcs_MultiThread102.37 µs
Myriad_Delegate109.31 µs
Arch_MonoThread_SourceGenerated134.12 µs
DefaultEcs_MonoThread142.35 µs
LeopotamEcs181.76 µs
FlecsNet_Each212.61 µs
LeopotamEcsLite230.50 µs
Myriad_Enumerable245.76 µs
RelEcs250.93 µs
SveltoECS322.30 µsEntityPadding=0, skips benchmark with 10
MonoGameExtended387.12 µs
Morpeh_Stash992.62 µs
Myriad_MultiThread1115.44 µs
Morpeh_Direct2465.25 µs

🥊 Comparisons: Punching above our weight?

So how doesfennecs compare to other ECSs?

This library is a tiny, tiny ECS with a focus on good performance and great simplicity. But itcares enough to provide a few things you might not expect.

Important

The idea offennecs was to fill the gaps that the author felt working with various established Entity-Component Systems. This is why this matrix is clearly imbalanced, it's a shopping list of things thatfennecs does well and was made to dowell; and things it may aspire to do but compromised on in order to be able to achieve the others.

(TL;DR - Foxes are soft, choices are hard - Unity dumb, .NET 8 really sharp.)

🥇🥈🥉 (click to expand) ECS Comparison Matrix

Here are some of the key properties wherefennecs might be a better or worse choice than its peers. Our resident fennecs have worked with all of these ECSs, and we're happy to answer any questions you might have.

fennecsHypEcsEntitasUnity DOTSDefaultECS
Boilerplate-to-Feature Ratio3-to-15-to-112-to-127-to-1 😱7-to-1
Entity-Component Queries
Entity-Entity Relations
(Map/MultiMap)
Entity-Object-Relations🟨
(System.Type only)
Target Querying
(find all targets of specific relations)
Wildcard Semantics
(match multiple relations in 1 query)
Journaling🟨
Shared Components
(ref types only)
🟨
(restrictive)
Mutable Shared Components
Reference Component Types
Arbitrary Component Types
(value types only)
Structural Change Events🟨
(planned)
☠️
(unreliable)
Workload Scheduling
(highly static)
No Code Generation Required🟨
(roslyn addon)
Enqueue Structural Changes at Any Time🟨
(restrictive)
🟨
Apply Structural Changes at Any Time
Parallel Processing⭐⭐⭐⭐⭐⭐⭐
Singleton / Unique Components🟨
(ref types only)
🟨
(per system)

🧡 Acknowledgements

Many thanks toByteron (Aaron Winter) for creatingHypEcs andRelEcs, the inspiring libraries thatfennecs evolved from.

Neofox was created byVolpeon and is in the Creative CommonsCC BY-NC-SA 4.0, the same license applies to all Neofox-derived works made for this documentation.


[8]ページ先頭

©2009-2025 Movatter.jp