From fd23c2ef85034aeb4bdad2ccfde66c5838f5aff6 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 24 Nov 2023 14:04:40 -0500 Subject: [PATCH] doc: add more warnings about --vimgrep The --vimgrep flag has some severe footguns when using a pattern that matches very frequently. We had already written some docs to warn about that, but now we also include a suggestion to avoid exorbitant heap usage. Closes #2505 --- CHANGELOG.md | 2 ++ crates/core/flags/defs.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de6c7230d..539a06e95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,8 @@ Bug fixes: Add documentation about `.ignore`/`.rgignore` files in parent directories. * [BUG #2480](https://github.com/BurntSushi/ripgrep/issues/2480): Fix bug when using inline regex flags with `-e/--regexp`. +* [BUG #2505](https://github.com/BurntSushi/ripgrep/issues/2505): + Improve docs for `--vimgrep` by mentioning footguns and some work-arounds. * [BUG #2519](https://github.com/BurntSushi/ripgrep/issues/2519): Fix incorrect default value in documentation for `--field-match-separator`. * [BUG #2523](https://github.com/BurntSushi/ripgrep/issues/2523): diff --git a/crates/core/flags/defs.rs b/crates/core/flags/defs.rs index cd7cdd32d..d4e3daf1e 100644 --- a/crates/core/flags/defs.rs +++ b/crates/core/flags/defs.rs @@ -7242,6 +7242,10 @@ if the pattern matches every byte in an input file, then each line will be repeated for every byte matched. For this reason, users should only use this flag when there is no other choice. Editor integrations should prefer some other way of reading results from ripgrep, such as via the \flag{json} flag. +One alternative to avoiding exorbitant memory usage is to force ripgrep into +single threaded mode with the \flag{threads} flag. Note though that this will +not impact the total size of the output, just the heap memory that ripgrep will +use. " } fn doc_choices(&self) -> &'static [&'static str] {