ElixirConf

ElixirConf

ElixirConf 2023 - Andrew Berrien - ECSx: A New Approach to Game Development in Elixir

ElixirConf: ElixirConf 2023 - Andrew Berrien - ECSx: A New Approach to Game Development in Elixir

Comments welcome! View the elixirconf tag for more ElixirConf talks!

Most Liked

APB9785

APB9785

Creator of ECSx

If anyone has any questions please don’t hesitate to let me know!

APB9785

APB9785

Creator of ECSx

Hi @oldpond ! Yes, of course there is a limit for each app where you will max out your hardware capabilities, but there are a few things in ECSx which can help with this.

First, we’ve kept all data writes and reads in-memory (implemented with ETS) for best performance. With this approach, we get constant-time operations regardless of how large your app’s data layer gets. In my experience, ETS is plenty fast enough, but it’s the complexity of algorithms used in System logic which will bottleneck performance first, so it’s important to optimize this logic as best you can.

Second, the ECSx framework adds very little overhead to its underlying data operations, so the performance should be in-line with existing ETS benchmarks. The main performance concern within ECSx itself, is that Systems are serialized via GenServer (the “Manager”) to avoid race conditions and preserve data integrity per-tick. This means by default, you’re running on a single thread without concurrency. To squeeze the most out of your hardware, it’s important to add concurrency within each individual System, if possible. An example of this would be a System that checks the velocity of each entity and adjusts the position coordinates appropriately. Instead of

  • fetch velocity components
  • for each entity: fetch position component(s), run the mathematical calculation(s), update position

we ideally add concurrency like:

  • fetch velocity components
  • split them into batches
  • spawn an async process/Task for each batch which does the previous step 2
  • System waits for all Tasks to finish before completing

which will ensure all your hardware is being put to use, and should be significantly faster for Systems with expensive logic.

Then there is the ECSx Live Dashboard - this will monitor each System individually, as well as the app’s overall performance, and provide a comparison to the “limit” which would cause slowdown/instability. There is always a hard limit of how much time can be used on computation, because each server “tick” is a set length of time. e.g. a server with tick_rate: 20 will expect to run the System logic 20 times per second, creating a time limit of 50 ms. So if you check the dashboard and see that it takes 45 ms for each tick, you know you’re at the limit, and will need to attempt one of the following before adding more load:

  • Lower the tick_rate setting to allow more time per-tick
  • Further optimize System logic to reduce the time it takes (adding concurrency may be helpful here, as described above)
  • Upgrade the hardware

Hope this helps! If you move forward with ECSx for your use-case, I’d love to hear about it, and happy to answer any further questions you might have.

trnasistor

trnasistor

Very cool!
I will remember to use it if I ever start a personal game project.
Adding first-class support for turn-based mechanics will be very welcomed too. :slight_smile:

Where Next?

Popular in Talks Top

axelson
ElixirConf 2017 - Embedded Elixir for Monitoring the Built Environment - Christopher Coté At CRT Labs (Natio...
New
axelson
ElixirConf 2017 - The Power of Zero - Andrew Forward Automation is hard, but the benefits can be phenomenal....
New
axelson
Almost done with posting the Elixir Conf talks! ElixirConf 2017 - Realtime Vehicle Tracking with Elixir and Phoenix - @st23am ...
New
axelson
ElixirConf US 2018 – Making a GraphQL Server with Absinthe & Dataloader – Aaron Votre (@shamshirz) The ...
New
axelson
ElixirConf 2017 - Building an Open Source, Real Time Forum with Phoenix and Elm - @knewter There’s a lot of ...
New
AstonJ
File uploads are an essential part of many web applications, but often handling them can be tricky, which explains why they are one of th...
New
axelson
ElixirConf US 2018 – We’re Just Getting Started - Our Three Years with Elixir – Maciej Kaszubowski (@mkaszubowski) ...
New
Lawrence_elixir
Tonci Galic - Building a GameBoy emulator with Elixir and Scenic - ElixirConfEU 2019 Tonći Galić - Automating my role, mak...
New
Lawrence_elixir
ElixirConf EU 2019 talk videos ElixirConf EU 2020 - Early bird tickets on sale now! Website: http://www.elixirconf.eu Twitter: www.t...
New
axelson
by @jon At PagerDuty, we run our systems across many geographic regions to ensure we’re always available, even when you might not be. E...
New

Other popular topics Top

Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement