Performance optimization techniques in C code

Jyothi
1 min readMar 5, 2024

--

Some general rules to optimize the C code:

  • Profile your code and focus on time-consuming code segments
  • Use -O2, -O3 compiler optimization macros. Sometimes you should be careful while these macros. One example is HW modifying some variables and s/w uses these variables which compiler may not be aware of it. If we use proper qualifiers like volatile , there may not be issues
  • loop optimizations , memory optimizations, inline functions, reduce function calls, pre-fetch operations, cache optimizations
  • Avoid global variables, optimize I/O operations, use right data types, avoid redundant code

Apart from these general optimizations, we did some kind of research while implementing data path functionalities. Some of this research is published as below patents:

Some part of this research is published as defensive publications at IP.com:

  • Implementation of SDN cumulative actions
  • Support for multiple keys in table lookup engine, enhancing efficiency and versatility

--

--

No responses yet