Bat: Slow to open a JSON file containing 100,000 '[' characters

Created on 25 Aug 2018  Â·  5Comments  Â·  Source: sharkdp/bat

I was doing some JSON-related work, using the examples at https://github.com/nst/JSONTestSuite. My code passes _most_ of the test cases, but one that it failed on was n_structure_100000_opening_arrays.json — a file containing nothing but one hundred thousand open brackets.

I tried opening the file in bat to see what it was, and it gets as far as printing out the "File:" header, but after that, just takes up 100% CPU doing syntax highlighting! Running with -l text displays the file instantly.

(I had similar troubles opening this file in my text editor, so don't feel bad. GitHub straight up refuses to render the file, too.)

screen shot 2018-08-25 at 12 03 52

All 5 comments

Thank you very much for reporting this.

That is unfortunate :disappointed:

This seems to be an issue with syntect, the (awesome) library that does the syntax highlighting for bat. I have reported the issue upstream: https://github.com/trishume/syntect/issues/201

I just noticed something unusual relating to this. The -p flag slows bat down considerably.

If I do bat -p some-minified-file.js it is incredibly slow to show each screenful, as in it takes over 2 seconds to draw the first page on the screen. Each page displays slower than the one before it, on the 3rd page I counted to 14 before it stopped rendering.

But if I do bat some-minified-file.js it is much faster, especially as I view each page. There doesn't seem to be any slow down as I page through the file.

Background: The js file is 381975 bytes. I noticed this because I made an alias for more to be bat -p.

I just noticed something unusual relating to this. The -p flag slows bat down considerably.

@nloadholtes Thank you for reporting this! I don't think this is related to this ticket (but I can reproduce this). Could you please open a new one?

I'm going to close this for now because there is nothing we can do here, but I'll keep an eye on the upstream ticket.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yannallain picture yannallain  Â·  3Comments

jkaan picture jkaan  Â·  3Comments

gAmUssA picture gAmUssA  Â·  3Comments

tomgoren picture tomgoren  Â·  3Comments

tbsvttr picture tbsvttr  Â·  3Comments