Skip to content

Conversation

@kernelkind
Copy link
Member

@kernelkind kernelkind commented Nov 23, 2025

Previously, for each media loading request (for both on disk and from net) needed a separate std::sync::thread. With many requests, this can cause alot of overhead. This PR makes it so all media loading requests go through the JobPool, and it is made easy to run combinations of synchronous and async jobs chained together for a single request.
Additionally, apps can make their own job types which aren't tied to the media loading types by making a new JobCache<K,T> and passing the type as K and job output as T. The JobCache supports pre action and completion closures, so the UI code touching the caching related structs can be immutable.

Performance

On slow internet connections, performance compared to master is about the same. On fast internet connections, it is much improved. The following trace screenshots are recorded from a fresh install on a Pixel 2

General

This trace == this PR
external == master
Pasted image 20251120201322

  • master has sd of ~23ms and this PR has sd ~9ms. much less standard deviation, more stable. additionally, this PR has a mean time 1.35 ms less than master, and a median time per frame of 2.06 ms less than master.

wgpu_integration::WgpuWinitRunning::run_ui_and_paint

Pasted image 20251123112318

Not sure why, but this method took much less time on this PR than master, and had a massive decrease in SD from 28.7 ms to 3.74 ms.

Device::create_texture

Pasted image 20251123112348

On average 3.1 ms less per frame than master. The SD on master was 42 ms, now it is 5.56 ms

Note: take these figures with a grain of salt, we need a much more robust testing framework for repeatable results...

Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
necessary for mpmc

Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
so I can make smaller commits for the jobs refactor

Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
- able to run sync & async jobs, where async jobs just utilize the tokio
  async thread pool.
- able to string together an arbitrary amount of sync & async calls back
  to back via a single nested closure
- arbitrary preactions & payload delivery possible via closures
- can use which ever job types necessary for app, since it uses generics
  for the output payload

Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: kernelkind <kernelkind@gmail.com>
@kernelkind kernelkind requested a review from jb55 November 23, 2025 18:27
@jb55 jb55 merged commit fd7238b into damus-io:master Dec 4, 2025
9 checks passed
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

Successfully merging this pull request may close these issues.

2 participants