bemasher / rtlamr

An rtl-sdr receiver for Itron ERT compatible smart meters operating in the 900MHz ISM band.
GNU Affero General Public License v3.0
2.19k stars 249 forks source link

rtlamr High CPU usage #187

Closed sprior closed 3 years ago

sprior commented 3 years ago

A friend and I are noticing that rtlamr is taking up 25% of a CPU making it by far the highest load on the machine, which seems like a lot given what it does, memory usage seems fine. I don't know it it's related, but we're both using the unique mode.

I'm not familiar with the Go language, but by any chance is there polling going on instead of blocking on input from rtl_tcp?

bemasher commented 3 years ago

What hardware are you running rtlamr on and which message types are you decoding?

Communication with rtl_tcp is likely not a botte-neck in rtlamr's performance. If you're curious, the goroutine for obtaining samples from rtl_tcp is found here: https://github.com/bemasher/rtlamr/blob/master/main.go#L155-L192

Signal processing in software requires a non-trivial amount of floating point operations. Listening at the highest reliable sample rate on rtl-sdr dongles requires processing 2.4M quadrature samples every second. Determining if a message is present in received samples requires demodulation, filtering, bit-decision, and a preamble search.

At the expense of sensitivity, some of these operations could be reduced by down-sampling, but I have found that rtlamr is efficient enough that this is not necessary.

sprior commented 3 years ago

I'm running rtl_tcp (and nothing else) on a Raspberry Pi 2 and running rtlamr on one virtCPU of an Intel Xeon in a Docker container. But I'm new at SDR so I didn't realize how much of the load was being done on the CPU so I need to adjust my expectations. I thought that rtl_tcp was doing the radio work.

bemasher commented 3 years ago

rtl_tcp is a spectrum server. It provides a control channel for the radio and serves up samples.

sprior commented 3 years ago

That sounds like something you don't necessarily want clogging up your main network.

Nils154 commented 3 years ago

You can run both rtl_tcp and trl_amr on a pi2, but don’t expect it to do anything else.

-- Nils Gokemeijer (Sent from iPhone)

On Apr 16, 2021, at 8:59 PM, sprior @.***> wrote:

 That sounds like something you don't necessarily want clogging up your main network.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

sprior commented 3 years ago

If I can reasonably run rtl_tcp, rtlamr | rtlamr_collect and have it post to Influx on a Pi2 which is running RaspberryOS Lit e(no desktop) then I'd be totally happy.

bemasher commented 3 years ago

I set up a similar configuration for my dad, RPi4 with the raspberry pi release of debian, rtlamr, rtlamr-collect, influxdb, and grafana all on the same pi. Though I would recommend connecting a more durable storage device than the microSD. His setup has a 120GB SSD connected by USB and has influxdb's data files stored there.

sprior commented 3 years ago

Oh the Influx (and Grafana) I was referring to was hosted on another machine. Is it reasonable to run ONLY rtl_tcp, rtlamr | rtlamr_collect on a Pi2 and nothing else? No X server and no data storage on the pi.

Nils154 commented 3 years ago

That worked for me, but I had to specifically request SCM and R900, it would not decode the R900 messages listening to all types.

-- Nils Gokemeijer (Sent from iPhone)

On Apr 16, 2021, at 10:38 PM, sprior @.***> wrote:

 Oh the Influx (and Grafana) I was referring to was hosted on another machine. Is it reasonable to run ONLY rtl_tcp, rtlamr | rtlamr_collect on a Pi2 and nothing else?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

bemasher commented 3 years ago

Be careful with the R900 decoder on pi-based systems, it requires a lot more processing relative to the ERT-flavored messages.

bemasher commented 3 years ago

Oh the Influx (and Grafana) I was referring to was hosted on another machine. Is it reasonable to run ONLY rtl_tcp, rtlamr | rtlamr_collect on a Pi2 and nothing else? No X server and no data storage on the pi.

That is the recommended use-case. My setup is an RPi 3 with rtl_tcp, rtlamr, and rtlamr-collect feeding an influxdb instance on another system. The RPi handles a few other telemetry related services, but otherwise that's it.

sprior commented 3 years ago

Ok great, I have enough info to keep working on this, thanks.