-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
String Perf traps and invalidations #45
Comments
Thanks! There's lots of room for optimization 😬 The goal so far was to get together a working, minimal, features set for people to start using Term. I'll have a look at the links you've sent, but if you have any advice on profiling/optimization practices that would help a lot, it's not something I've spent a lot of time doing in Julia yet. |
#60 introduces substantial changes that reduce runtime and allocations. Pre-compilation still takes a few seconds. I'm happy to make changes if you have suggestions for that. |
This is awesome work to see. I don't want to backseat drive your package's design, but here's a sketch of ideas that I didn't get a chance to test:
Huge fan and I can't wait to see what comes next. |
Not at all, this is very useful.
Have you got any specific spot in place?
After your initial issue I've spent a bunch time cleaning up the code and now the style parsing is more efficient: pts = """Lorem[red] ipsum dolor s[/red]it amet, consectetur adipiscing elit,
ed do eiusmod tempor [bold blue]incididu[underline]nt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nos[/underline]trud exercitation ullamco laboris nisi ut aliquip ex
ea commodo consequat. Duis aute [/bold blue][red on_black]irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat[/red on_black] cupidatat non proident,
sunt in [green]culpa qui officia[/green] deserunt mollit anim
id est laborum."""
@time apply_style(pts); # 0.000245 seconds (412 allocations: 37.781 KiB) 200ns is not great, surely what you suggest would be faster. The problem is that as you hint to, I need to cut and stitch together the whole string a bunch of times and that takes allocations. I get screwed over by the fact that strings are immutable in Julia. I've considered working with vectors of
The challenge with this approach is that you still need to remove the markup style tags I guess one thing worth mentioning is that I don't see Term processing huge amounts of text. It's to produce nice output for humans and there's only so much reading a human can do. The styling part is also one of the most expensive parts. So it's mostly about sparingly producing nice terminal output in you code and it would likely add a few milliseconds to runtime. It's still worth improving performance, especially when dealing with things like progressbars that are refreshed at 60Hz, but it might not be worth obsessing over it (for now).
Thanks! I'm looking forward to see what you make of it!. For the time being it will be mostly about performance improvements and bug fixes, but in the future I will start adding new features like |
I love this repo!
But there's some easy perf steps to implement without too much hassle if you read the manual
Some of the trickier ones (but hoo boy, taking like 5s to print the
make_logo
:/ ) can also be found here - they should help out a ton for many of the use cases that you are using.The text was updated successfully, but these errors were encountered: