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

safer units of measure #1059

Open
spacejam opened this issue May 6, 2020 · 0 comments
Open

safer units of measure #1059

spacejam opened this issue May 6, 2020 · 0 comments

Comments

@spacejam
Copy link
Owner

spacejam commented May 6, 2020

we perform the same calculations on various types all over the place in the sled codebase, in ad-hoc error-prone ways that cost time when debugging, refactoring, or implementing any change that may touch on them.

we frequently convert between SegmentId, Lsn, LogOffset, usize, PageId, i64 and u64.

we can take ideas from https://yoric.github.io/post/uom.rs/, https://docs.rs/uom/0.26.0/uom/index.html, etc...

goals:

  • remove casting
  • remove ad-hoc modulus
  • remove ad-hoc division of Lsn / LogOffset by segment_size to get a SegmentId
  • further remove normalization (already partially addressed with Config::normalize)
  • remove clippy lint bypasses
  • remove -1 as a valid Lsn if possible (may not be, as we use AtomicI64 to track stability, but maybe this is possible to do in a safer way)
  • remove as much use of TryInto / TryFrom as possible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant