Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Encode expected/actual info in ShapeError#962

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
bluss wants to merge3 commits intomaster
base:master
Choose a base branch
Loading
fromshape-info-in-error

Conversation

bluss
Copy link
Member

@blussbluss commentedMar 29, 2021
edited
Loading

Add a (limited) way to add specific information to a ShapeError

Admittedly wonky, but maybe worthwhile.

Result<(), ShapeError> used to be 1 byte, and with this change it
expands to 16 bytes (2 usize on 64-bit).

The remaining 15 bytes are used for optimistically packing as much of
extra info into the error message as possible.

For example we can store expected/actual index for errors (for example
index out of bounds or axis out of bounds, these are not so commonly
handled with ShapeError).

With this change it is supported:

  • Expected/actual index with 7 bytes per index
  • Expected/actual shape with 7-14 bytes per shape
    supports storing shapes with one or two bytes (< 256²) per dimension,
    with limited ndim.

Add a (limited) way to add specific information to a ShapeErrorAdmittedly wonky, but space efficient.Result<(), ShapeError> used to be 1 byte, and with this change itexpands to 16 bytes (2 usize on 64-bit).The remaining 15 bytes are used for optimistically packing as much ofextra info into the error message as possible.For example we can store expected/actual index for errors (for exampleindex out of bounds or axis out of bounds, these are not so commonlyhandled with ShapeError).With this change it is supported:- Expected/actual index with 7 bytes per index- Expected/actual shape with 7 bytes per shape  supports storing shapes with one or two bytes (< 256²) per dimension,  with limited ndim.
Where possible, add expected/actual information to the ShapeError.In many places it is identified new places where more specificErrorKinds and error messages are needed. These are not updated here - acomment is inserted - this will be updated in a future version, when wecan accept breaking changes.
@blussbluss changed the titleShape info in errorEncode expected/actual info in ShapeErrorMar 29, 2021
@bluss
Copy link
MemberAuthor

I guess I needed to experiment with this no-alloc approach. This is a good starting point for also experimenting with an error in a Box, which also does fine on microbenchmarks. Maybe it can be optional.

@bluss
Copy link
MemberAuthor

After exploring this, I'm ready to try adding something likeShapeError(Box<ErrorDetails>) to pack in more information. Thoughts? What I don't like is the code bloat that results from cleanup pads (code to drop the extra box in various places). It could even be made optional, to have such error details.

@blussbluss added this to the0.16.0 milestoneMay 18, 2021
@blussbluss modified the milestones:0.16.0,0.17.0Apr 6, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
0.17.0
Development

Successfully merging this pull request may close these issues.

1 participant
@bluss

[8]ページ先頭

©2009-2025 Movatter.jp