Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multiple threads to better spread CPU workload #54

Open
philpem opened this issue Dec 22, 2019 · 5 comments
Open

Use multiple threads to better spread CPU workload #54

philpem opened this issue Dec 22, 2019 · 5 comments

Comments

@philpem
Copy link
Contributor

philpem commented Dec 22, 2019

I've been trying to run HackTV on a Raspberry Pi 4 B+ (4GB RAM).

This setup works fine when showing a test card at an 11MHz or 14MHz sample rate, but when Videocrypt is enabled the Pi can't keep up (HackRF suffers underruns).

It appears that all the processing work is being done in a single thread - one of the Pi's CPU cores is fully saturated while the other three aren't doing anything.

Could HackTV be enhanced to do its processing across multiple threads?

@captainjack64
Copy link
Contributor

ffmpeg decoding is done in a separate thread, though most other things are in a single one.

@fsphil
Copy link
Owner

fsphil commented Dec 23, 2019

The bottleneck I kept hitting on my older machine was memory bandwidth, rather than processing power. I'm not sure multiple threads would help in that case, but it certainly wouldn't harm it. Audio modulation, video modulation, and the FIR filters could potentially be moved into their own threads quite easily.

One potential quick fix for the Pi might be to disable NICAM audio with --nonicam.

@philpem
Copy link
Contributor Author

philpem commented Dec 24, 2019

I did notice that enabling the FIR filter caused underruns on my laptop (which usually handles HackTV quite well) - and that's a reasonably specced machine (Thinkpad X220). So this might have benefits on desktops too.

I'll try without NICAM and see how I get on - is that known to be particularly computationally intensive?

EDIT: Disabling NICAM significantly improved things. The Pi can happily transmit a test card with Videocrypt-1 using the HackRF.

@fsphil
Copy link
Owner

fsphil commented Dec 25, 2019

I don't think NICAM is any more intensive than FM audio, but it's often just enough to push slower machines over the edge.

I believe the main issue for performance at the moment are the Y, U and V level lookup tables. They're very large, and the lookups are often fairly random so difficult for the CPU to predict or cache.

@neo7530
Copy link

neo7530 commented Dec 29, 2019

D2mac fm works quite well up to 20mhz sampling rate on raspi 4. Disabling nicam on pal g works well to. But only with testpattern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants