Susumu Yamazaki

Susumu Yamazaki

ZACKY at Univ. of Kitakyushu, Japan.

Susumu Yamazaki (ZACKY) is currently an Associate Professor at the University of Kitakyushu. One of his current research interests focuses on system and social implementation using Elixir, Phoenix, Nerves and Nx. He is a co-founder and creator of Pelemay series, and satellite image processing systems with Elixir.

How to Describe Robust NIFs: : Bridging Elixir and C with Performance for Fault-tolerant Systems

When implementing a system that requires performance, we sometimes use NIFs, a mechanism for calling higher-performance C code from Elixir. NIFs perform better than Port, another mechanism to call C. However, they have the disadvantage that if they crash, the entire Erlang VM will be abnormally terminated, even under Supervisor’s control. This defect is a significant obstacle when building fault-tolerant systems.

This talk shows three points to describe robust NIFs:

  1. Appropriately set a conditional branch where each function call may return an uncertain value.
  2. Perform error handling according to general conventions.
  3. Make assertions that specify implicit preconditions and raise exceptions for Supervisor to handle. This talk also shows how to improve performance even with such robustness and fault tolerance and build NIFs for various platforms.

Talk objectives:

  • Present that NIFs are mechanisms for calling higher-performance C code from Elixir.
  • Also, present that though Supervisor realizes fault tolerance, ordinal NIFs hinder it.
  • Provide three tips on enabling Supervisor to achieve fault tolerance even with NIFs.

Target audience:

  • Anyone who has interested in how to describe NIFs with fault-tolerance.