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

Painfully slow on 16MB (minified) JSON #2

Open
corneliusroemer opened this issue Mar 19, 2024 · 8 comments
Open

Painfully slow on 16MB (minified) JSON #2

corneliusroemer opened this issue Mar 19, 2024 · 8 comments

Comments

@corneliusroemer
Copy link
Contributor

I love the idea of this tool, and the demo looks really cool too!

Installation worked flawlessly with cargo install jnv, but when I fired it up on a real JSON I had looked at with jq earlier, I noticed it was painfully slow, unusably slow, response times were on the order of 5-10 seconds after each key stroke.

Of course this is v0.1.0 - but just wanted to give feedback nonetheless from my real world test drive.

I'm on an M1 Pro with 32GB RAM which is fairly high end.

I tried reducing the display depth but that didn't help.

@ynqa
Copy link
Owner

ynqa commented Mar 19, 2024

@corneliusroemer Thanks for your reporting! 👍

Could you share the actual JSON, if possible? I'd like to test it myself and understand the current data size limits.

@corneliusroemer
Copy link
Contributor Author

Sure, here we go: test.json

I've meanwhile found fx to be very good for such large JSON files, don't even notice any slowdown at all.

@ynqa
Copy link
Owner

ynqa commented Mar 19, 2024

@corneliusroemer fx and jless are indeed famous for their ability to display content very quickly.

On the other hand, jnv relies on the processing speed of libjq, so it can take time to handle very large JSON files. For example, you can see how long it takes by running cat test.json | jq.

I believe there can be a division of use cases: utilize fx or jless when you want to get an overview of the large JSON, and use jnv when you want to try out complex queries with jq for the mid-size JSON.

fx and jless do allow for field lookup with .path.to.field and have some simple DSL query capabilities, but I understand that they cannot handle complex queries like jq can.

@corneliusroemer
Copy link
Contributor Author

Thanks for the detailed reply. I suppose some async/await could help with not freezing the TUI - but the added complexity may well not be worth it. The tool would still be usable with the 16MB file if it simply didn't show output until say 3s after the last keystroke.

The biggest usability problem for large files is that keystrokes are delayed.

@ynqa
Copy link
Owner

ynqa commented Mar 20, 2024

I suppose some async/await could help with not freezing the TUI
The biggest usability problem for large files is that keystrokes are delayed

@corneliusroemer You're absolutely right; there's a potential to degrade user experience.

jnv utilizes the mechanisms from promkit, where I'm considering implementing a system that can handle keystrokes and data structure editing concurrently using async/await at promkit (I've tried this before, but it's been a bit challenging and is currently pending).

@rocurley
Copy link

Hey, I wrote a similar project a while ago: Jex. While the UI looks a lot better here, I didn't have this problem. I believe the difference is that I parsed the JSON once at load and then used the parsed structure from there on out.

Looking at your code, you already parse the output to json so you're in a pretty good spot there. Even if you don't think it's worth it to switch your rendering code to use JQ's internal representation, I bet you could convert from JQ's representation to yours a lot faster if you didn't go through a string representation between the two.

@rockwotj
Copy link

I would recommend Jaq, it's native rust and you can won't have to convert each time, and was built to fix some speed cases with many filters compared to jq.

https://docs.rs/jaq-interpret/latest/jaq_interpret/

@ynqa
Copy link
Owner

ynqa commented Mar 23, 2024

@rockwotj Regarding the replacement with jaq, I have created #24, so please provide your opinions/reactions there 🙏

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

5 participants
@rocurley @ynqa @rockwotj @corneliusroemer and others