]>
Sergey Matveev's repositories - bfs.git/log
Tavian Barnes [Thu, 12 Oct 2023 19:50:59 +0000 (15:50 -0400)]
bftw: Make sure we don't close a directory while we unwrap it
bftw_cache_reserve() can lead to bftw_cache_pop(), which could close the
directory we're trying to unwrap! If that happened, we would try
dup_cloexec(-1), which would fail with EBADF, so there was no observable
bug. But it's better to avoid the whole situation.
Tavian Barnes [Thu, 12 Oct 2023 19:13:02 +0000 (15:13 -0400)]
bftw: Fix to_close list corruption with !BFS_USE_UNWRAPDIR
It's possible for pincount to drop to zero, then get incremented and
drop back to zero again. If this happens, we shouldn't add it to the
to_close list twice.
This should fix the intermittent hang on the macOS CI.
Fixes: 815798e1eea7fc8dacd5acab40202ec4d251d517
Tavian Barnes [Thu, 12 Oct 2023 17:18:00 +0000 (13:18 -0400)]
list: Assert that we're not inserting already-attached nodes
Tavian Barnes [Thu, 12 Oct 2023 17:09:11 +0000 (13:09 -0400)]
diag: Move enum debug_flags out of ctx.h
Tavian Barnes [Thu, 12 Oct 2023 14:41:04 +0000 (10:41 -0400)]
bftw: Don't force buffering for parallel dfs
Tavian Barnes [Thu, 12 Oct 2023 15:24:49 +0000 (11:24 -0400)]
bftw: Fix unbuffered depth-first searches
bftw() implements depth-first search by appending files to a batch, then
prepending the batch to the queue. When we switched to separate file/
directory queues, this was only implemented for the file queue.
Unbuffered searches don't use the file queue, so they were all breadth-
first in practice.
This meant that iterative deepening (-S ids) was actually "iterative
deepening *breadth*-first search," a horrible strategy with no advantage
over regular breadth-first search. Now it performs iterative deepening
*depth*-first search, which at least limits its memory consumption.
Fixes: c1b16b49988ecff17ae30978ea14798d95b80018
Tavian Barnes [Thu, 12 Oct 2023 13:44:27 +0000 (09:44 -0400)]
bftw: Let iterative deepening work depth-first when sorting
Tavian Barnes [Tue, 10 Oct 2023 15:51:34 +0000 (11:51 -0400)]
bench: Default to --strategies=rust
Tavian Barnes [Tue, 10 Oct 2023 15:37:40 +0000 (11:37 -0400)]
bench: New --jobs benchmark
Tavian Barnes [Tue, 10 Oct 2023 15:34:26 +0000 (11:34 -0400)]
bench: Group by strategy in comparison mode
Tavian Barnes [Tue, 10 Oct 2023 15:21:38 +0000 (11:21 -0400)]
bench: Don't print paths in the --strategies benchmark
Tavian Barnes [Tue, 10 Oct 2023 15:14:18 +0000 (11:14 -0400)]
bench: Allow format specifiers in (sub)group headers
Tavian Barnes [Fri, 6 Oct 2023 23:08:33 +0000 (19:08 -0400)]
bar: Replace volatile sig_atomic_t with actual atomics
Tavian Barnes [Fri, 6 Oct 2023 16:37:01 +0000 (12:37 -0400)]
alloc: Test allocation size overflows
Tavian Barnes [Fri, 6 Oct 2023 16:00:02 +0000 (12:00 -0400)]
tests/bfs/status: Try to test SIGWINCH
Tavian Barnes [Fri, 6 Oct 2023 15:56:31 +0000 (11:56 -0400)]
tests: Check for expect_unbuffer too
That's where FreeBSD installs it.
Tavian Barnes [Fri, 6 Oct 2023 15:42:06 +0000 (11:42 -0400)]
tests: New bfs_pty wrapper for unbuffer
Tavian Barnes [Thu, 5 Oct 2023 21:29:52 +0000 (17:29 -0400)]
ci: Install expect for unbuffer
Tavian Barnes [Thu, 5 Oct 2023 21:18:40 +0000 (17:18 -0400)]
tests/bfs: Add a test that runs -status
Tavian Barnes [Thu, 5 Oct 2023 20:25:56 +0000 (16:25 -0400)]
tests/bfs: Add tests for color autodetection
Tavian Barnes [Thu, 5 Oct 2023 20:25:21 +0000 (16:25 -0400)]
tests: Respect $NO_COLOR
Tavian Barnes [Thu, 5 Oct 2023 18:44:55 +0000 (14:44 -0400)]
README: Realign badges
A recent GitHub change broke the nice alignment of the badges to the top
heading, so just put the badges underneath it for now.
Tavian Barnes [Thu, 5 Oct 2023 16:56:36 +0000 (12:56 -0400)]
bfstd: Add a thread-safe wrapper for strerror()
Tavian Barnes [Thu, 5 Oct 2023 16:55:56 +0000 (12:55 -0400)]
thread: Define thread_local
Tavian Barnes [Thu, 5 Oct 2023 16:47:31 +0000 (12:47 -0400)]
config: Fold !__FreeBSD__ into BFS_USE_SYS_CAPABILITY_H
Tavian Barnes [Tue, 3 Oct 2023 20:26:05 +0000 (16:26 -0400)]
dstring: Limit the special dchar typedef to lint builds
Clang still thinks that alignof(dstr[1]) == 2, so out of an abundance of
caution, don't mess with dchar alignment in normal builds.
Tavian Barnes [Tue, 3 Oct 2023 20:25:56 +0000 (16:25 -0400)]
build: New lint flag
Tavian Barnes [Tue, 3 Oct 2023 17:07:21 +0000 (13:07 -0400)]
thread: s/call_once/invoke_once/
call_once() is a reserved identifier from C11.
Tavian Barnes [Tue, 3 Oct 2023 14:17:12 +0000 (10:17 -0400)]
ci/freebsd: Use tailscale ssh
Tavian Barnes [Tue, 3 Oct 2023 14:11:42 +0000 (10:11 -0400)]
ci/macos: Don't install coreutils
Since we build our own touch(1) implementation, we no longer need to
work around the macOS bug.
Tavian Barnes [Mon, 2 Oct 2023 18:13:49 +0000 (14:13 -0400)]
tests: Fix make_deep() on FreeBSD
I keep forgetting that PATH_MAX is only 1024 there.
Tavian Barnes [Mon, 2 Oct 2023 17:09:41 +0000 (13:09 -0400)]
Merge branch 'io-uring'
Tavian Barnes [Mon, 2 Oct 2023 17:09:36 +0000 (13:09 -0400)]
Merge branch 'benchmarks'
Tavian Barnes [Mon, 2 Oct 2023 16:57:26 +0000 (12:57 -0400)]
tests: Don't cd into paths longer than PATH_MAX
This fixes a warning on at least Alpine Linux that looks like
cd: error retrieving current directory: getcwd: cannot access parent directories: Filename too long
Tavian Barnes [Tue, 11 Jul 2023 18:04:40 +0000 (14:04 -0400)]
ioq: Use io_uring
Closes #65.
Tavian Barnes [Tue, 11 Jul 2023 18:30:52 +0000 (14:30 -0400)]
build: Add liburing on Linux
Tavian Barnes [Mon, 2 Oct 2023 14:49:41 +0000 (10:49 -0400)]
bench: Add a README
Tavian Barnes [Fri, 29 Sep 2023 18:13:06 +0000 (14:13 -0400)]
bench: Add benchmarking script
Tavian Barnes [Thu, 28 Sep 2023 21:39:34 +0000 (17:39 -0400)]
bench: New script to clone a git repo without file contents
Tavian Barnes [Fri, 29 Sep 2023 19:13:41 +0000 (15:13 -0400)]
tests/xtouch: Try creating the immediate parent first
Tavian Barnes [Wed, 27 Sep 2023 16:11:15 +0000 (12:11 -0400)]
Formatting fixes
Tavian Barnes [Tue, 26 Sep 2023 19:42:35 +0000 (15:42 -0400)]
bit: Fix UINTPTR_WIDTH typo
Tavian Barnes [Tue, 26 Sep 2023 19:05:43 +0000 (15:05 -0400)]
bit: Use predefined __*_WIDTH__ macros if we can
Tavian Barnes [Tue, 26 Sep 2023 16:48:21 +0000 (12:48 -0400)]
dstring: New dchar typedef for dynamic strings
Tavian Barnes [Mon, 25 Sep 2023 19:26:52 +0000 (15:26 -0400)]
ci/freebsd: Switch to Tailscale OAuth
Tavian Barnes [Mon, 25 Sep 2023 17:58:19 +0000 (13:58 -0400)]
Use the new list macros
Tavian Barnes [Mon, 25 Sep 2023 17:53:15 +0000 (13:53 -0400)]
list: New for_[s]list() macros
Tavian Barnes [Mon, 25 Sep 2023 17:34:17 +0000 (13:34 -0400)]
list: Unify formatting
Tavian Barnes [Mon, 25 Sep 2023 17:29:03 +0000 (13:29 -0400)]
list: New [S]LIST_EMPTY() macros
Tavian Barnes [Mon, 25 Sep 2023 17:16:35 +0000 (13:16 -0400)]
list: New [S]LIST_ITEM_INIT() macros
Tavian Barnes [Mon, 25 Sep 2023 17:03:51 +0000 (13:03 -0400)]
list: Use (void)(...) rather than do { ... } while (0)
This makes everything usable in expression contexts.
Tavian Barnes [Thu, 14 Sep 2023 16:14:26 +0000 (12:14 -0400)]
README: Add Guix and OpenBSD packages
Tavian Barnes [Wed, 13 Sep 2023 15:39:50 +0000 (11:39 -0400)]
bftw: Share the bftw_state between iterations of ids/eds
Tavian Barnes [Tue, 12 Sep 2023 19:04:30 +0000 (15:04 -0400)]
parse: Give more ephemeral_fds to -no{user,group}
Fewer than 3 can lead to
Assertion failed: (retval->write_queue != -1), function __open_cached_connection, file /usr/src/lib/libc/net/nscachedcli.c, line 224.
on a FreeBSD system with LDAP accounts.
Tavian Barnes [Thu, 7 Sep 2023 01:15:50 +0000 (21:15 -0400)]
Release 3.0.2
Tavian Barnes [Wed, 6 Sep 2023 21:13:04 +0000 (17:13 -0400)]
bfstd: Work around a FreeBSD-specific msan issue
Link: https://github.com/llvm/llvm-project/issues/65532
Tavian Barnes [Wed, 6 Sep 2023 20:28:12 +0000 (16:28 -0400)]
bfstd: Skip a whole loop in dollar_quote() if possible
Tavian Barnes [Wed, 6 Sep 2023 20:23:10 +0000 (16:23 -0400)]
bfstd: Fix printable_len() off-by-one
If xmbrtowc() fails, or if xiswprint() is false, then we shouldn't
include that wide char in the printable length.
Fixes: 19c96abe0a1ee56cf206fd5e87defb1fd3e0daa5
Tavian Barnes [Wed, 6 Sep 2023 18:59:59 +0000 (14:59 -0400)]
bfstd: Fix an OOB string index in xmbrtowc()
This bug could be reproduced with something like
$ bfs -samefile $'\xFA\xFA'
bfs: error: bfs: dstrnescat@src/dstring.c:252: wordesc() result truncated
or worse, with -DNDEBUG,
$ bfs -samefile $'.....................\xFA\xFA'
bfs: error: bfs -samefile $'.....................\xFA\xFA\x00\x55\x53\x45\x52\x3D\x74\x61\x76\x69\x61\x6E\x61\x74\x6F\x72
bfs: error: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bfs: error: No such file or directory.
which prints the memory after the end of the string (in this case, the
environment variable USER=tavianator).
The bug was caused by the line `*i += len`, which was intended to be
`*i = len`. But actually, the right behaviour seems to be `*i += 1`.
Fixes: 19c96abe0a1ee56cf206fd5e87defb1fd3e0daa5
Tavian Barnes [Wed, 6 Sep 2023 13:30:47 +0000 (09:30 -0400)]
bftw: Enforce the dirlimit strictly
The previous accounting didn't fully control the number of allocated
bfs_dirs, as the dirlimit was incremented once we popped the directory,
not when we freed it.
Alejandro Lazaro [Fri, 1 Sep 2023 15:50:26 +0000 (17:50 +0200)]
bfs uses the C17 standard version
`bfs` uses C17 since 3.0
Tavian Barnes [Thu, 31 Aug 2023 15:07:38 +0000 (11:07 -0400)]
pwcache: Don't use _SC_GET{PW,GR}_R_SIZE_MAX
They tend be 1024, which is a lot of memory per user/group. 128 is
usually enough, so start there instead.
Tavian Barnes [Thu, 31 Aug 2023 14:55:39 +0000 (10:55 -0400)]
pwcache: Arena-allocate struct passwd/group
Tavian Barnes [Thu, 31 Aug 2023 14:42:42 +0000 (10:42 -0400)]
alloc: New varena_grow() function
Tavian Barnes [Thu, 31 Aug 2023 14:16:35 +0000 (10:16 -0400)]
trie: New trie_clear() function
Tavian Barnes [Thu, 31 Aug 2023 14:16:15 +0000 (10:16 -0400)]
alloc: New [v]arena_clear() functions
Tavian Barnes [Thu, 24 Aug 2023 03:19:55 +0000 (23:19 -0400)]
Work around https://github.com/llvm/llvm-project/issues/64946
Tavian Barnes [Tue, 8 Aug 2023 20:03:11 +0000 (16:03 -0400)]
ioq: New ioq_slot_monitor() helper
Tavian Barnes [Tue, 15 Aug 2023 19:57:02 +0000 (15:57 -0400)]
docs/bfs.1: Document each -regextype
Tavian Barnes [Tue, 15 Aug 2023 18:35:55 +0000 (14:35 -0400)]
docs/bfs.1: Document that -help/-version exit immediately
Tavian Barnes [Tue, 15 Aug 2023 18:30:41 +0000 (14:30 -0400)]
docs/bfs.1: Don't unnecessarily quote {}
Tavian Barnes [Tue, 15 Aug 2023 18:30:17 +0000 (14:30 -0400)]
docs/bfs.1: Clarify the effects of $POSIXLY_CORRECT
Tavian Barnes [Tue, 15 Aug 2023 18:28:10 +0000 (14:28 -0400)]
docs/bfs.1: Document use of $PATH
Tavian Barnes [Tue, 15 Aug 2023 18:27:01 +0000 (14:27 -0400)]
docs/bfs.1: Document that -prune does not work together with -depth
Tavian Barnes [Tue, 15 Aug 2023 18:26:23 +0000 (14:26 -0400)]
docs/bfs.1: Document the -type d,f syntax
Tavian Barnes [Tue, 15 Aug 2023 18:25:42 +0000 (14:25 -0400)]
docs/bfs.1: Use a bulleted list for -size units
Tavian Barnes [Tue, 15 Aug 2023 18:21:47 +0000 (14:21 -0400)]
docs/bfs.1: Give an example with a space separating date from time
Tavian Barnes [Tue, 15 Aug 2023 18:19:59 +0000 (14:19 -0400)]
docs/bfs.1: Make bold/italic formatting more consistent
Tavian Barnes [Mon, 14 Aug 2023 20:05:35 +0000 (16:05 -0400)]
tests: Add missing .out file
Tavian Barnes [Mon, 14 Aug 2023 19:59:04 +0000 (15:59 -0400)]
parse: Allow -files0-from an empty set of paths
This follows a behaviour change in GNU findutils 4.9.0.
Tavian Barnes [Tue, 8 Aug 2023 19:11:45 +0000 (15:11 -0400)]
bfstd: Don't label a declaration
Tavian Barnes [Mon, 7 Aug 2023 23:11:18 +0000 (19:11 -0400)]
stat: Don't check for statx() mask bits we already checked for
Tavian Barnes [Mon, 7 Aug 2023 23:41:12 +0000 (19:41 -0400)]
bfstd: Check multiple chars at once for isascii()
Tavian Barnes [Mon, 7 Aug 2023 22:29:19 +0000 (18:29 -0400)]
bfstd: Speed up wordesc() by caching isprint()/isspace()
Tavian Barnes [Mon, 24 Jul 2023 16:13:38 +0000 (12:13 -0400)]
bit: Add a cast to squelch -Wsign-compare
I see this only with musl-gcc for some reason.
Martin Polden [Sat, 22 Jul 2023 10:51:35 +0000 (12:51 +0200)]
README: Official Homebrew formula
An official `bfs` formula has been added to Homebrew now.
Wayne Scott [Sat, 22 Jul 2023 09:55:58 +0000 (05:55 -0400)]
README.md: fix reversed examples
Raf Czlonka [Thu, 20 Jul 2023 15:58:51 +0000 (16:58 +0100)]
Rename Makefile to GNUmakefile
Tavian Barnes [Thu, 20 Jul 2023 12:45:11 +0000 (08:45 -0400)]
README: Add official Arch Linux package
Jason Stewart [Wed, 19 Jul 2023 16:50:14 +0000 (12:50 -0400)]
CFLAGS adjustment in Makefile
`-flto` to `-flto=auto` to eliminate `using serial compilation of 3 LTRANS jobs` gcc warning
see https://stackoverflow.com/questions/
72218980 /gcc-v12-1-warning-about-serial-compilation
Tavian Barnes [Tue, 18 Jul 2023 16:23:21 +0000 (12:23 -0400)]
Release 3.0.1
Tavian Barnes [Tue, 18 Jul 2023 16:14:07 +0000 (12:14 -0400)]
bftw: Use bftw_file->next for multiple lists
A file can be on the to_open and to_read lists at the same time, but
otherwise only one list, so we can save memory by sharing the pointers.
Tavian Barnes [Tue, 18 Jul 2023 15:56:41 +0000 (11:56 -0400)]
bftw: Use a larger ioq depth
Now that the dirlimit provides backpressure on the number of open
directories, we can use a uniformly larger queue depth for increased
performance. The current parameters were tuned with a small grid search
on my workstation.
Tavian Barnes [Tue, 18 Jul 2023 15:43:21 +0000 (11:43 -0400)]
bftw: Add a queue of directories to unwrap
For !BFS_USE_UNWRAPDIR, if a file is still pinned in bftw_closedir(), it
has to stay open until its pincount drops to zero. Since this happens
in bftw_ioq_pop(), we can't immediately call bftw_unwrapdir() as that
adds to the ioq. Instead, add it to a list that gets drained by the
next bftw_gc().
Tavian Barnes [Tue, 18 Jul 2023 00:30:57 +0000 (20:30 -0400)]
bftw: Add dirs to the end of the queue in bftw_ioq_pop()
I tried this before in #105 but it led to performance regressions. The
key to avoiding those regressions is to put some backpressure on how
many bfs_dir's can be allocated simultaneously.
Tavian Barnes [Mon, 17 Jul 2023 22:40:32 +0000 (18:40 -0400)]
bftw: Use separate queues for open and closed directories
Tavian Barnes [Mon, 17 Jul 2023 23:58:39 +0000 (19:58 -0400)]
bftw: Check that file->fd == bfs_dirfd(file->dir) earlier
This has the potential to fail on at least one known platform: macports
with the legacysupport implementation of fdopendir().
Link: https://github.com/macports/macports-ports/pull/19047#issuecomment-1636059809
Tavian Barnes [Mon, 17 Jul 2023 23:05:23 +0000 (19:05 -0400)]
bftw: Reserve space in the cache before opening files
This fixes a storm of EMFILE retries observed with -j1 on a very large
directory tree.
Fixes: 7888fbababd22190e9f919fc272957426a27969e
Tavian Barnes [Mon, 17 Jul 2023 23:03:30 +0000 (19:03 -0400)]
bftw: Pass the whole bftw_state to bftw_openat()
This required shuffling a lot of code around. Hopefully the new order
makes more sense.
Tavian Barnes [Mon, 17 Jul 2023 21:15:47 +0000 (17:15 -0400)]
bftw: Add bfs_dir allocation wrappers