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
Pairs#move_cursor is slow down iter #784
Comments
How about feature-guarding it? It'll be disabled by default -- if someone needs it, they can enable that feature? |
Or change API like peekable or flatten, to make a special iterator? pairs.locatable().next() This will make a |
@huacnlee yes, that's perhaps simpler in the sense that the combination of possible feature flags doesn't increase more. Would you like to open a PR with this fix? |
I have trying to find other way to solve it. |
…e performance issues. Resolve pest-parser#784 Ref: https://github.com/rust-lang/rust/blob/1.67.0/src/tools/rust-analyzer/crates/ide-db/src/line_index.rs Benchmark result: ``` pair.line_col time: [11.032 µs 11.653 µs 12.461 µs] position.line_col time: [219.32 µs 224.17 µs 229.99 µs] pairs nested iter time: [2.0168 ms 2.0381 ms 2.0725 ms] pairs flatten iter time: [4.5973 µs 4.6132 µs 4.6307 µs] ```
…ate and `Pair::line_col` performance. Resolve pest-parser#784 Ref: https://github.com/rust-lang/rust/blob/1.67.0/src/tools/rust-analyzer/crates/ide-db/src/line_index.rs Benchmark result: ``` pair.line_col time: [11.032 µs 11.653 µs 12.461 µs] position.line_col time: [219.32 µs 224.17 µs 229.99 µs] pairs nested iter time: [2.0168 ms 2.0381 ms 2.0725 ms] pairs flatten iter time: [4.5973 µs 4.6132 µs 4.6307 µs] ```
…ate and `Pair::line_col` performance. Resolve pest-parser#784 Ref: https://github.com/rust-lang/rust/blob/1.67.0/src/tools/rust-analyzer/crates/ide-db/src/line_index.rs Benchmark result: ``` pair.line_col time: [11.032 µs 11.653 µs 12.461 µs] position.line_col time: [219.32 µs 224.17 µs 229.99 µs] pairs nested iter time: [2.0168 ms 2.0381 ms 2.0725 ms] pairs flatten iter time: [4.5973 µs 4.6132 µs 4.6307 µs] ```
…ate and `Pair::line_col` performance. Resolve pest-parser#784 Ref: https://github.com/rust-lang/rust/blob/1.67.0/src/tools/rust-analyzer/crates/ide-db/src/line_index.rs Benchmark result: ``` pair.line_col time: [11.032 µs 11.653 µs 12.461 µs] position.line_col time: [219.32 µs 224.17 µs 229.99 µs] pairs nested iter time: [2.0168 ms 2.0381 ms 2.0725 ms] pairs flatten iter time: [4.5973 µs 4.6132 µs 4.6307 µs] ```
…ext` and `Pair::line_col` performance. (#785) * Add benchmark test for nested and flatten iterate all pairs. For issue #784 * Add `LineIndex` instead of `Pairs::move_cursor` to improve Pairs iterate and `Pair::line_col` performance. Resolve #784 Ref: https://github.com/rust-lang/rust/blob/1.67.0/src/tools/rust-analyzer/crates/ide-db/src/line_index.rs Benchmark result: ``` pair.line_col time: [11.032 µs 11.653 µs 12.461 µs] position.line_col time: [219.32 µs 224.17 µs 229.99 µs] pairs nested iter time: [2.0168 ms 2.0381 ms 2.0725 ms] pairs flatten iter time: [4.5973 µs 4.6132 µs 4.6307 µs] ``` * Fix `Pair#into_inner` to ref `line_index`. * Fix LineIndex for support utf8 char. And update benchmark result. * Add benchmark result for 10K times iter for line_col.
Hi @tomtau,
I am very sorry about that. 😥
I have found
Pairs#iter
performance issue when we merged #754.Because when we iter pairs, each iter next will called
Position#line_col
once to move cursor. That will slow down the iter .Especially that, in sometimes we just need get a little pair's line,col, not all of pairs. So to do this is not value of money.
By my test:
So we need decide to how to do, remove it or find some solution to fix that.
The text was updated successfully, but these errors were encountered: