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

Optimize ByteBufferFetcher, Prototype #1974

Merged
merged 5 commits into from
Jan 1, 2024
Merged

Optimize ByteBufferFetcher, Prototype #1974

merged 5 commits into from
Jan 1, 2024

Conversation

revonateB0T
Copy link
Contributor

@revonateB0T revonateB0T commented Dec 28, 2023

Close #1971

We will do following things in this CL

  • Make ByteBuffer lazily extracted to okio Buffer, to avoid heap thrashing (Actually we should let okio Buffer take these byte[]'s ownership if it is a HeapByteBuffer, but seems it is not possible)
  • Introduce ByteBufferMetadata , to allow ImageDecoder take it directly

@colinrtwhite colinrtwhite deleted the branch coil-kt:main December 30, 2023 21:08
@colinrtwhite colinrtwhite reopened this Dec 30, 2023
@revonateB0T revonateB0T changed the base branch from 3.x to main December 31, 2023 04:19
@revonateB0T revonateB0T marked this pull request as ready for review January 1, 2024 19:00
@revonateB0T
Copy link
Contributor Author

@colinrtwhite
Done, PTAL
Didn't let AnimatedImageDecoderDecoder use ByteBufferMetadata in case one pass a HeapByteBuffer

@colinrtwhite colinrtwhite enabled auto-merge (squash) January 1, 2024 21:12
* Metadata containing the [bytebuffer] of a ByteBuffer, maybe direct
*/
@ExperimentalCoilApi
class ByteBufferMetadata(
Copy link
Member

Choose a reason for hiding this comment

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

I think this file might have to be renamed to ImageSource.jvm.kt to avoid class name conflicts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it doesn't have top-level functions/field, so will not have clash.

@colinrtwhite colinrtwhite merged commit 4790263 into coil-kt:main Jan 1, 2024
8 checks passed
@revonateB0T
Copy link
Contributor Author

@colinrtwhite
Aha, Btw ByteArrayFetcher could be optimized with the same method(lazy extraction)

source = Buffer().apply { write(byteArray) },

But I decided not to optimize it as I think one use ByteArray to decode would not care performance

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.

[Coil 3] Introduce ByteBufferMetadata
2 participants