-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Split SyntaxNode into TreeNode & SyntaxData #193
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems pretty reasonable. But I'm curious how much this helps you downstream? It looks like you don't get much functionality with TreeNode{SomeOtherNodeData}
as the methods are still specialized to SyntaxNode
here.
In terms of benchmarks, there's not really any formal benchmarks at this point. As a rough guide, converting all the way to Expr
should be about 5x faster than the existing parser. You could try the following code before and after the changes? (I'll PR this to test/benchmark.jl shortly. I'm not sure what reliable infrastructure we have for benchmarking automatically...)
using BenchmarkTools
using JuliaSyntax
include("test_utils.jl")
function concat_base()
basedir = joinpath(Sys.BINDIR, "..", "share", "julia", "base")
io = IOBuffer()
for f in find_source_in_path(basedir)
write(io, read(f, String))
println(io)
end
return String(take!(io))
end
all_base_code = concat_base()
b_ParseStream = @benchmark JuliaSyntax.parse!(JuliaSyntax.ParseStream(all_base_code), rule=:toplevel)
b_GreenNode = @benchmark JuliaSyntax.parseall(JuliaSyntax.GreenNode, all_base_code)
b_SyntaxNode = @benchmark JuliaSyntax.parseall(JuliaSyntax.SyntaxNode, all_base_code)
b_Expr = @benchmark JuliaSyntax.parseall(Expr, all_base_code)
@info "Benchmarks" ParseStream=b_ParseStream GreenNode=b_GreenNode SyntaxNode=b_SyntaxNode Expr=b_Expr
We might still need to broaden some other methods but I was planning to do that focally as I build out functionality. For now this is all I need, and it seems to clearly pave the way for elegantly handling both typed and untyped syntax trees. We can wait to merge this if you prefer that I have JuliaDebug/Cthulhu.jl#345 re-implemented. The only thing I really need to know is whether this approach is acceptable, otherwise I'll quit on this approach and start working on a different one. But I'm guessing from your comment above is that you're fine with this, and might simply prefer to take it when there won't be a lot of further changes. |
Thanks for the benchmarks; the last three are unchanged, but surprisingly there's a ~30% regression on the first one, which drops to ~15% if I add |
That would be troubling, but it's very confusing because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should go ahead and merge this if you think it's the right way forward.
It's surprisingly non-breaking ❤️
(I would like to understand whether the performance regression is real, it does bother me and it should be impossible. But I don't know if I have space in my head to dig deep into it right now.) |
Before I merge:
|
These two files are particularly affected by recent and upcoming changes (e.g., #193). This adds a bit more coverage as a guard against breakage.
These two files are particularly affected by recent and upcoming changes (e.g., #193). This adds a bit more coverage as a guard against breakage.
Co-authored-by: c42f <chris42f@gmail.com>
I'm not quite sure what was happening before, but today when I run the benchmarks there are no signs of trouble. |
Codecov Report
@@ Coverage Diff @@
## main #193 +/- ##
==========================================
+ Coverage 94.86% 94.87% +0.01%
==========================================
Files 15 15
Lines 3776 3789 +13
==========================================
+ Hits 3582 3595 +13
Misses 194 194
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Cool this makes sense! The only thing I could think of was that perhaps the |
Closes #192
Pleasantly straightforward. Note that this object is slightly bigger since
val
has basically become two fields now, one for children and one for the actual value. I hope that's a tolerable increase.I haven't timed anything to see if there are any regressions. (If constprop works, I think there won't be any.) Is there a task I should use?