Julia for real time, worried about the garbage collector

Just want to contribute some things to this wonderful discussion. I am new to Julia, but I come from the field of practice, and research about (hard) real-time systems and stumbled upon this thread randomly.

A hard-real time system is a system that performs every task within a strict given time frame, and I/O is serviced strictly within a small time window, not earlier, not later. Now, what you are proposing here is merely the setup for a real-time system. What you lack is guarantees in the form of formal proofs, that the execution of the algorithms and programs will respect the hard deadlines. You can’t provide these guarantees, especially on a Linux machine that runs on a multiprocessor system with shared memory and caches (pretty much every modern general purpose PC). What I mean is, even if you isolate the execution of an algo to the CPU, it is still not isolated, since it still uses a shared memory, which means any time the other cores access that memory, your CPU may be stalled. Cache coherency and collision is another issue that can stall your CPU execution for a nondeterministic amount of time. These are things that you have NO control over, unless you design your entire stack from the ground up to be hard deadline aware (read deterministic, which is very hard). That you have some empirical evidence to support some “real-time” performance on your setup is absolutely irrelevant.

To guarantee your system is hard real-time compliant, one usually needs to:

  1. Formally verify the correctness of the program
  2. Ensure that each task satisfies the given deadlines – i.e. use static scheduling
  3. Eliminate ANY task communication interference
  4. Analyze and fix a deterministic flow of data

That is something that is handled at the very bottom of the stack (read drivers and custom hardware). Entire hardware architectures are built just for this purpose, as well as RTOS kernels. Julia is way up the layers of the stack, with little to no control over these aspects. And that’s okay, because as far as I see, it addresses a completely different market. Furthermore, its not up to the language and its infrastructure that should address this issue, it is up to the designer. The language and its infrastructure should only provide the tools and capability to design the real-time system. Julia, unfortunately, does not provide these tools.

11 Likes