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

Always maintain JSON stack pointer #65

Merged
merged 1 commit into from
Nov 27, 2024
Merged

Always maintain JSON stack pointer #65

merged 1 commit into from
Nov 27, 2024

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Nov 25, 2024

Previously, we used to populate the JSON stack pointer only under the semantics of AllowDuplicateNames(false). The argument made at the time was that the stack pointer becomes imprecise if there are duplicate names and that someone might want to disable duplicate name checks for the sake of performance in which case the logic to maintain the name stack becomes an unnecessary burden if the user does not care about ever retrieving the stack.

However, preserving the stack pointer is important for providing good errors and v1 has functionally always operated under AllowDuplicateNames(true) semantics. Thus, in order to preserve good errors in v1, always maintain the name stack needed to produce a JSON pointer.

Previously, we used to populate the stack pointer only under
the semantics of AllowDuplicateNames(false).
The argument made at the time was that the stack pointer
becomes imprecise if there are duplicate names and
that someone might want to disable duplicate name checks
for the sake of performance in which case the logic
to maintain the name stack becomes an unnecessary burden
if the user does not care about ever retrieving the stack.

However, preserving the stack pointer is important for
providing good errors and v1 has functionally always
operated under AllowDuplicateNames(false) semantics.
Thus, in order to preserve good errors in v1,
always maintain the name stack needed to produce a JSON pointer.
@dsnet
Copy link
Collaborator Author

dsnet commented Nov 25, 2024

For historical review, here's when we last talked about this behavior: https://youtu.be/Y9Me5UzDYTA?feature=shared&t=370

For the sake of good v1 compatibility, this PR changes course on a decision we have previously made.

@dsnet dsnet changed the title Always update stack pointer Always maintain JSON stack pointer Nov 25, 2024
Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

Is there a performance impact to the changes?

@dsnet
Copy link
Collaborator Author

dsnet commented Nov 25, 2024

Is there a performance impact to the changes?

According to the recorded Meet call, this will make things 5-10% slower if AllowDuplicateNames(true) (which is the default for v1). Note that AllowDuplicateNames(false) (which is the default for v2) will be unaffected.

@dsnet dsnet merged commit 9802db0 into master Nov 27, 2024
8 checks passed
dsnet added a commit that referenced this pull request Dec 8, 2024
In #65, we always populate the JSON pointer stack.
Thus, there is no need to use the fallback logic of encoding
the missing name with the member index.
dsnet added a commit that referenced this pull request Dec 8, 2024
In #65, we always populate the JSON pointer stack.
Thus, there is no need to use the fallback logic of encoding
the missing name with the member index.
@dsnet dsnet deleted the stack-pointer branch December 8, 2024 08:21
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