Skip to content

Pipelining text with ANSI color code to bat consumes huge CPU and memory. #1481

@cedric-sun

Description

@cedric-sun

What version of bat are you using?
bat 0.17.1

Describe the bug you encountered:

I was working on the nginx source tree: http://nginx.org/download/nginx-1.19.6.tar.gz

grep -rniI 'u_char' --color=always | bat

less will open but scrolling to end (G) takes 8 seconds for a 2500 lines grep result. top report that less consumed a whole CPU core and 960 MiB physical memory (RES) during that 8 seconds.

grep -rniI 'u_char' --color=never | bat works fine.
grep -rniI 'u_char' --color=always | less -RN works fine.

What did you expect to happen instead?
Performance should be equivalent to grep -rniI 'u_char' --color=always | less -RN.

How did you install bat?
Archlinux pacman.


Evironment

system

$ uname -srm
Linux 5.9.14-arch1-1 x86_64

bat

$ bat --version
bat 0.17.1

$ env

bat_config

bat_wrapper

No wrapper script for 'bat'.

bat_wrapper_function

No wrapper function for 'bat'.

No wrapper function for 'cat'.

tool

$ less --version
less 563 (PCRE regular expressions)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions