Search Results
6/29/2025, 6:07:52 PM
>>105724992
>What are you working on?
a network filesystem in C (using libFUSE).
I've only discovered Linux `perf` profiler today, but it already taught me a lot about performance.
I assumed the overhead of my program would be miniscule compared to hitting the disks and the network, turns out i was wrong.
Some lessons i've learned:
1. memset is expensive. Don't zero out structs and arrays if not necessary.
2. ifs are expensive. For logging, don't check the loglevel inside the logging function. Instead, use a function pointer for each loglevel, pointing either to the logging function, or an empty function if that loglevel is disabled. (maybe there's an even better way without the function call overhead?)
3. when (de)serializing data, don't do it field-by-field by advancing a pointer. Instead, (de)serialize by using offsets from the pointer, the compiler will then generate fast SIMD code for these paths.
Profile your code anons!
>What are you working on?
a network filesystem in C (using libFUSE).
I've only discovered Linux `perf` profiler today, but it already taught me a lot about performance.
I assumed the overhead of my program would be miniscule compared to hitting the disks and the network, turns out i was wrong.
Some lessons i've learned:
1. memset is expensive. Don't zero out structs and arrays if not necessary.
2. ifs are expensive. For logging, don't check the loglevel inside the logging function. Instead, use a function pointer for each loglevel, pointing either to the logging function, or an empty function if that loglevel is disabled. (maybe there's an even better way without the function call overhead?)
3. when (de)serializing data, don't do it field-by-field by advancing a pointer. Instead, (de)serialize by using offsets from the pointer, the compiler will then generate fast SIMD code for these paths.
Profile your code anons!
Page 1