-
Notifications
You must be signed in to change notification settings - Fork 305
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
lib: Add a lighter weight internal checksum wrapper #1256
lib: Add a lighter weight internal checksum wrapper #1256
Conversation
The faster (OpenSSL/GnuTLS) code lived in a `GInputStream` wrapper, and that adds a lot of weight (GObject + vtable calls). Move it into a simple autoptr-struct wrapper, and use it in the metadata path, so we're now using the faster checksums there too. This also drops a malloc there as the new API does hexdigest in place to a buffer. Prep for more work in the commit path to avoid `GInputStream` for local file commits, and ["adopting" files](ostreedev#1255).
dfc9079
to
69c898f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sane overall, just some minor nits.
src/libotutil/ot-checksum-utils.c
Outdated
guint8 digest[_OSTREE_SHA256_DIGEST_LEN]; | ||
ot_checksum_get_digest (&checksum, digest, sizeof(digest)); | ||
g_autofree guchar *ret_csum = g_malloc (sizeof (digest)); | ||
memcpy (ret_csum, digest, sizeof (digest)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit: we're not very consistent with space between the sizeof
operator and the opening parenthesis.
}; | ||
typedef struct OtChecksum OtChecksum; | ||
|
||
/* Same as OSTREE_SHA256_DIGEST_LEN, but this header can't depend on that */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I missed the part about why we can't do that. Can you expand on this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but it feels like a layering violation since conceptually src/libostree
depends on src/libotutil
(which depends on libglnx/
), etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I came up with something that'll at least error out if we somehow make them different ⬇️
Time for a ⚡️! @rh-atomic-bot r+ 36c8169 |
⚡ Test exempted: merge already tested. |
The faster (OpenSSL/GnuTLS) code lived in a
GInputStream
wrapper, and thatadds a lot of weight (GObject + vtable calls). Move it into a simple
autoptr-struct wrapper, and use it in the metadata path, so we're
now using the faster checksums there too.
This also drops a malloc there as the new API does hexdigest in place to a
buffer.
Prep for more work in the commit path to avoid
GInputStream
for local filecommits, and "adopting" files.