-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
PathMarkupParser rewrite #1661
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
PathMarkupParser rewrite #1661
Conversation
|
Thanks for this @Gillibald - looks much better than before, the only thing I'm worried about is that it looks to be creating a lot of objects during parsing, I'm a bit worried about the memory traffic it will introduce. It might be worth creating some benchmarks with Benchmark.Net to see what's happening there. Don't know what you think @jkoritzinsky? |
|
I'm always up for more memory benchmarks! It's always better to have quantitative data when possible. |
|
Will do some profiling. Converting to a PathGeometry introduces a bigger memory footprint but will habe a look where is room for improvements. |
|
Yeah, I'm sure |
|
Looks like I am not the right person to write some benchmarks fot the new component. I probably need some help or atleast some advice. |
|
You'll probably want to use |
|
@Gillibald Here's the documentation for testing memory traffic: https://www.jetbrains.com/help/dotmemory-unit/Checking_Memory_Traffic.html |
|
Will have a look. Thanks for your help. |
|
@Gillibald I hope you don't mind but I just pushed a benchmark for It's hard to tell how much of that is from the parser and how much is from the |
|
Given that, should we merge this? Or did you want to take a look at the benchmark first? |
|
One way to test how much memory is used by the parser might be:
This might be nice as it would also allow creation of |
|
I did exactly the same as you did with the benchmark. Wasnt sure how to compare the results :) Your proposed additions make so much sense and I will implement them to get more flexibility. We even get more insides what the actual memory usage of the parser itself. |
|
This is my current benchmark result: BenchmarkDotNet=v0.10.8, OS=Windows 10.0.17134
Processor=Intel Core i7-4500U CPU 1.80GHz (Haswell), ProcessorCount=4
Frequency=2338342 Hz, Resolution=427.6534 ns, Timer=TSC
dotnet cli version=2.1.300
[Host] : .NET Core 4.6.26328.01, 64bit RyuJIT
DefaultJob : .NET Core 4.6.26328.01, 64bit RyuJIT
|
|
Ok, that's not too bad. I think that maybe with the new |
|
.Net Core 2.1 will probably improve a lot |
|
I can go through and Span-ify in a new PR. The Span-ification of the PathMarkupParser will be blocked on the same bug that #1668 is blocked on. |
|
Merged! Thanks @Gillibald ! |
|
I started prototyping a Span-ified version. I've included the benchmark results below. The perf change is insane! |
|
Looks promising👍The benefit is quit obvious. |
|
Result from my newest prototype: BenchmarkDotNet=v0.10.14, OS=Windows 10.0.17134
Intel Core i5-6300U CPU 2.40GHz (Skylake), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=2.1.300
[Host] : .NET Core 2.0.7 (CoreCLR 4.6.26328.01, CoreFX 4.6.26403.03), 64bit RyuJIT
DefaultJob : .NET Core 2.0.7 (CoreCLR 4.6.26328.01, CoreFX 4.6.26403.03), 64bit RyuJIT
I'll put out a PR with the Span-ified version in a bit. |
This PR changes the way how path markup is parsed in avalonia to make parsing more testable.
The current implementation just writes commands to a StreamGeometry.
The updated version produces PathGeometry instead of calling methods on the StreamGeometry directly. That way we can write better unit tests for the SVG spec.
The new parser uses a regex to split the path data into command tokens that hold all arguments specified in the data string between command identifiers. That way we can identify implicit commands and process them later.
Checklist:
Fixes #1606
Fixes #1640
Fixes #1659