Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rg spins in a nanosleep loop when one thread is blocked on a fifo #2761

Open
1 task done
leahneukirchen opened this issue Mar 21, 2024 · 0 comments
Open
1 task done

Comments

@leahneukirchen
Copy link

Please tick this box to confirm you have reviewed the above.

  • I have a different issue.

What version of ripgrep are you using?

ripgrep 14.1.0

features:-simd-accel,+pcre2
simd(compile):+SSE2,-SSSE3,-AVX2
simd(runtime):+SSE2,+SSSE3,+AVX2

PCRE2 10.42 is available (JIT is available)

How did you install ripgrep?

Distribution packages of Void Linux

What operating system are you using ripgrep on?

Void Linux x86_64 glibc

Describe your bug.

When recursively traversing a large directory and hitting a FIFO, one thread of rg gets stuck on the FIFO (suboptimal, but okay. Perhaps FIFO should not be opened with -r? ugrep seems to skip over fifo, GNU grep has the option of using -D skip).

After the whole tree is traversed, the remaining threads start to busy loop in ignore::walk::Worker::get_work. On a system with a bunch of CPU, this results in quite heavy syscall load across the system.

I'd at least expect the other threads to block, requiring no CPU time.

What are the steps to reproduce the behavior?

mkfifo /tmp/myfifo
strace -ff rg foobar /usr/include /tmp/myfifo

Notice how the threads spin on clock_nanosleep

What is the actual behavior?

The process keeps looping in clock_nanosleep.

I also attached a backtrace of the threads.

bt.log

What is the expected behavior?

ripgrep should just stall on the openat call for the FIFO, and not do busy looping in the other threads.

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

No branches or pull requests

1 participant