mirror of
https://github.com/sxyazi/yazi.git
synced 2026-05-13 08:16:40 +00:00
perf: make preload tasks discardable (#2875)
This commit is contained in:
parent
aae3f9ea4a
commit
917fee939f
16 changed files with 145 additions and 63 deletions
|
|
@ -122,7 +122,7 @@ impl Watcher {
|
|||
|
||||
async fn fan_out(rx: UnboundedReceiver<Url>) {
|
||||
// TODO: revert this once a new notification is implemented
|
||||
let rx = UnboundedReceiverStream::new(rx).chunks_timeout(1000, Duration::from_millis(350));
|
||||
let rx = UnboundedReceiverStream::new(rx).chunks_timeout(1000, Duration::from_millis(250));
|
||||
pin!(rx);
|
||||
|
||||
while let Some(chunk) = rx.next().await {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ impl Tasks {
|
|||
let mut loaded = self.scheduler.prework.loaded.lock();
|
||||
let mut tasks: [Vec<_>; MAX_PREWORKERS as usize] = Default::default();
|
||||
for f in paged {
|
||||
let hash = f.hash();
|
||||
let hash = f.hash_u64();
|
||||
for g in YAZI.plugin.fetchers(&f.url, mimetype.by_file(f).unwrap_or_default()) {
|
||||
match loaded.get_mut(&hash) {
|
||||
Some(n) if *n & (1 << g.idx) != 0 => continue,
|
||||
|
|
@ -31,7 +31,7 @@ impl Tasks {
|
|||
pub fn preload_paged(&self, paged: &[File], mimetype: &Mimetype) {
|
||||
let mut loaded = self.scheduler.prework.loaded.lock();
|
||||
for f in paged {
|
||||
let hash = f.hash();
|
||||
let hash = f.hash_u64();
|
||||
for p in YAZI.plugin.preloaders(&f.url, mimetype.by_file(f).unwrap_or_default()) {
|
||||
match loaded.get_mut(&hash) {
|
||||
Some(n) if *n & (1 << p.idx) != 0 => continue,
|
||||
|
|
@ -49,7 +49,7 @@ impl Tasks {
|
|||
}
|
||||
|
||||
let targets: Vec<_> = {
|
||||
let loading = self.scheduler.prework.size_loading.read();
|
||||
let loading = self.scheduler.prework.sizing.read();
|
||||
targets
|
||||
.iter()
|
||||
.filter(|f| f.is_dir() && !targets.sizes.contains_key(f.urn()) && !loading.contains(&f.url))
|
||||
|
|
@ -60,7 +60,7 @@ impl Tasks {
|
|||
return;
|
||||
}
|
||||
|
||||
let mut loading = self.scheduler.prework.size_loading.write();
|
||||
let mut loading = self.scheduler.prework.sizing.write();
|
||||
for &target in &targets {
|
||||
loading.insert(target.clone());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue