Skip to content
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

logging: provide tree-sitter parsing and query time #940

Open
matu3ba opened this issue Oct 31, 2021 · 3 comments
Open

logging: provide tree-sitter parsing and query time #940

matu3ba opened this issue Oct 31, 2021 · 3 comments
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors

Comments

@matu3ba
Copy link

matu3ba commented Oct 31, 2021

Describe your feature request

Provide very simple logging for tree-sitter on INFO/-vvv, so users can estimate expections of tree-sitter performance: 1. parsing and query time can be printed separately.
As of now, tree-sitter timings are not logged at all: hx -vvv ir.cpp of ir.cpp shows only content from helix_lsp::transport and mio::poll.

Details truncated to 125 symbols line length, because some stuff is giantic in output even on only opening files. The same output uncovered bug #941.

2021-10-30T14:04:31.296 mio::poll [TRACE] registering event source with poller: token=Token(1), interests=READABLE | WRITABLE
2021-10-30T14:04:31.296 mio::poll [TRACE] registering event source with poller: token=Token(2), interests=READABLE | WRITABLE
2021-10-30T14:04:31.296 mio::poll [TRACE] registering event source with poller: token=Token(3), interests=READABLE | WRITABLE
2021-10-30T14:04:31.296 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"text
2021-10-30T14:04:31.297 mio::poll [TRACE] registering event source with poller: token=Token(4), interests=READABLE | WRITABLE
2021-10-30T14:04:31.297 mio::poll [TRACE] registering event source with poller: token=Token(5), interests=READABLE | WRITABLE
2021-10-30T14:04:31.297 mio::poll [TRACE] registering event source with poller: token=Token(0), interests=READABLE
2021-10-30T14:04:31.297 mio::poll [TRACE] registering event source with poller: token=Token(1), interests=READABLE
2021-10-30T14:04:31.309 helix_lsp::transport [ERROR] err <- "I[14:04:31.309] clangd version 12.0.1\n"
2021-10-30T14:04:31.309 helix_lsp::transport [ERROR] err <- "I[14:04:31.309] PID: 805639\n"
2021-10-30T14:04:31.309 helix_lsp::transport [ERROR] err <- "I[14:04:31.309] Working directory: $HOME/dev/git/zig/zig/src/sta
2021-10-30T14:04:31.309 helix_lsp::transport [ERROR] err <- "I[14:04:31.309] argv[0]: clangd\n"
2021-10-30T14:04:31.309 helix_lsp::transport [ERROR] err <- "I[14:04:31.309] Starting LSP over stdin/stdout\n"
2021-10-30T14:04:31.309 helix_lsp::transport [ERROR] err <- "I[14:04:31.309] <-- initialize(0)\n"
2021-10-30T14:04:31.310 helix_lsp::transport [ERROR] err <- "I[14:04:31.310] --> reply:initialize(0) 0 ms\n"
2021-10-30T14:04:31.310 helix_lsp::transport [INFO] <- {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"
2021-10-30T14:04:31.310 helix_lsp::transport [INFO] <- {"capabilities":{"astProvider":true,"callHierarchyProvider":true,"code
2021-10-30T14:04:31.310 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2021-10-30T14:04:31.310 helix_lsp::transport [ERROR] err <- "I[14:04:31.310] <-- initialized\n"
2021-10-30T14:04:31.313 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocume
2021-10-30T14:04:31.320 helix_lsp::transport [ERROR] err <- "I[14:04:31.320] <-- textDocument/didOpen\n"
2021-10-30T14:04:31.323 helix_lsp::transport [ERROR] err <- "I[14:04:31.323] Failed to find compilation database for $HOME/de
2021-10-30T14:04:31.324 helix_lsp::transport [ERROR] err <- "I[14:04:31.324] ASTWorker building file $HOME/dev/git/zig/zig/sr
2021-10-30T14:04:31.324 helix_lsp::transport [ERROR] err <- "[$HOME/dev/git/zig/zig/src/stage1]\n"
2021-10-30T14:04:31.324 helix_lsp::transport [ERROR] err <- "/usr/bin/clang $HOME/dev/git/zig/zig/src/stage1/ir.cpp -fsyntax-
2021-10-30T14:04:32.289 helix_lsp::transport [ERROR] err <- "I[14:04:32.289] --> textDocument/publishDiagnostics\n"
2021-10-30T14:04:32.289 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{
2021-10-30T14:04:36.395 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"shutdown","params":null,"id":1}
2021-10-30T14:04:36.395 helix_lsp::transport [INFO] <- {"id":1,"jsonrpc":"2.0","result":null}
2021-10-30T14:04:36.395 helix_lsp::transport [INFO] <- null
2021-10-30T14:04:36.395 helix_lsp::transport [ERROR] err <- "I[14:04:36.395] <-- shutdown(1)\n"
2021-10-30T14:04:36.396 helix_lsp::transport [ERROR] err <- "I[14:04:36.395] --> reply:shutdown(1) 0 ms\n"
2021-10-30T14:04:36.396 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"exit","params":null}
2021-10-30T14:04:36.396 helix_lsp::transport [ERROR] err <- "I[14:04:36.396] <-- exit\n"
2021-10-30T14:04:36.396 helix_lsp::transport [ERROR] err <- "I[14:04:36.396] LSP finished, exiting with status 0\n"
2021-10-30T14:04:36.409 helix_lsp::transport [ERROR] err: <- StreamClosed
2021-10-30T14:04:36.409 mio::poll [TRACE] deregistering event source from poller
2021-10-30T14:04:36.409 helix_lsp::transport [ERROR] err: <- StreamClosed
2021-10-30T14:04:36.409 mio::poll [TRACE] deregistering event source from poller
2021-10-30T14:04:36.419 mio::poll [TRACE] deregistering event source from poller
2021-10-30T14:04:36.419 mio::poll [TRACE] deregistering event source from poller
2021-10-30T14:04:36.419 mio::poll [TRACE] deregistering event source from poller
@matu3ba matu3ba added the C-enhancement Category: Improvements label Oct 31, 2021
@kirawi kirawi added A-tree-sitter Area: Tree-sitter E-good-first-issue Call for participation: Issues suitable for new contributors labels Oct 31, 2021
dariooddenino added a commit to dariooddenino/helix that referenced this issue Jul 22, 2022
@dariooddenino
Copy link
Contributor

I'm not familiar with tree-sitter, so I'm very unsure of these log placements (especially the query one):

dariooddenino@2fd1ab1

@the-mikedavis
Copy link
Member

I think the query one may be logging the query analysis time rather than the time it takes to run the query (though I'd have to dig further to confirm). You should consult the tree-sitter-cli code in the tree-sitter repo https://github.com/tree-sitter/tree-sitter/tree/1f1b1eb4501ed0a2d195d37f7de15f72aa10acd0 to see how it gathers the metrics.

@dariooddenino
Copy link
Contributor

I think the query one may be logging the query analysis time rather than the time it takes to run the query (though I'd have to dig further to confirm). You should consult the tree-sitter-cli code in the tree-sitter repo https://github.com/tree-sitter/tree-sitter/tree/1f1b1eb4501ed0a2d195d37f7de15f72aa10acd0 to see how it gathers the metrics.

Yeah, I had a little more time to check how tree-sitter work and helix code, and that spot has nothing to do with the query execution time.
Still need to pinpoint exactly the point, but I think Syntax::update is probably a good start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors
Projects
None yet
Development

No branches or pull requests

4 participants