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

Add span information for TOML imports #1949

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Conversation

yannham
Copy link
Member

@yannham yannham commented Jun 10, 2024

This PR uses a feature of the toml crate allowing to embed span information into the deserialized data (imported from Nickel). This makes it possible to give nice error messages and point to within a TOML file when the application of a Nickel contract to an existing TOML configuration fails, or in case of non-mergeable values.

Doing so requires a bit of boilerplate and brings an additional crate in (although small). It can also impact deserialization performance, because we need to first deserialize in an intermediate TOML-like datastructure. For those reasons, spanned deserialization has been gated by the spanned-deser feature, which is enabled by default, but can be disabled if this isn't useful.

@github-actions github-actions bot temporarily deployed to pull request June 10, 2024 16:30 Inactive
@yannham yannham force-pushed the feat/spanned-toml-values branch from 83294f1 to 7b1f31a Compare June 10, 2024 17:54
@github-actions github-actions bot temporarily deployed to pull request June 10, 2024 17:57 Inactive
@yannham yannham force-pushed the feat/spanned-toml-values branch from 7b1f31a to f3dc2f3 Compare June 10, 2024 18:16
@github-actions github-actions bot temporarily deployed to pull request June 10, 2024 18:21 Inactive
@yannham yannham force-pushed the feat/spanned-toml-values branch from f3dc2f3 to b144353 Compare June 10, 2024 19:41
@github-actions github-actions bot temporarily deployed to pull request June 10, 2024 19:44 Inactive
@yannham yannham force-pushed the feat/spanned-toml-values branch from b144353 to 3874d05 Compare June 11, 2024 08:19
@github-actions github-actions bot temporarily deployed to pull request June 11, 2024 08:22 Inactive
This commits use a feature of the toml crate allowing to embed span
information into the deserialized data (imported from Nickel). This
makes it possible to give nice error messages and point to within a TOML
file when the application of a Nickel contract to an existing TOML
configuration fails, or in case of unmergeable values.

Doing so requires a bit of boilerplate and brings an additional crate in
(although small). It can also impact deserialization performance,
because we need to first deserialize in an intermediate TOML-like
datastructure. For those reasons, spanned deserialization has been gated
by the `spanned-deser` feature, which is enabled by default, but can be
disabled if this isn't useful.
@yannham yannham force-pushed the feat/spanned-toml-values branch from 3874d05 to d91ee15 Compare June 11, 2024 08:32
@github-actions github-actions bot temporarily deployed to pull request June 11, 2024 08:35 Inactive
@yannham yannham marked this pull request as ready for review June 11, 2024 11:59
@yannham yannham requested review from jneem and ErinvanderVeen June 11, 2024 11:59
@yannham yannham added this to the Next minor (1.8) milestone Jun 11, 2024
Copy link
Member

@jneem jneem left a comment

Choose a reason for hiding this comment

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

I do wonder whether it's worth the extra feature -- I'd be surprised if there's a measurable impact on performance or binary size. I guess for yaml/json there might be a bigger difference...

@ErinvanderVeen
Copy link
Contributor

ErinvanderVeen commented Jun 12, 2024

I do wonder whether it's worth the extra feature -- I'd be surprised if there's a measurable impact on performance or binary size. I guess for yaml/json there might be a bigger difference...

I do think it's worth the extra feature. There is a tendency to blow up the dependencies of any given crate. And since the code for when this feature is disabled is so small, why not hide it behind a feature flag. I approve.

I would like to see some "real" performance measurements though.

@yannham
Copy link
Member Author

yannham commented Jun 12, 2024

Actual measurement is the path forward, yes. In the meantime, another parameter is that the #[cfg..] attributes are really minimal and easy to insert in this case, so it doesn't cost too much to keep it a feature for now, I think.

@yannham yannham added this pull request to the merge queue Jun 12, 2024
Merged via the queue into master with commit 808b268 Jun 12, 2024
5 checks passed
@yannham yannham deleted the feat/spanned-toml-values branch June 12, 2024 08:43
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.

3 participants