mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[PR #866] [MERGED] Improve dithering CPU usage #1119
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#1119
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/librespot-org/librespot/pull/866
Author: @roderickvd
Created: 10/18/2021
Status: ✅ Merged
Merged: 10/19/2021
Merged by: @roderickvd
Base:
dev← Head:dither-faster📝 Commits (3)
9ac52baImprove dithering CPU usage12e5b98Improve dithering CPU usage further on 64-bit platforms776b00eImprove dithering CPU usage further on 32-bit platforms📊 Changes
4 files changed (+40 additions, -12 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
Cargo.lock(+12 -2)📝
playback/Cargo.toml(+1 -0)📝
playback/src/dither.rs(+26 -10)📄 Description
This little PR shaves off about 33% CPU usage when dithering, while the effects on the binary size are next to none. This is true both on my Raspberry Pi 3B+ (from about 15 to 10% CPU) and my Mac (from 3 to 1%).
The trick is taking cue from
SmallRnginstead ofThreadRng, then sprinkling some 64-bit optimisations on top by hand-picking the fastest generator that still has high enough linear complexity for 64-bit floats.While at it, bump the
rand_distrcrate, even though it doesn't contribute to the speed-up.Unless there are any objections, I intend to merge this before releasing
0.3.1.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.