# "freebsd-update fetch" improved efficiency.  Please test if you're interested.



## tux2bsd (Oct 2, 2021)

Slightly edited quote for relevant history:


			
				tux2bsd said:
			
		

> It isn't about "speed", it is about reducing unnecessary inefficiency.  It's that simple.
> 
> My underlying goal was to get `freebsd-update fetch` be more efficient *when there are no updates*.
> 
> ...



https://github.com/freebsd/freebsd-src/pull/543   I promised to share it, so there it is.  ( fyi grahamperrin, jbodenmann, SirDice )


----------



## tux2bsd (Oct 2, 2021)

And a bug report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258863


----------



## tux2bsd (Oct 26, 2021)

There have been a few changes since then but if you want to try this out you can.









						"freebsd-update fetch", be efficient if no updates by tux2bsd · Pull Request #543 · freebsd/freebsd-src
					

When there are no updates available there is no need run through the the entirety of fetch_run () This introduces a simple check and its most significant benefit is avoiding the disk intensive phas...




					github.com


----------



## tux2bsd (Mar 16, 2022)

I've tackled this problem another way, it's disgusting but it works, to quote myself:



> # Take freebsd-update, modify it and have it standalone as 'freebsd-update-prefire' .
> # This is hideous but there's too much entangled code in freebsd-update.
> # The cruft of freebsd-update could be whittled away from 'freebsd-update-prefire'
> # with sufficient time, it took me about an hour to get this prototype going.



I've called my new hack job `freebsd-update-prefire`, run like so: `freebsd-update-prefire && freebsd-update fetch install` (etc)

`freebsd-update-prefire` does an initial probe to check if there are updates, this avoids freebsd-update's pointless disk thrashing in the bugreport above.

It's a tweak on the existing `freebsd-update` code, just being sensible about checking for updates prior to prematurely jumping to the next step.  It's the same mechanism (checking tags at the right time) as I had prior but is now external to `freebsd-update`.

`freebsd-update` is self-entangled and monolithic and cannot be corrected internally, there are a multitude of different run modes that impact each other.

grahamperrin would be interested, maybe some other people.

If `freebsd-update` shits itself you need salvage that directly, `freebsd-update-prefire` would think you were up to date because it only sees and compares tags (grep freebsd-update for "tag").


diff file posted as a .ini because of the forums...  diff is against https://raw.githubusercontent.com/freebsd/freebsd-src/main/usr.sbin/freebsd-update/freebsd-update.sh (            Latest commit            e01e8f9            on 13 Feb)


----------



## grahamperrin@ (Mar 16, 2022)

Certainly interested, thanks, although my more immediate priorities include `13.1-BETA⋯` e.g. the foot of <https://forums.freebsd.org/posts/560319> and then <https://forums.freebsd.org/posts/559993> PkgBase …


----------



## tux2bsd (Mar 24, 2022)

I've cracked it, that thing was too large to whittle into something else so I've abandoned it.  Started from scratch `freebsd-update-probe.sh` posting it to github soon.


----------



## tux2bsd (Mar 24, 2022)

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258863#c9 , github link from there.


----------



## tux2bsd (Mar 24, 2022)

```
root@freebsd-dns:~ # time /root/freebsd-update-probe.sh || freebsd-update fetch install
freebsd-update-probe.sh found matching tags, no update needed.
0.067u 0.141s 0:00.60 33.3%     119+187k 0+0io 0pf+0w

root@freebsd-dns:~ # time freebsd-update fetch install
src component not installed, skipped
Looking up update.FreeBSD.org mirrors... 2 mirrors found.
Fetching metadata signature for 13.0-RELEASE from update2.freebsd.org... done.
Fetching metadata index... done.
Inspecting system... done.
Preparing to download files... done.

No updates needed to update system to 13.0-RELEASE-p10.
No updates are available to install.
76.380u 22.593s 1:31.64 107.9%  22+170k 0+0io 0pf+0w
```

That's on a raspberry pi 3b.


----------

