Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Fix: Buffer utilities codegen#2104

Merged
esden merged 1 commit intomainfrom
fix/buffer-utils-codegen
Apr 3, 2025
Merged

Fix: Buffer utilities codegen#2104
esden merged 1 commit intomainfrom
fix/buffer-utils-codegen

Conversation

@dragonmux
Copy link
Copy Markdown
Member

Detailed description

In this PR we address a codegen/optimisation issue that has been identified in the buffer utilities functions. These functions include the read_{l,b}e{2,4,8}() routines which do an endian-aware read of a buffer to (re)construct an integer.

The way these functions were expressed is somewhat naïve and results in extremely poor codegen (a sled of loads, shifts and adds) due to the need to deal with an offset into the buffer. It was quickly identified, however, that moving the data to a function-internal buffer with memcpy() and then doing the endian-dependant read produced the correct code output - one load, and depending on host endian, one swap.

This greatly improves the performance of these functions and their call footprint as they get inlined where they're called.

Your checklist for this pull request

Closing issues

…nes were expressed that results in a massive optimisation miss and very poor codegen
@dragonmux dragonmux added Bug Confirmed bug Enhancement General project improvement labels Apr 3, 2025
@dragonmux dragonmux added this to the v2.0 release milestone Apr 3, 2025
@dragonmux dragonmux requested a review from esden April 3, 2025 00:55
Copy link
Copy Markdown
Member

@esden esden left a comment

Choose a reason for hiding this comment

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

LGTM

@esden esden merged commit 03d87d4 into main Apr 3, 2025
17 of 36 checks passed
@dragonmux dragonmux deleted the fix/buffer-utils-codegen branch April 3, 2025 01:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Bug Confirmed bug Enhancement General project improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants