Repository navigation
perf(clipboard): reconcile cut lists in linear time after moves - #2634
Conversation
Finishing a move compared every cut location with every moved location through locations_equal, which builds and canonicalizes two GFiles per non-identical pair. ViewState::complete_cut_transfer alone took 5 s for 5,000 files, 26 s for 10,000 and 464 s for 50,000, on the main thread after the transfer itself had finished. Match through a LocationSet instead: exact Location lookups first, then one GFile per location bucketed by URI and confirmed with GFile::equal, so GIO equivalence (native path vs file:// URI) is unchanged. same_locations, used when a paste compares the clipboard with the shared cut, uses the same bucketing for its multiset fallback instead of a nested scan. complete_cut_transfer now takes 0.02 s for 50,000 files.
A copy into an open folder runs as a background operation, which stops deferring monitor changes, so every copied file was applied on its own: two scans of the column, a hidden-name pass over every entry and a UI splice per file. Copying 10,000 files took 45-55 s with the window frozen for up to 21 s at a time. Monitor changes still apply one at a time while their columns' sizes within one burst stay under 100,000 entries. Past that, the rest of the burst queues in order and publishes every 100 ms through the batch path that file operations already use, until an interval passes quietly. Changes applied directly, such as staged load deltas, stay synchronous unless a batch is pending ahead of them. A starting operation publishes the queue before it clears it.
Two things differed once a burst of monitor changes went through the batch path instead of applying one at a time. A rescan queued behind the burst was stripped by the operation batch path, which holds rescans until a file operation ends, so the column was never reloaded. A rescan now publishes the queued burst and reloads its column at once, as it does outside a burst. Every batch reported the cursor, as batches deferred by a file operation do, so each 100 ms flush scrolled the listing back to the cursor and gave it keyboard focus while files kept arriving. A live batch now reports the cursor only when it removes the cursor's entry or the column has none, like a single live change. Change handling is split into smaller steps so the file's code health does not drop.
Review and cleanupMerged Review against the description. There is no linked issue and there were no review comments or threads to reconcile.
Fixes pushed in
Tests. None removed: the PR's tests each guard distinct behaviour (GIO-equivalent multiset matching, the 20,000-entry reconcile, burst ordering, an operation starting mid-burst). Added to
Manual check (private QA container,
Validation
Notes for the author and owner
CI: the fork's run needed approval; approved, and all checks are green on |
The 100 ms flush timer from lgse#2634 stayed attached to the default main context after its browser was dropped. Its closure is bound to the thread that created it, so the next test thread that iterated the context fired it and glib's thread guard aborted the test binary. This failed Rust tests shard 0 in the local_departures monitor test on unrelated pull requests. Refs lgse#2710
* feat(preview): play animated WebP previews Animated WebP files showed only their first frame because every WebP went to the still-image decoder. A local WebP whose header declares an animation now plays in the media sandbox, like a GIF, when the runtime FFmpeg has the webp_anim decoder (9.0 or newer, asked once per process). With an older FFmpeg it keeps the still preview. FFmpeg's animated WebP demuxer reports no duration and cannot seek, so -stream_loop stalls and -ss skips to the end. The period comes from the container's frame durations instead, short animations loop with the loop filter ahead of the 30 fps conversion within a 256 MiB frame budget, and offsets are reached by decoding and trimming. Refs #2710 * fix(preview): keep the animated WebP loop budget from overflowing The frame budget multiplied the frame count by a canvas size read from an untrusted header. A 16,384-frame file declaring a 16,777,216 pixel square canvas wraps to zero bytes, which panics a debug build and passes the budget in a release build. Refs #2710 * refactor(preview): clear code-health findings in animated WebP playback Split the RIFF walk into header and chunk readers, name the software-only, animation and demuxer-loop conditions, pass the probe request as a struct, move the WebP routing out of classify, and share one long-animation assertion between the GIF and WebP playback tests. No behaviour changes. Refs #2710 * docs(preview): drop comments that restate animated WebP tests Refs #2710 * fix(browser): remove the live-change flush timer when the browser drops The 100 ms flush timer from #2634 stayed attached to the default main context after its browser was dropped. Its closure is bound to the thread that created it, so the next test thread that iterated the context fired it and glib's thread guard aborted the test binary. This failed Rust tests shard 0 in the local_departures monitor test on unrelated pull requests. Refs #2710 --------- Co-authored-by: Pierre Berube <[email protected]>
Description
Feel free to do any other implementation as mine might not be good, but needed something working so might as well share here.
Currently large cut+paste operations can freeze whole apps for minutes, like my last cut of 50k files took over 9 minutes...
This is mostly caused by the
retain_untransferredmethod used in thecomplete_cut_transferthat does some very unoptimized quadratic check due to complexity oflocations_equalinside.This change just basically adds a fancy hashset to bring that time from 460 seconds on my machine to ~ 20ms.
Sadly this is not the only slowdown and second issue will probably require some more discussion as its related to
upsert_monitored_entry, during transfer there seems to be some extra logic to apply them in batches, and that works well, but when files are transferred all the new events are processed one by one with each event causing checking of whole folder, so again looking at these 50k files each time, so that still stalled whole app for around 10 extra seconds - the app is unresponsive during that time so can't do anything.Also its kinda annoying right now as during the move I can't use the same window to do anything else as there is just a big progress modal in my face, why is that?
Visual evidence
N/A, perf only
How to test
Expected result:
Fast file operations