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

When comparing Field.t values, avoid the conversion to bigint #14597

Closed
wants to merge 2 commits into from

Conversation

tizoc
Copy link
Member

@tizoc tizoc commented Nov 22, 2023

Explain your changes:

  • For Field.compare, perform the comparison in Rust instead of converting the values to bigints to compare them. More context here

Explain how you tested your changes:
*

Checklist:

  • Dependency versions are unchanged
    • Notify Velocity team if dependencies must change in CI
  • Modified the current draft of release notes with details on what is completed or incomplete within this project
  • Document code purpose, how to use it
    • Mention expected invariants, implicit constraints
  • Tests were added for the new behavior
    • Document test purpose, significance of failures
    • Test names should reflect their purpose
  • All tests pass (CI will check this if you didn't)
  • Serialized types are in stable-versioned modules
  • Does this close issues? List them
  • Closes #0000

@tizoc
Copy link
Member Author

tizoc commented Nov 22, 2023

!ci-build-me

@tizoc tizoc force-pushed the optimization/fields-ffi branch from a5dd0c4 to 3c6eb58 Compare November 22, 2023 11:39
@tizoc
Copy link
Member Author

tizoc commented Nov 22, 2023

!ci-build-me

Copy link
Member

@georgeee georgeee left a comment

Choose a reason for hiding this comment

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

I support this change: it strictly streamlines the code.

I ran a round of this fix with the ledger test-apply tool and saw performance improvement of around 10%. It might be a statistical aberration though, but looks like even if there is a performance improvement, it;'s a marginal one.

Copy link
Member

@mrmr1993 mrmr1993 left a comment

Choose a reason for hiding this comment

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

Per the original discussion please create a rust binding that explicitly calls into_repr and use that instead.

From the comment on the rust function backing compare:

        /// users should use this `Ord` for applications where
        /// any ordering suffices (like in a BTreeMap), and not in applications
        /// where a particular ordering is required.

@tizoc
Copy link
Member Author

tizoc commented Nov 22, 2023

@mrmr1993 to clarify, should into_repr() calls be added to the already existing Rust _compare functions, or what you mean is that I should add new Rust functions that use into_repr() and use that for the OCaml compare? (leaving the originals as-is)

@mrmr1993
Copy link
Member

@tizoc either is fine, whichever you prefer

@tizoc
Copy link
Member Author

tizoc commented Nov 22, 2023

Ok, just updated the existing compare functions (wanted to be sure that doing so would not have some unintended consequence).

@tizoc tizoc force-pushed the optimization/fields-ffi branch from 54bffd2 to 12a164f Compare November 22, 2023 16:38
@tizoc tizoc marked this pull request as ready for review November 22, 2023 18:04
@tizoc tizoc requested a review from a team as a code owner November 22, 2023 18:04
@georgeee georgeee force-pushed the feature/ledger-mask-maps branch from efdf699 to 098f683 Compare November 27, 2023 20:17
@georgeee georgeee requested a review from a team as a code owner November 27, 2023 20:17
@tizoc
Copy link
Member Author

tizoc commented Nov 27, 2023

This one is included in #14599, leaving it open for now because this one is already approved and the other isn't, but they are related.

@tizoc tizoc force-pushed the optimization/fields-ffi branch from 12a164f to 2d71655 Compare November 27, 2023 20:40
@tizoc tizoc changed the base branch from feature/ledger-mask-maps to rampup November 27, 2023 20:40
@tizoc
Copy link
Member Author

tizoc commented Dec 4, 2023

This is included in #14599 which got merged already, closing.

@tizoc tizoc closed this Dec 4, 2023
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