Add Position metadata to the parser#6061
Add Position metadata to the parser#6061slrtbtfs wants to merge 24 commits intoprometheus:masterfrom
Conversation
|
We looked at the code a little and couldn't find the data race, maybe someone sees it or can think of a data race that may had been there all along, but only now triggers the race detector. |
|
Output of the race detector: https://gist.github.com/slrtbtfs/359c05c7a5f28c1df3f9d9a1b6be99c6 |
|
Data race has been found by Casey and Simon approx. at the same time. |
41c5c60 to
746b49b
Compare
8458451 to
f551356
Compare
|
Update: All AST Nodes have Position information now. There are still two edge cases where that the positions are not accurate:
|
|
The PR should be in a sane state now. |
simonpasquier
left a comment
There was a problem hiding this comment.
I'm that familiar with the promql code but here are some comments.
b5256dd to
e402759
Compare
Deprecate old file location API of the lexer and add new one Add File Option in lexer initialisation Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
ATM they are still populated with zeros Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Offset modifiers are not yet reflected in the syntax tree Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
|
The merge conflict should be resolved now. |
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
|
Is there any specific reason stopping this from being merged? |
|
sorry I don't think I will be able to provide a review here as I am focused on the cert rotation PR in Thanos. |
|
lgtm from an implementation side, @juliusv @brian-brazil @beorn7 are you happy with moving forward with this in general? As a side note we're going to be investigating a generated parser next, our investigation so far have shown that even if we go with that, the overwhelming majority of this PR would still be required (more comprehensive proposal in progress). |
|
Yeah, I haven't checked the implementation in detail, but in general I'm all for it. I'm very much looking forward to PromQL syntax highlighting and autocompletion :) |
Will be part of a separate PR Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
|
I guess @tomwilkie is way more qualified than I am to comment on this. |
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
|
Here are some benchmarks for this PR. https://gist.github.com/slrtbtfs/07fec8f8e023e70e50ee220c9bd29ca8 |
|
Looks like there is no performance hit. The number of allocations actually seems to have gone slightly down. |
|
The benchmarks above test the whole PromQL engine. Since the parser is only a small part of these workloads, the changes of this PR might get buried in the noise. I've added another benchmark (see #6355) , that exclusively tests the parser. Here a negative performance impact is visible, but not dramatic. It can be seen that the position logic adds 5 allocations per parser run. https://gist.github.com/slrtbtfs/e95ffda4b8cd12b77428d57ac2cdb774 |
|
I'd consider if the changes are lost in the noise, then all is good. |
|
Closed in favour of adding the features of this PR, after the parser has been replaced by a generated one. |
This aims to implement part one of proposal https://github.com/slrtbtfs/promql-lsp/blob/master/doc/proposals/2019_promql-parser-improvements.md
It introduces position metadata in the error messages and the AST.
Current state:
The AST is able to store position metadata but currently mostly uses zeros as placeholders.The last commit fills some of the position fields with real data. Unfortunately it triggers a data race. Despite staring at the code for quite a while I haven't been able to figure out the root cause of that race, so any help there would be appreciated.