Flecs 3.0 is out!

What is Flecs?

  • Store data for millions of entities in data structures optimized for CPU cache efficiency and composition-first design
  • Find entities for game systems with a high performance query engine that can run in time critical game loops
  • Run code using a multithreaded scheduler that seamlessly combines game systems from reusable modules
  • Builtin support for hierarchies, prefabs and more with entity relationships which speed up game code and reduce boiler plate
  • An ecosystem of tools to profile, visualize, document and debug projects

What happened?

  • Almost a 1000 new commits got added with the repository now having more than 3000 commits in total
  • More than 100 issues and PRs submitted by dozens of community members got closed and merged ❤️
  • The Flecs Discord server almost doubled in size and now has over a 1000 members
  • The number of GitHub stars more than doubled from 1300 to almost 2900
  • The number of test cases grew from 2600 to 4400, with the amount of test code growing from 71K to 130K lines of code
  • There are now 4 community supported and actively developed language bindings for Lua, C#, Zig and Rust

Who is using Flecs?

https://github.com/ConfettiFX/The-Forge

Release Highlights

  • Entity Relationships. While first introduced in v2.4.8, this release is a huge step forward. Relationships in Flecs 3 are faster, more stable, have more features and are easier to use than ever (blog).
  • Flecs Explorer. The Explorer is a brand new Flecs 3 tool for inspecting running apps, profile systems, trying out Flecs features and much more. Click here to try it out.
Features of the Flecs Explorer
  • City Demo. A new demo has been created that showcases many Flecs 3 features and is built with flecs hub modules. The demo runs on all major platforms, including the browser: https://flecs.dev/city.
Screenshot of the city demo
  • Reflection. Flecs 3 comes with an optional reflection addon that is designed from scratch to integrate with scripting languages, other game engines and reflection frameworks like RTTI or Cereal. Reflection data is created at runtime and stored in the ECS using regular entities and components.
  • New Scheduler. Flecs 3 has a new default scheduler that uses a dependency tree to order systems. In addition the pipeline addon now makes it possible for apps to specify a custom systems query, which allows for full customization of which systems get matched by a schedule, and which ordering algorithm to use.
  • Query & Observer Unification. Flecs 3 uses a single query engine for both queries and observers. This means that apps can now use the full expressiveness of Flecs queries when observing events, while being assured that both mechanism match exactly the same entities.
  • New AI Inspired Query Engine. Flecs 3 extends the query engine with an experimental new constraint solver that is inspired by Artificial Intelligence tools like Prolog. The new engine can efficiently match complex patterns across entity relationships, bringing AI technology one step closer to realtime gaming (examples).
  • App Framework. Flecs 3 has a new optional app addon that manages the main loop. This can be used to hide platform specific details about how the main loop is ran, like how a browser takes control of the main loop in webasm apps. Overridable hooks allow modules such as a renderer to inject custom logic (example).
  • Monitoring. A new monitor module tracks metrics from the existing statistics addon over time periods ranging from one second to one week. Metrics are stored in components, and can be inspected with the regular ECS API or with the performance dashboards of Flecs Explorer:
Monitoring metrics in the Flecs Explorer
  • Scene DSL. Flecs 3 has a new text-based format for loading entities and components into the ECS. The format integrates with features like relationships and reflection, and can be used for things like configuration files, scene descriptions and assets (example).
  • Enum Relationships. The C++ API now allows for adding enumeration constants directly to entities. Constants are added as relationships, which makes them queryable. Enumerations do not have to be registered in advance. An example:
enum Color { Red, Green, Blue };// create entity with (Color, Color::Red)
flecs::entity e = world.entity()
.add(Color::Red);
  • New C99 Descriptor APIs. The new C99 descriptor APIs now support a new notation that reduces the amount of boiler plate. The old notation is still supported. An example:
// Old
ecs_filter_t *f = ecs_filter_init(world, &(ecs_filter_desc_t) {
.terms = {{ Npc }, { InRange }}
});
// New
ecs_filter_t *f = ecs_filter(world, {
.terms = {{ Npc }, { InRange }}
});
  • Performance Improvements. Flecs 3 introduces many performance improvements that speed up almost every part of the ECS, like core data structures, the component storage, indices used to accelerate queries, the table graph, search algorithms and API internals.
  • Usability Improvements. Flecs 3 has fewer concepts, a more streamlined API, less confusing naming and more quality of life improvements than previous releases in both the C and C++ APIs.
  • ECS Documentation. Flecs 3 has a new doc addon that makes it possible to annotate entities, components, systems and more with things like descriptions, user friendly names and hyperlinks. These annotations are stored in regular components which can be read by the ECS API and are read by the Flecs explorer to improve visualization:
Doc annotations visualized in the explorer

What’s next?

  • Command Merging. One of the most expensive operations in an archetype ECS is moving entities between tables. The command merging feature combines deferred commands for a single entity into a single archetype move, which can drastically reduce the number of times entities are moved between tables.
  • Pluggable Storages. Not all components benefit from being stored in aligned (SoA) arrays in a table. A new storage interface will make it possible to implement new storage types that are stored outside of tables, which can reduce how often an entity is moved between tables, and reduce the total number of components that need to be moved.
  • Dense/Sparse tables. Currently any id, whether it is a tag or component, fragments tables. This can sometimes lead to unnecessary fragmentation which can hurt performance. A new storage feature will introduce “sparse tables”, which are tables that index into “dense tables”, where dense tables only contain components, not tags. This can greatly decrease table fragmentation, while still allowing for entities with many different component/tag combinations.
  • Reachable Cache. This one is a bit more into the weeds. A new memoization data structure is being designed that can cache the results of relationship graph traversal. Graph traversal is a common operation in many parts of Flecs, which the reachable cache will speed up. This will be especially noticeable in apps that are heavy users of relationships or apps with deep hierarchies.
  • Node API. One of the biggest new features on the roadmap is a new node based API that will make it possible to build node graphs from ECS systems. Flecs 3 laid the groundwork for the node API by unifying iterators across the different kinds of queries and systems.

Big Thanks To

  • @Hexlord
  • @mason-bially
  • @jemc
  • @Metadorius
  • @MewSoul
  • @BlackxSnow
  • @bazhenovc
  • @Sygmei
  • @Jared-Miller
  • @RobertBiehl
  • @photex
  • @BHolman-LBI
  • @Coul33t
  • @tourkit
  • @jtfrson
  • @stickyfingies
  • @ZeroErrors
  • @logankaser
  • @Wesxdz
  • @randy408
  • @LostBoysInteractive
  • @Lexxicon
  • @Zifkan
  • @Nox4041
  • @MatthewOwens
  • @TFlippy
  • @Hexlord
  • @ikrima
  • @silenttowergames
  • @jtferson
  • @wesleysliao
  • @rsms
  • @tcdude
  • @schipdah
  • @Manningham
  • @BlackxSnow
  • @clibequilibrium
  • @ubermenzchen
  • @magmabit
  • @Scaless
  • @photex
  • Everyone that is sponsoring privately!

--

--

Author of Flecs, an Entity Component System for C and C++

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store