-
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
chore(test): Break up integration tests per language #859
Conversation
While trying to solve some failing formatting tests for #845 I noticed some unusual slowness from the test cases. Once tests were broken up, it seems that the OCaml tests perform significantly worse than other languages and #519 may still be a problem (ocaml iface test is commented out for this PR, so ignore test failure): $ cargo nextest run
Compiling topiary-cli v0.6.0 (/Users/mkatychev/Documents/rust/topiary/topiary-cli)
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.90s
Starting 32 tests across 3 binaries (run ID: d0702afd-a92f-45ff-b1cf-1e3266a708c9, nextest profile: default)
PASS [ 0.618s] topiary-cli::cli-tester test_cfg
PASS [ 0.805s] topiary-cli::cli-tester test_fmt_stdin
PASS [ 0.815s] topiary-cli::cli-tester test_fmt_invalid
PASS [ 0.820s] topiary-cli::cli-tester test_fmt_dir
PASS [ 0.851s] topiary-cli::cli-tester test_fmt_stdin_query_fallback
PASS [ 0.856s] topiary-cli::cli-tester test_fmt_stdin_query
PASS [ 0.908s] topiary-cli::cli-tester test_fmt_files_query_fallback
PASS [ 0.921s] topiary-cli::cli-tester test_fmt_files
PASS [ 0.316s] topiary-cli::cli-tester test_vis
PASS [ 0.109s] topiary-cli::sample-tester test_coverage::coverage_input_json
PASS [ 0.308s] topiary-cli::cli-tester test_vis_invalid
PASS [ 0.179s] topiary-cli::sample-tester test_coverage::coverage_input_ocamllex
PASS [ 1.112s] topiary-cli::sample-tester test_coverage::coverage_input_toml
PASS [ 2.171s] topiary-cli::sample-tester test_coverage::coverage_input_css
PASS [ 0.986s] topiary-cli::sample-tester test_coverage::coverage_input_tree_sitter_query
PASS [ 2.153s] topiary-cli::sample-tester test_coverage::coverage_input_openscad
PASS [ 0.129s] topiary-cli::sample-tester test_fmt::fmt_input_json
PASS [ 2.593s] topiary-cli::sample-tester formatted_query_tester
PASS [ 0.619s] topiary-cli::sample-tester test_fmt::fmt_input_bash
PASS [ 1.022s] topiary-cli::sample-tester test_fmt::fmt_input_css
PASS [ 0.103s] topiary-cli::sample-tester test_fmt::fmt_input_ocamllex
PASS [ 0.197s] topiary-cli::sample-tester test_fmt::fmt_input_openscad
PASS [ 0.135s] topiary-cli::sample-tester test_fmt::fmt_input_toml
PASS [ 1.356s] topiary-cli::sample-tester test_fmt::fmt_input_nickel
PASS [ 0.355s] topiary-cli::sample-tester test_fmt::fmt_input_tree_sitter_query
PASS [ 2.349s] topiary-cli::sample-tester test_fmt::fmt_input_ocaml
PASS [ 2.314s] topiary-cli::sample-tester test_fmt::fmt_queries
PASS [ 5.225s] topiary-cli::sample-tester test_fmt::fmt_input_ocaml_interface
PASS [ 8.159s] topiary-cli::sample-tester test_coverage::coverage_input_nickel
PASS [ 26.421s] topiary-cli::sample-tester test_coverage::coverage_input_bash
SLOW [> 60.000s] topiary-cli::sample-tester test_coverage::coverage_input_ocaml
SLOW [> 60.000s] topiary-cli::sample-tester test_coverage::coverage_input_ocaml_interface
SLOW [>120.000s] topiary-cli::sample-tester test_coverage::coverage_input_ocaml
SLOW [>120.000s] topiary-cli::sample-tester test_coverage::coverage_input_ocaml_interface
PASS [ 147.559s] topiary-cli::sample-tester test_coverage::coverage_input_ocaml
SLOW [>180.000s] topiary-cli::sample-tester test_coverage::coverage_input_ocaml_interface
SLOW [>240.000s] topiary-cli::sample-tester test_coverage::coverage_input_ocaml_interface
FAIL [ 261.056s] topiary-cli::sample-tester test_coverage::coverage_input_ocaml_interface
--- STDOUT: topiary-cli::sample-tester test_coverage::coverage_input_ocaml_interface ---
running 1 test
test test_coverage::coverage_input_ocaml_interface has been running for over 60 seconds
test test_coverage::coverage_input_ocaml_interface ... FAILED
failures:
failures:
test_coverage::coverage_input_ocaml_interface
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 21 filtered out; finished in 261.04s The
|
3311e6b
to
283e501
Compare
Going off of the tree-sitter tips for performance, the tree-sitter-ocaml base grammar has about ten times the underperformant example's state counts:
with the ts-ocaml state cont being about 10x and large state count a 5x:
with operators and expressions having a rather large state count:
|
I've had a quick look through this and, in principle, I really like the idea of using a macro to abstract this 👍 Before reviewing this more thoroughly, I have some initial thoughts:
|
@Xophmeister that's my conclusion, if you see the post above, ocaml AST state count is about 10x that of the rust repo. I think the definitions in the ocaml
Here's one of the recent main commit test durations (228s):
Yes that's very odd, not sure what to make of it, seems to be some sort of linker error. Hopefully it wasn't EDIT: I wonder if it has something to do with the lazy fetching of the dylib grammar since there may be multiple |
Continued from #859 (comment): A good illustration of this is to call |
Thanks for this analysis 🙏 Bear in mind that we are currently pinned to a version of It's also worth pointing out that Topiary largely is a consumer of the grammar. If we can patch this then we of course should, but the Topiary team doesn't have that kind of capacity at the moment. Of course, just to reiterate, that does not in any way diminish the usefulness of your analysis. |
I don't see anything in the changes to I don't know Footnotes
|
Going off @Xophmeister's suggestion of prefetching the grammars, seems the CI is now failing at that step, not sure how my changes could have impacted |
My takeaway from the ocaml performance is that as more grammars are added to the repo, whatever grammars topiary leverages means that their performance issues carry over on top of actual topiary specific logic. For new languages, I don't have any immediate solutions to this issue other than restricting additions based on an acceptable limit in duration of coverate/perf tests. In ocaml's case the recourse is limited to raising/fixing the issues upstream, dropping support (I'm not advocating for this), or downgrading it to a community grammar (so it's not in the hot path of testing). Long term perhaps moving community |
So this is a particularly weird error:
Building the TOML grammar failed because it's trying to link with the Rust build artefact, which has already been deleted! 🤷 I agree that I cannot see how your changes are causing this problem. Yet, other post-v0.6.0 PRs are not suffering from it. While I don't think it's your responsibility to fix, I'm reluctant to merge this PR until this Windows problem is resolved. That being said, I'm now strongly of the opinion that a race condition is the problem. Indeed, @nbacquey put in this code in topiary/topiary-cli/tests/cli-tester.rs Lines 20 to 47 in df1cfc3
Could you revert the CI change I suggested and try implementing something similar in your sample testing macros? (With my apologies for the wild goose chase!) (Meanwhile, I will try to look into a potential problem with parallel builds on Windows.)
We are considering separating queries into their own repositories, so they're not coupled to Topiary releases. This is still very much in the "thinking about" stage -- not even "planning" -- but it's definitely on our radar 👍 I think your point adds weight to this: The original thought was just simply for decoupling's sake. However, unburdening the tests from those dependencies is going to be worthwhile. Of course, that inversion will require us to rethink how we test in the absence of a real grammar. |
I'm definitely against merging this PR if it breaks CI, I'll take a look at the |
Thanks, @mkatychev 🙏
Serialising the builds on Windows seems to fix the problem (see #869). Hopefully doing something similar in your macros will do the same and we can merge 🤞 |
@mkatychev #869 has now merged; apologies for the delay. |
@Xophmeister merging it seems to have fixed the issue 🥳 |
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.
Looks great; thank you 🙏
chore(test): Break up integration tests per language
Related Issues: #519, #539
Description
mod test_fmt
andmod test_coverage
test modules with a macro generating the test functionstopiary/topiary-cli/tests/sample-tester.rs
Lines 79 to 92 in 68e5844
Checklist
Checklist before merging: