Skip to content

Possible optimizations #57

Description

@anonymous-one

Sigh

It is what it is:

Since I've been running rtl_wmbus for a good 5+ years now, 24/7... I thought I would run it through one of the LLMs.

TBH, I don't know nearly enough about this project to tell if any of this is warranted... What I do know is that after applying these changes as well as the ones it recommended for rtl_sdr... My load average dropped, and I continue to recieve what appear to be valid datagrams from both my power meter as well as my water meters.

I am just pasting this for reference, maybe its garbage, maybe not...

Key Changes Made:

FIR Filter (fir.h):
Rewrote using circular buffer pattern with better loop structure for auto-vectorization.
Added restrict keywords and always_inline hints.

IIR Filter (iir.h):
Optimized to use local register variables, reducing memory accesses in the hot path.

Moving Average Filter (moving_average_filter.h):
Created specialized mavgi8() and mavgi16() functions for the fixed 8-tap and 16-tap cases
Uses power-of-2 bitwise AND for index wrapping instead of modulo
Uses multiplication by reciprocal (0.125, 0.0625) instead of division

Fast Magnitude Approximation:
Replaced sqrtf(i*i + q*q) with max(|i|,|q|) + 0.4*min(|i|,|q|) for RSSI calculation (~3% error, much faster)

Memory Alignment:
Added 32/64-byte alignment hints for filter histories to enable SIMD

Branch Prediction Hints:
Added __builtin_expect() on unlikely branches (buffer wraparound, error conditions)

LTO (Link-Time Optimization):
Enabled in Makefile for cross-function optimization

Larger I/O Buffer:
Increased from 4KB to 8KB for better I/O efficiency

Compiler Flags:
Added -ffast-math -funroll-loops -ftree-vectorize -fomit-frame-pointer

These are the changes it made to rtl_sdr:

Image

Feel free to flame away, heck, I would ;P

Opus 4.5 BTW.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions