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

Device-write efficiency improvements #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CJCShadowsan
Copy link

@CJCShadowsan CJCShadowsan commented Nov 28, 2024

Improve device write efficiency.

device_write currently does unnecessary type conversion for rc to int, and has redundant checks increasing branching.

This version allows early return, more efficient error handling, and prevents unnecessary type conversion.

We do cast rc to size_t, but a cast is effectively free from a performance standpoint and we did the check to see if it was a negative value beforehand anyway.

Design Documents

  • None

Related JIRAs

  • N/A

Risk

LOW - The function has the same core functionality, it is only more efficient.

Tests

Unable to test - Code inspection only. Highly recommend testing.

- Maintain type consistency to avoid unnecessary type conversion
- Early returns to simplify control flow and reduce branching
- Eliminate redundant checks
@CJCShadowsan
Copy link
Author

Btw, it would be nice if someone does test this, to show me for my own morbid curiosity what performance uplift this gives :)

@jswaro jswaro self-requested a review January 9, 2025 20:45
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.

1 participant