Skip to content
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

Slow to open a JSON file containing 100,000 '[' characters #221

Closed
ogham opened this issue Aug 25, 2018 · 5 comments
Closed

Slow to open a JSON file containing 100,000 '[' characters #221

ogham opened this issue Aug 25, 2018 · 5 comments

Comments

@ogham
Copy link

ogham commented Aug 25, 2018

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

@ogham ogham changed the title Slow to open a JSON file contain 100,000 '[' characters Slow to open a JSON file containing 100,000 '[' characters Aug 25, 2018
@sharkdp
Copy link
Owner

sharkdp commented Aug 27, 2018

Thank you very much for reporting this.

That is unfortunate 😞

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

@sharkdp
Copy link
Owner

sharkdp commented Aug 31, 2018

Also related: trishume/syntect#202

@nloadholtes
Copy link

nloadholtes commented Oct 10, 2018

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.

@sharkdp
Copy link
Owner

sharkdp commented Oct 10, 2018

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?

@sharkdp
Copy link
Owner

sharkdp commented Oct 31, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants