Skip to content

Commit

Permalink
Rewrite clone logic for better performance & Fix Bugs (#18)
Browse files Browse the repository at this point in the history
The clone logic was rewritten for better concurrency which yields higher
performance in most cases since a lot of our time is spent in blocking
IO (e.g. download chunks / writing chunks). Additionally some
parallelism was added to the clone code for the parts that are CPU
intensive (i.e. chunk hashing). A number of outstanding bugs were fixed
especially around progress reporting.

**Changes**:

- Rewrote cloning logic so it can be done in multiple steps concurrently
for multiple files:
  - Enables more concurrency and parallelism where possible
- Improves progress reporting for each step (chunking, downloading,
etc.)
  - Code is easier to follow
- Progress reporting is more accurate, especially in case for partial
downloads when chunks are already present

- Refactored progress to use shared state instead of messages
- This improves UI performance because we don't need to drain every
message but can just update the progress on each tick. In some cases we
literally took more time to update the UI than the actual update process
took
  -  Simplifies the code by reducing message passing handlers

- Fixed a lurking bug where the child process (e.g. trose or new
updater) would not be able to exit cleanly because parent stdio handles
were dropped. For updater to updater process starts this would cause the
updater to never exit in the background even when closing it which
caused updates to continue
- Removed all the shutdown receivers which were incorrectly added to
protect against this

- Added text to status bar for different stages to provide extra
information
- Changed updater download logic
- Previously the existing process was renamed then the updater was
downloaded. If the updater failed users would be left without a
functioning updater
- Now the updater will be downloaded AND then the files will be renamed
  - The full updater will always be redownloaded to avoid any issues
- TODO: Atomic renames using `FileReplace` on windows and `renameat2` on
linux (and macos?)
  • Loading branch information
rminderhoud authored Jan 31, 2025
1 parent ac546f5 commit 558d73f
Show file tree
Hide file tree
Showing 11 changed files with 965 additions and 655 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Install dependencies (Ubuntu only)
if: matrix.os == 'ubuntu-latest'
run: sudo apt update && sudo apt install -y libwebkit2gtk-4.1-dev

- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2

- name: Build in release mode
run: cargo build --release
Loading

0 comments on commit 558d73f

Please sign in to comment.