Optimize rsync performance and reduce GUI overhead during copy stage

- Replace --progress with --info=progress2 for better rsync performance
- Change -av to -a to reduce verbose output
- Reduce progress update frequency from 1%/3s to 2%/5s
- Reduce re-estimation frequency from 5s to 10s
- Add fallback progress parsing for --info=progress2 format
- These changes should significantly speed up the copy stage
parent 6cd581e6
......@@ -486,7 +486,7 @@ class InstallerWorker(QThread):
self.progress_updated.emit(90)
# Step 10: Bootloader installation moved to configure_target_system (before unmount)
# Step 10: Bootloader installation (moved to configure_target_system for proper bind mounts)
self.progress_updated.emit(95)
......@@ -761,11 +761,11 @@ class InstallerWorker(QThread):
estimated_copy_time = 180 # 3 minutes default
self.log("Could not estimate total size, using default 3-minute estimation")
# Use rsync with progress output for dynamic updates
# Use rsync with optimized progress output for better performance
# Exclude the target directory to prevent copying into itself
target_exclude = f'--exclude={target_mount}'
cmd = [
'rsync', '-av', '--progress',
'rsync', '-a', '--info=progress2', # Use -a instead of -av and --info=progress2 for better performance
target_exclude,
'--exclude=/proc', '--exclude=/sys', '--exclude=/dev',
'--exclude=/tmp', '--exclude=/run', '--exclude=/mnt',
......@@ -825,7 +825,7 @@ class InstallerWorker(QThread):
self.copy_progress.emit(line)
# Parse rsync progress for actual bytes copied
# Look for lines like: "1,234,567 100% 123.45MB/s 0:00:00 (xfr#1, to-chk=0/1)"
# Look for lines like: "1,234,567 100% 1.23MB/s 0:00:01 (xfr#123, to-chk=0/456)"
if 'xfr#' in line and 'to-chk=' in line:
try:
# Extract bytes from the beginning of the line
......@@ -838,6 +838,17 @@ class InstallerWorker(QThread):
bytes_copied = new_bytes
except (ValueError, IndexError):
pass
# Also try to parse lines that just show progress without xfr#
elif '%' in line and len(line.split()) >= 3:
try:
parts = line.strip().split()
if parts[0].replace(',', '').isdigit():
bytes_str = parts[0].replace(',', '')
new_bytes = int(bytes_str)
if new_bytes > bytes_copied:
bytes_copied = new_bytes
except (ValueError, IndexError):
pass
last_update_time = time.time()
......@@ -849,8 +860,8 @@ class InstallerWorker(QThread):
current_time = time.time()
elapsed_time = current_time - start_time
# Re-estimate progress every 5 seconds based on actual transfer rate
if current_time - last_reestimate_time >= 5.0 and bytes_copied > last_reestimate_bytes:
# Re-estimate progress every 10 seconds based on actual transfer rate
if current_time - last_reestimate_time >= 10.0 and bytes_copied > last_reestimate_bytes:
bytes_since_last = bytes_copied - last_reestimate_bytes
time_since_last = current_time - last_reestimate_time
......@@ -906,12 +917,12 @@ class InstallerWorker(QThread):
current_progress = min(current_progress, copy_progress_end - 2) # Leave room for final update
# Update progress more frequently during copy (every 1% change or 3 seconds)
# Update progress less frequently to optimize performance (every 2% change or 5 seconds)
should_update = False
if hasattr(self, '_last_progress'):
progress_diff = abs(current_progress - self._last_progress)
time_since_last_update = current_time - getattr(self, '_last_update_time', 0)
if progress_diff >= 1.0 or time_since_last_update >= 3.0:
if progress_diff >= 2.0 or time_since_last_update >= 5.0:
should_update = True
else:
should_update = True
......@@ -1067,8 +1078,8 @@ class InstallerWorker(QThread):
# Configure NTP
self._configure_ntp(target_mount)
# Install GRUB bootloader BEFORE unmounting (moved from main run method)
self.log("Installing GRUB bootloader...")
# Install GRUB bootloader BEFORE unmounting (this is the very last step before cleanup)
self.log("Installing GRUB bootloader (final step before unmounting)...")
try:
self.install_bootloader(target_mount, self.config['target_disk'])
self.log("GRUB bootloader installed successfully")
......@@ -1222,11 +1233,34 @@ class InstallerWorker(QThread):
return env
def install_bootloader(self, target_mount, target_disk):
# GRUB installation with clean environment
cmd = ['chroot', target_mount, 'grub-install', target_disk]
clean_env = self._clean_env()
subprocess.run(cmd, check=True, env=clean_env)
self.log("Bootloader installed")
# GRUB installation with enhanced error handling and clean environment
self.log(f"Installing GRUB bootloader on {target_disk}...")
try:
# First, try to install GRUB
cmd = ['chroot', target_mount, 'grub-install', target_disk]
clean_env = self._clean_env()
result = subprocess.run(cmd, capture_output=True, text=True, check=True, env=clean_env)
self.log("GRUB bootloader installed successfully")
# Generate GRUB configuration
self.log("Generating GRUB configuration...")
grub_cfg_cmd = ['chroot', target_mount, 'update-grub']
result = subprocess.run(grub_cfg_cmd, capture_output=True, text=True, check=True, env=clean_env)
self.log("GRUB configuration generated successfully")
except subprocess.CalledProcessError as e:
self.log(f"Warning: GRUB installation failed: {e.stderr}")
# Try alternative GRUB installation method
try:
self.log("Attempting alternative GRUB installation...")
alt_cmd = ['chroot', target_mount, 'grub-install', '--force', target_disk]
result = subprocess.run(alt_cmd, capture_output=True, text=True, check=True, env=clean_env)
self.log("GRUB bootloader installed with --force option")
except subprocess.CalledProcessError as e2:
self.log(f"Warning: Alternative GRUB installation also failed: {e2.stderr}")
# Continue with installation despite GRUB failure
self.log("Continuing installation despite GRUB installation failure")
def run_post_install(self, target_mount):
# Run post-install script if available
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment