1

There seems to be a pathological case with one of the files I'm reading with less. The file is ~300MB in size, disk is fast (local NMVE) and the file can comfortably fit in memory, there is no swapping or anything like that.

less --version gives me

less 563 (PCRE regular expressions)

on Arch Linux. I run with no commandline parameters (no -R or -S). The file I am reading is being written to.

Usage: I notice using follow (pressing F) is generally slow for this file, but workable. Things are made worse by having a search active (for highlighting) while follow is in progress. Now if I search for the following: (something|something-else).*|.*warn and then hit F (follow), it totally grinds to a halt. I need to kill it from a different terminal.

I've been using such regexes with much larger files with no issue. Could something be amiss?

Edit: more exact steps and info:

  • happens with 50MB file, no long lines
  • another process appends to the file every 15s

Steps:

  • I open the file, go to end (Shift+g)
  • search for (something|something-else).*|.*warn (says Pattern not found since at the end)
  • follow (Shift+f) -> CPU goes to 100% and seemingly never stops
  • instead of pressing Shift+f, the same happens if I press UpArrow following the search
  • if I reduce the regex to one of its parts (either (something|something-else).* or .*warn the operations take a few seconds, still slow but manageable
  • resident memory shows as 400MB in htop
  • Ctrl+C doesn't work to interrupt it, need to kill from outside
haelix
  • 582
  • 1
  • 5
  • 10
  • 1
    About that regular expression, do you still have the same issue if you remove the two instances of `.*` (which does not seem to be necessary for actually matching)? – Kusalananda Mar 14 '21 at 12:23
  • Are their newlines in the file or is it one big 300MB-line? – Wieland Mar 14 '21 at 15:59
  • It's a log file, there are some long lines but not exceptionally long. I just tried again and the issue is there, adding precise steps on how it reproduces for me. – haelix Mar 17 '21 at 10:46
  • Why do you need `.*`? – muru Mar 17 '21 at 11:10
  • it's mostly for the highlighting, tbh. Highlighting starts from the beginning so I can quickly tell what's what – haelix Mar 17 '21 at 19:57

0 Answers0