-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
bat is extremely slow (>100x slower than cat) for 4 char file #925
Comments
Thank you for the detailed report. The problem is not the time that it takes Measuring the hyperfine --warmup 10 'echo test | bat' --export-markdown no-custom-set.md
With a custom syntax/theme set, I get: bat cache --build
hyperfine --warmup 10 'echo test | bat' --export-markdown custom-set.md
Startup time of So how do we deal with this?
Profiling a startup run of I'm not sure if this is completely CPU bound, however. The There are several ideas that come to mind which could improve the situation:
|
Thanks for your response. The thing is is, I have never had any custom syntax or theme set. The only customization I have is the May it be related to #882 because I have files from older versions? I have this line in my zshrc to work around the cache being older than the bat binary: |
Hm. at some point,
Why would you have that line in the |
It seems the Anyway if I remove |
That should not be the case. The "Solarized (dark)" theme should be part of bat 0.13. How did you install
No. By custom theme, I mean a
Phew... could you please post the output of Random guess: did you maybe build |
I can confirm the colors are not right, until I run
No I'm using the official Arch Linux package. Output of info.sh after
|
Weird. I can not reproduce this. What do you mean by "colors are not right"? Maybe you have another version of "Solarized (dark)" in |
For the "4 char file"? It would be great if you could post a reproducible test case here. If it's not too much to ask, it would be helpful to get reliable benchmark results via echo "hello world" > test.txt
hyperfine \
--warmup 10 \
--show-output \
--export-markdown result.md \
'bat --no-config test.txt' On my laptop, I get:
|
Yup, I had another theme file there I don't remember adding... I will open another issue, because the current Solarized themes shipped with bat are broken and outdated. Timings measured by hyperfine, after running
Before you ask, my CPU is an Intel i7 X 990, overclocked at 4GHz. My root partition (and the bat binary) in on a SSD. Definitely not brand new, but not low end either. |
Ok, thanks!
Thank you. These times are actually comparable with mine (min time of 50 ms), but I am assuming that you had a few other IO heavy processes running (Spotify, Dropbox, ..) which lead to a rather large standard deviation and a max time of almost 100 ms. |
The situation has actually improved with the newly released bat v0.15 For custom caches, we should now see comparable startup times:
This is due to a recent change by @lzutao: e37e9c1#diff-977a955f26740fd3b439f4e2f0d7aaff 👍 |
Nice, even with cache cleared, it seems to improve performance measurably on my system: Release build at commit a482838 (one commit before the clippy fixes):
Release build at commit e37e9c1:
EDIT: Or maybe it's just noise in the measurements... |
Hm, yeah. I'd be surprised if it did improve for the builtin cache as well. |
Quoting myself:
That is not needed anymore after the fix in v0.15 mentioned above.
This would still be great. I'm going to open a new ticket to address startup speed in particular. The other issues in this ticket seem to be resolved? |
What version of
bat
are you using?See output of
info.sh
below.Describe the bug you encountered:
Bat is ~100-150x slower than cat, even with
--plain
.It may be a recent regression, because it did not notice it was that slow before.
Describe what you expected to happen?
I expect it to be as fast or only marginally slower.
I have seen #304 but this issue is not about piping thousands of lines, just a few chars, and the fact that it's that slow with
--plain
tells something abnormal is going on.How did you install
bat
?Official Arch package: https://www.archlinux.org/packages/community/x86_64/bat/
Here is the output of
info.sh
for my system:system
$ uname -srm
Linux 5.4.32-1-lts x86_64
$ lsb_release -a
LSB Version: 1.4
Distributor ID: Arch
Description: Arch Linux
Release: rolling
Codename: n/a
bat
$ bat --version
bat 0.13.0
$ env
BAT_THEME=Solarized (dark)
$ bat --list-languages
Found custom syntax set.
$ bat --list-themes
Found custom theme set.
bat_config
bat_wrapper
No wrapper script.
bat_wrapper_function
No wrapper function.
tool
$ less --version
less 551 (PCRE regular expressions)
The text was updated successfully, but these errors were encountered: