Skip to content

System Developing Essentials

Misc Advice

Tools

  • Stack and Register Dumper
  • NMI and software Watchdog
  • Tracepoint and Ring Buffer
  • Profilers
  • Counters
  • Whiskey and Luck

Keep in mind

  • Stress your system
    • Every single critical subsystem
    • Confident with your base subsystem
    • Fix bug/Improve perf at early stage
  • Plan ahead
    • Single thread, or thread pool?
    • How to avoid using lock?
    • What lock to use?
    • How to reduce lock contention?
    • Does this data structure need reference counter?
    • Should I use per-cpu data structures?
    • Should I pad this lock $-line aligned to avoid pingpong?
  • Decent Cleanup

    • I’m fucking hate a crap kernel module just kill my machine, either stuck or bug.
    • Free buffer/structure
    • Remove the pointer from friends’ list/tree. If you forgot to do so, mostly you will have some silent memory corruption. So be kind, cleanup what you have done during intilization.
    • Report error. Do not be SILENT.
  • Clever Buffer Management

    • kmem_cache?
    • static pre-allocated array?
    • Ring buffer?
    • Other than kmem_cache, I used other two solutions to optimize various dynamic allocation in LegoOS. The motivation is very simple: some data structures will be allocated/free very very frequently at runtime. So we want to speed it up!

System Building Advice

  • John Ousterhout
    • If you don’t know what the problem was, you haven’t fixed it
    • If it hasn’t been used, it doesn’t work