Performance benefits of Rust vs C for microsecond-precision serial port I/O, and inter-process communication with Qt

I have a time-sensitive C program that performs serial port I/O with microsecond-level precision. The program currently works well and meets our requirements. I have two questions:

  1. Would there be any significant advantages to rewriting this program in Rust, particularly in terms of performance or reliability for such precise timing operations?
  2. Currently, the program writes the data it reads from the serial port to an ASCII file. A separate Qt application launches this C program and displays the current file size. We now need to modify the system so that the Qt application can also display the contents of the data being read at 1 or 2 seconds periodicity. What would be the most efficient way to implement this inter-process communication between the C program and the Qt application?

Additional context:

  • The target OS is Yocto Linux
  • The C program is responsible for data acquisition from the serial port.
  • The timing requirements are very strict (microsecond level). This means,
  1. The program needs to send commands and read responses at very specific, short intervals (measured in millionths of a second).
  2. It uses high-precision timing functions to measure and control these intervals.
  3. The code tries to maintain consistent timing between operations, adjusting for any delays.
  4. It uses real-time scheduling to ensure the program gets immediate CPU attention when needed.
  • The system needs to remain responsive and efficient.

I'd appreciate insights on both the potential benefits of a Rust rewrite and recommendations for implementing the new IPC requirement with Qt. Thanks in advance!

Do you perform anything significant other than IO in the program? Do you change the logic often or have you had maintenance issues? Is the serial interface a security boundary? Are there any libraries you'd like to use but C makes it difficult?
If none of that applies and it's basically a done thing then I don't see much you'd gain from rewriting in rust.

If your project is generally moving towards Rust then at some point in the future it might make sense just to get more things onto the same language.

I'm not sure you even need explicit IPC here. Just filesystem change notifications (inotify, fanotify) should do the job.

3 Likes

Thanks for your suggestions.

I wouldn't argue for rewriting working software. Rather I'd argue to update your build system (I think yocto is able to do it) so that new development could be made in Rust. For the same reasons as argued by Torvalds: C has inherent issues, finding skilled C developers is hard, Rust sets a minimal requirement bar.

I think the biggest hurdle you'll have is integrating Rust. It can be non trivial in an existing build system.

4 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.