-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Faster pattern picker popup #2264
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
Conversation
I've reopened this one. Turns out I can't live without it. So much faster. I apply it to every build I make for debugging when I have to open patterns and every release build for general use. |
Thanks for the PR! Here's a video showcasing the speed on my machine: Recording.2025-05-25.202745.mp4 |
it is pretty slow for me too. it is not the auto loader it is when you click on import pattern on the menu |
Import.pattern.mp4I understand your reluctance to have parallel parsers. That said it’s only interested in #pragma directives. And it really is slow. So slow I initially though the app was broken. But we are loading it in different ways. |
And the with the cutom parser Faster.mp4 |
I did circumvent the preprocessor completely now and only run the lexer on the input files. For me that produces about the same speeds and doesn't require the reimplement a parser from scratch again. Could you try that latest commit and let me know if it's as fast for you too? |
App hangs loading fonts on splash screen. I sould have, as you suggested, just pulled that one commit. |
Ok. Killed the process and it started up the second time. It's slower than with the custom parser but still much faster than before both our changes. The code is a lot cleaner. I think it's a good compromise. On subsequent starts the app seems to start up quicker than before I pulled and compiled. |
Problem description
I’ve found ImHex to be impressively zippy. I’ve no doubt that’s intentional. Why use the GPU to render the UI otherwise?
Opening the pattern file selection popup, however, takes ages (on my system at least). On a release build just over 7 seconds (much worse in debug builds, around 50 seconds!). Enough time for one to wonder if it’s working.
The reason is that ImHex has to preprocess every pattern file to extract the pattern's descriptions.
This PR uses a standalone parser designed just extract the description, and only loads the initial portion of the file when doing so, assuming the description pragma will be near the beginning.
Implementation description
Pretty much as described above. I won’t blame you if you object to the handwritten parser however. Noxiously fiddly problematic things. That said, some effort at least has been expended to match the behaviour of pattern_language’s parsing.
There's a magic number.
Even so, I suggest you try it out and see the difference. As more and more patterns are added the problem will only get worse and worse.
This is my second attempt at this PR. Rouge files made it into my last attempt. Still leanring how to use git properly. Sorry.