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

chore(deps): drop dependency on lexical #37

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

AlexTMjugador
Copy link
Contributor

@AlexTMjugador AlexTMjugador commented Oct 22, 2023

The lexical crate maintenance status has been called into question while being affected by several soundness issues, as explained in RUSTSEC-2023-0055. However, as far as I can see, we don't really need to use lexical in the GLSL preprocessor:

  • For parsing #version numbers, lexical didn't provide results that complied with my interpretation of the GLSL specification, which I explained in a code comment, and that I believe motivated a TODO item to move on from lexical. Moreover, as #version directives are expected to be infrequent (usually, at most once per translation unit), I don't think it's worth to bloat our dependencies with atoi(_simd|_radix10), as #version numbers are tiny 16-bit integers where SIMD and bitwise optimizations have a neglible performance impact, so these changes go for simplicity and use the INT and UINT token parsing routines to parse these.
  • For parsing floating point numbers, modern Rust stdlib versions ship a performant algorithm proposed by lexical's author, which negates previous performance gaps between both implementations. Therefore, just use the standard parsing functions in these cases.

As far as I am aware, these changes are not semver-breaking because the modified VersionError enum was never exposed outside of the lang-pp crate.

I'm also working on a PR to update all the dependencies to their latest versions, including syn, logos and lalrpop, to bring these crates up to the most used dependency versions in the ecosystem and reduce build time and dependency tree size. However, these updates are a bit more involved (I ran into issues like TedDriggs/darling#238 with the lang_util::Token derive macro), so I'll be completing the updates over the next days.

The `lexical` crate maintenance status has been called into question
while being affected by several soundness issues, as explained in
[`RUSTSEC-2023-0055`](https://rustsec.org/advisories/RUSTSEC-2023-0055).
However, as far as I can see, we don't really need to use `lexical` in
the GLSL preprocessor:

- For parsing `#version` numbers, `lexical` didn't provide results that
  complied with my interpretation of the GLSL specification, which I
  explained in a code comment, and that I believe motivated a TODO item
  to move on from `lexical`. Moreover, as `#version` directives are
  expected to be infrequent (usually, at most one per translation unit),
  I don't think it's worth to bloat our dependencies with
  `atoi(_simd|_radix10)`, as `#version` numbers are tiny 16-bit integers
  where SIMD and bitwise optimizations have a neglible performance
  impact, so these changes go for correctness and use the INT and UINT
  token parsing routines to parse these.
- For parsing floating point numbers, modern Rust stdlib versions ship
  a performant algorithm proposed by `lexical`'s author, which negate
  previous performance gaps between both implementations. Therefore,
  just use the standard parsing functions in these cases.

As far as I am aware, these changes are not semver-breaking because the
modified `VersionError` enum was never exposed outside of the `lang-pp`
crate.
Copy link
Owner

@alixinne alixinne left a comment

Choose a reason for hiding this comment

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

LGTM!

@alixinne alixinne merged commit 8a34d08 into alixinne:master Oct 30, 2023
4 checks passed
@AlexTMjugador AlexTMjugador deleted the deps/drop-lexical branch November 11, 2023 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants