Rethinking deltarpms

Here’s the Python script I used to generate those stats tables, if anyone is curious to check on their own DeltaRPM performance. I strongly suspect this will only be useful if you use commandline dnf to update, GNOME Software may use deltaRPMs but I doubt it would be logged in /var/log/dnf.log even so.

#!/usr/bin/python3

import os
import re

with os.scandir("/var/log") as scan:
    dnf_logs = [entry for entry in scan if entry.name.startswith("dnf.log")]
linestats = []
dnf_logs.sort(key=lambda x: x.stat().st_mtime)
for dnf_log in dnf_logs:
    with open(dnf_log, "r") as f:
        for l in f.readlines():
            if not "Delta RPMs" in l:
                continue
            match = re.search(
                r"^([0-9]{4}-[0-9]{2}-[0-9]{2}).*Delta RPMs (.*?) ([0-9.]*) MB of updates to ([0-9.]*) MB \((.*) (saved|wasted)",
                l)
            if not match:
                continue
            date = match.group(1)
            before, after, delta = (match.group(3), match.group(4), match.group(5))
            reduced = bool(match.group(2) == "reduced")
            linestats.append((date, float(before), float(after), delta))
print("      Date  Before (MB)  After (MB)    Saved")
print("--------------------------------------------")
for line in linestats:
    print("%10s  %10.2f  %10.2f  %8s" % line)
    allmb += line[1]
    deltamb += line[2]
savedmb = allmb - deltamb
print(
    "\nTotal MBytes: %8.2f Delta MBytes: %8.2f (Saved: %6.2f, %5.2f%%)"
    % (allmb, deltamb, savedmb, 100 * (savedmb / allmb)))

(There’s a bit of useless code in there, like I didn’t end up actually using the reduced string-match for anything.)

1 Like