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

make tracking for better error details optional (fixes #1009) #1013

Merged
merged 3 commits into from
May 1, 2024

Conversation

tomtau
Copy link
Contributor

@tomtau tomtau commented Apr 30, 2024

2.7.8 cargo bench:

http parser             time:   [321.39 µs 321.54 µs 321.70 µs]
json parser             time:   [20.382 µs 20.425 µs 20.484 µs]

2.7.9 cargo bench (baseline 2.7.8):

http parser             time:   [2.1007 ms 2.1013 ms 2.1020 ms]
                        change: [+552.62% +553.14% +553.59%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 7 outliers among 100 measurements (7.00%)
  1 (1.00%) high mild
  6 (6.00%) high severe

json parser             time:   [124.16 µs 124.19 µs 124.23 µs]
                        change: [+506.35% +507.34% +508.18%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 10 outliers among 100 measurements (10.00%)
  1 (1.00%) low mild
  6 (6.00%) high mild
  3 (3.00%) high severe

this PR fix when disabled (baseline 2.7.9):

http parser             time:   [378.87 µs 379.17 µs 379.72 µs]
                        change: [-81.966% -81.952% -81.929%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  5 (5.00%) high mild
  5 (5.00%) high severe

json parser             time:   [25.925 µs 25.935 µs 25.946 µs]
                        change: [-79.118% -79.105% -79.093%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 15 outliers among 100 measurements (15.00%)
  3 (3.00%) low severe
  4 (4.00%) low mild
  5 (5.00%) high mild
  3 (3.00%) high severe

@tomtau tomtau added the pr label Apr 30, 2024
@tomtau tomtau requested a review from a team as a code owner April 30, 2024 09:11
@tomtau tomtau requested review from NoahTheDuke and removed request for a team April 30, 2024 09:11
Copy link
Contributor

coderabbitai bot commented Apr 30, 2024

Warning

Rate Limit Exceeded

@tomtau has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 6 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 23f6082 and a9e08b6.

Walkthrough

The changes across various files focus on introducing the set_error_detail function to manage error details in parsing, impacting error handling and token matching based on error detail settings, enhancing debugging capabilities.

Changes

Files Change Summary
pest/src/parser_state.rs Added set_error_detail function for error detail control, enabled field in ParseAttempts, and logic based on parse_attempts.enabled.
pest/src/parser_state.rs Modified error handling and token matching functions based on parse_attempts.enabled.

🐰✨ A whimsical verse from a rabbit's burrow,
To celebrate the code that we now follow.
With a hop and a skip, errors we'll detail,
In the land of code, we shall never fail.
Toggle on, toggle off, with ease we sail,
Through bugs and features, we prevail! 🌟📜


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tomtau tomtau linked an issue Apr 30, 2024 that may be closed by this pull request
@tomtau
Copy link
Contributor Author

tomtau commented Apr 30, 2024

@EmirVildanov FYI this disables tracking for detailed errors to reduce the performance overhead, but it can still be optionally enabled via set_error_detail

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

pest/src/parser_state.rs Outdated Show resolved Hide resolved
tomtau and others added 2 commits April 30, 2024 17:15
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Member

@NoahTheDuke NoahTheDuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good. My only thought is: should these checks be in the impacting functions instead of at the call-sites? Seeing if new_state.parse_attempts.enabled { try_add_rule_to_stack(&mut new_state); } multiple times (along with the others) gives me pause.

I don't know the performance implications of unnecessary function calls, so I'll trust your judgement here, given that we're trying to fix a performance issue. This isn't such a big deal that we should worsen performance more for a little more clarity.

@tomtau
Copy link
Contributor Author

tomtau commented May 1, 2024

@NoahTheDuke yeah, I was thinking that; I went for checking at call-sites, because 1) it was easier to cross-check against the original PR's modifications in the parser state, 2) some of those calls had a String allocation before that guarded call (maybe the compiler could inline functions there and optimize away those allocations, maybe not).
Anyway, this is open to potential follow-up PRs with more refactoring and optimization work.

@tomtau tomtau merged commit f090ec1 into pest-parser:master May 1, 2024
9 checks passed
@tomtau tomtau deleted the disable-better-error branch May 1, 2024 12:20
@klensy
Copy link

klensy commented May 3, 2024

With a release of 2.7.10, can 2.7.9 be yanked? Regression was quite big to actually prevent users to use it.

@tomtau
Copy link
Contributor Author

tomtau commented May 3, 2024

@klensy that makes sense, so 2.7.9 should be yanked now

renovate bot referenced this pull request in rosetta-rs/parse-rosetta-rs Jun 1, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [lalrpop](https://togithub.com/lalrpop/lalrpop) | build-dependencies |
patch | `0.20.0` -> `0.20.2` |
| [lalrpop-util](https://togithub.com/lalrpop/lalrpop) | dependencies |
patch | `0.20.0` -> `0.20.2` |
| [pest](https://pest.rs/)
([source](https://togithub.com/pest-parser/pest)) | dependencies | patch
| `2.7.9` -> `2.7.10` |
| [serde_json](https://togithub.com/serde-rs/json) | dependencies |
patch | `1.0.116` -> `1.0.117` |
| [winnow](https://togithub.com/winnow-rs/winnow) | dependencies | patch
| `0.6.7` -> `0.6.9` |

---

### Release Notes

<details>
<summary>lalrpop/lalrpop (lalrpop)</summary>

###
[`v0.20.2`](https://togithub.com/lalrpop/lalrpop/blob/HEAD/RELEASES.md#0202-2024-02-)

[Compare
Source](https://togithub.com/lalrpop/lalrpop/compare/0.20.1...0.20.2)

Special thanks to our newest maintainers, Daniel Burgener and Patrick
LaFontaine for helping to coordinate this release.

##### Features

- Lalrpop no longer depends on the `is-terminal` crate (thanks to
Kmeakin!)
- Better performance with the default lexer using the underlying
`regex-automata` crate (thanks to QuarticCat!)
- Allow the catch-all `_` case for token matching can now be set to a
higher precedence in match (thanks to fpoli!)
-   Fewer clippy lints triggered in generated code
-   Lalrpop now traverses symlinks to find .lalrpop files(thanks mbid!)
- Lalrpop now supports block comments including nestings(thanks
seanbright!)

##### Bugfixes

- Lalrpop now uses the ascii-aware space regex when the unicode feature
is not enabled (thanks to QuarticCat!)
- Dangling symlinks in crate no longer cause build failure (thanks to
legeana
    for the report!)
- Unicode is now set as a default feature in lalrpop-util to align with
    lalrpop's defaults

##### Compatibility note

-   MSRV increased to `1.70`.
- `process_root_unconditionally` now correctly lints as having been
deprecated.
- Internal types which lead with a `__` and should not be relied upon
are no longer publicly exposed (thanks to arnaudgolfouse!)
-   Lalrpop files containing a space in their name now return an error.

###
[`v0.20.1`](https://togithub.com/lalrpop/lalrpop/blob/HEAD/RELEASES.md#0201-2024-02-)

[Compare
Source](https://togithub.com/lalrpop/lalrpop/compare/0.20.0...0.20.1)

Yanked

</details>

<details>
<summary>pest-parser/pest (pest)</summary>

###
[`v2.7.10`](https://togithub.com/pest-parser/pest/releases/tag/v2.7.10)

[Compare
Source](https://togithub.com/pest-parser/pest/compare/v2.7.9...v2.7.10)

#### What's Changed

- make tracking for better error details optional (fixes
[#&#8203;1009](https://togithub.com/pest-parser/pest/issues/1009)) by
[@&#8203;tomtau](https://togithub.com/tomtau) in
[https://github.com/pest-parser/pest/pull/1013](https://togithub.com/pest-parser/pest/pull/1013)

There was a performance regression in 2.7.9 due to the overhead from
tracking for better error details. This is now disabled by default, but
if you wish to use it, you can enable it via the
`pest::set_error_detail(true)` call (before your parsing code starts).

**Full Changelog**:
pest-parser/pest@v2.7.9...v2.7.10

#### Warning: Semantic Versioning

Note that the node tag feature in 2.6.0 was a technically
semver-breaking change even though it is a backwards-compatible /
non-breaking change in the meta-grammar. There may be similar
non-breaking changes to the meta-grammar between minor versions in the
future. These non-breaking changes, however, may translate into
semver-breaking changes due to the additional variants propagated from
the generated `Rule` enum.

This new feature caused issues in some Cargo version resolution
situations where Cargo mixed different versions of pest dependencies.
For this reason, these "grammar non-breaking but semver-breaking"
changes are now available only under the "grammar-extras" feature flag.
If you would like to use node tags (or other future grammar features),
you can do so by enabling this flag on the pest_derive crate in your
Cargo.toml:

    ...
    pest_derive = { version = "2.7", features = ["grammar-extras"] }

</details>

<details>
<summary>serde-rs/json (serde_json)</summary>

###
[`v1.0.117`](https://togithub.com/serde-rs/json/releases/tag/v1.0.117)

[Compare
Source](https://togithub.com/serde-rs/json/compare/v1.0.116...v1.0.117)

- Resolve unexpected_cfgs warning
([#&#8203;1130](https://togithub.com/serde-rs/json/issues/1130))

</details>

<details>
<summary>winnow-rs/winnow (winnow)</summary>

###
[`v0.6.9`](https://togithub.com/winnow-rs/winnow/blob/HEAD/CHANGELOG.md#069---2024-05-28)

[Compare
Source](https://togithub.com/winnow-rs/winnow/compare/v0.6.8...v0.6.9)

##### Compatibility

-   Bump MSRV to 1.65

##### Features

-   Add `Debug` impls for `stream::Stateful` and `stream::Recoverable`

###
[`v0.6.8`](https://togithub.com/winnow-rs/winnow/blob/HEAD/CHANGELOG.md#068---2024-05-06)

[Compare
Source](https://togithub.com/winnow-rs/winnow/compare/v0.6.7...v0.6.8)

##### Features

-   Support `&mut [impl Parser]` within `alt`

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 5am on the first day of the
month" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/rosetta-rs/parse-rosetta-rs).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNzcuOCIsInVwZGF0ZWRJblZlciI6IjM3LjM3Ny44IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

perf regression in 2.7.9
3 participants