This is feature release bringing a lot of small quality of life improvements and support for basic multithreading on ECS level.
First of all, entity name have become a way more convenient to use because they got support for hierarchical lookup:
auto europe = wld.add();
auto slovakia = wld.add();
auto bratislava = wld.add();
wld.child(slovakia, europe);
wld.child(bratislava, slovakia);
wld.name(europe, "europe");
wld.name(slovakia, "slovakia");
wld.name(bratislava, "bratislava");
auto e1 = wld.get("europe.slovakia"); // returns slovakia
auto e2 = wld.get("europe.slovakia.bratislava"); // returns bratislava
Character '.' (dot) is used as a separator. Therefore, dots can not be used inside entity names.
auto e = wld.add();
wld.name(e, "eur.ope"); // invalid name, the naming request is going to be ignored
The main feature of the release is the ability to perform basic multithreading directly from ECS.
The feature is exposed via queries. By default, all queries are handles by the thread that iterates the query. However, it is possible to execute them by multiple threads at once simply by providing the right ecs::QueryExecType parameter.
The user can select what cores are used to execute the query - performance core, efficiency cores or all of them at once are supported.
// Ordinary single-thread query (default)
q.each([](ecs::Iter& iter) { ... });
// Ordinary single-thread query (explicit)
q.each([](ecs::Iter& iter) { ... }, ecs::QueryExecType::Default);
// Multi-thread query, use all available cores
q.each([](ecs::Iter& iter) { ... }, ecs::QueryExecType::Parallel);
// Multi-thread query, use performance cores only
q.each([](ecs::Iter& iter) { ... }, ecs::QueryExecType::ParallelPerf);
// Multi-thread query, use efficiency cores only
q.each([](ecs::Iter& iter) { ... }, ecs::QueryExecType::ParallelEff);
Future releases will add the ability to handle dependencies and more.
Note, performance of ThreadPool has also been greatly increased in this release so throwing a huge amount of tasks at it won't be an issue.
This build also started making a better use of allocators internally. Thanks to that, performance of certain operations became more stable. For example, entity records are allocated using a page allocator now. As a result, no matter how many entities are created, the performance remains stable (linear with the number of entities created). Previously, when the capacity of the original array was about to be exceeded, a larger array had to be created first and the original copied over and released, slowing things down.
Once again, more work is going to be done in this area in future releases.
Release Notes:
Fixed:
- resubmitted jobs didn't respect priority (57b2ef7)
- unnecessary wake up signals when submitting jobs (d0c2a7a)
- make sure all mutex locks are profiled when profiling is enabled (06e2e21)
- notify a worker thread after a job is submitted (06e2e21)
- use GAIA_ALIGNAS instead of alignas (5bd7d06)
- fixed sparse_storage id->page index mapping (5343606)
- incorrect storage types used in various places in sparse set (eb7dfe9)
- incorrect path to MT executables (eeaf2bd)
- proper path escaping in make_single_header.bat (923acd0)
- various sparse set issues (87ddede)
- workaround for issue with order of initialization of global variables in Rougelike example (b3fe1b3)
Added:
- hierarchical entity name lookup (ae00116)
- custom sortFunc for quick sort (981fa08)
- support for basic parallelization of queries (73f4f81)
- systems show their name in the profiler trace now (30744de)
- iterators carry the world pointer now (30744de)
- GAIA_CACHELINE_SIZE for retrieving the cache line size (393d4a7)
- custom storage for ilist (5343606)
- spinlock (f85df62)
- forward linked list fwd_ilist (63fc505)
- proper support for bitset iterators (e8dd857)
- power-of-2 utility functions (6019b90)
Changed:
- USE_SANITIZER renamed to GAIA_USE_SANITIZER (6082dba)
- print cmake project variables (dfd22d0)
- superfluous darray inside chunk allocator replaced with forward linked list (63fc505)
- EntityContainer uses paged storage (00a7409)
- page_storage uses PagedAllocator (d8fd8a6)
Tweaked:
- batch processing cleanup (ea0a26a)
- MT perf exe extended (74acdec)
- one less mutex used by JobManager (99d3f7d)
- less contention when submitting jobs (e10e055)
- ThreadPool efficiency optimizations (9751069, 913ece1, 0d08e45, c78ea9f, e49868f)
- simplified GAIA_PROF_EXTRACT_MUTEX (a6a870e)
- SparseSet minor improvements (5639fab)
- VSCode project dictionary (4645a15)
Full Changelog: v0.8.10...v0.9.0