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 - Well Behaved Native Implemented Functions for Elixir - @potatosalad Native Implemented Fun...
New
axelson
ElixirConf 2017 - Building Realtime Mobile Apps with React Native and Elixir - Osayame Gaius Obaseki Buildin...
New
axelson
ElixirConf US 2018 – Texas: Virtual DOM Library for Server-Side V-DOM. – Dan McGuire (@dgmcguire) Client-side applicatio...
New
ElixirConf
ElixirConf: ElixirConf 2023 - Charlie Holtz - Building AI Apps with Elixir Comments welcome! View the <span class="hashtag-icon-placehol...
New
axelson
by @takasehideki Can you imagine that your Elixir code will be executed as a hardware circuit on an FPGA? The FPGA (Field-Programmable...
New
axelson
Hey folks, beginning to post today’s round of ElixirConf videos! ElixirConf US 2018 – Elixir at a Walking Pace – Lance Halvorsen (@lance...
New
Lawrence_elixir
@voltone - Security advocate, BEAM enthusiast Learn you some ‘ssl’ for much security! Talk in three words: TLS, security, troubleshooti...
New
axelson
ElixirConf 2017 - Live APIs with GraphQL Subscriptions - @bruce and @benwilson512 APIs have gone live with G...
New
axelson
Consistent, Distributed Elixir - @keathley Elixir and Erlang provide powerful mechanisms for building systems that are alw...
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

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement