database.am: Fix option -f speed regression#2333
Merged
ivan-hc merged 1 commit intoivan-hc:mainfrom May 8, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It was introduced by this commit:
146152b
Running
du -sb .as a check is expensive, so I simply catch the error code instead. bsd'sduoutputs 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 useawkhere, 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 -skoutputs slightly different file sizes compared todu -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.