Skip to content

database.am: Fix option -f speed regression#2333

Merged
ivan-hc merged 1 commit intoivan-hc:mainfrom
fiftydinar:patch-1
May 8, 2026
Merged

database.am: Fix option -f speed regression#2333
ivan-hc merged 1 commit intoivan-hc:mainfrom
fiftydinar:patch-1

Conversation

@fiftydinar
Copy link
Copy Markdown
Contributor

@fiftydinar fiftydinar commented May 8, 2026

It was introduced by this commit:
146152b

Running du -sb . as a check is expensive, so I simply catch the error code instead. bsd's du outputs error code 64 for non-available option, but I also check for error code other than 0.

We can use the shell arithmetic calculation instead of awk, but I use awk here, because of 32bit shell limitations (precision up to ~2GiB. After that, it shows wrong info). And I saw the Raspberry Pi OS having 64 bit kernel, while other apps are 32 bit, including shell.

du -sk outputs slightly different file sizes compared to du -sb, but it's still relatively accurate. It's also slightly slower, but not a big deal (and not visible like with my system with 100 GBs of data).

This makes it fast like it was before, while retaining support for BSD, Busybox and GNU utilities.

It was introduced by this commit:
ivan-hc@146152b

Running `du -sb .` as a check is expensive, so I simply catch the error code instead.
bsd's `du` outputs error code 64 for non-available option, but I also check for error code other than 0.

We can use the shell arithmetic calculation instead of `awk`, but I use `awk` here, because of 32bit shell limitations. And I saw the Raspberry Pi OS having 64 bit kernel, while other apps are 32 bit, including shell.

`du -sk` outputs slightly different file sizes compared to `du -sb`, but it's still relatively accurate.

This makes it fast like it was before, while retaining support for BSD, Busybox and GNU utilities.
@ivan-hc ivan-hc merged commit 30f094a into ivan-hc:main May 8, 2026
@fiftydinar fiftydinar deleted the patch-1 branch May 8, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants