Repository navigation
Make keyed Compose HTML EAP rendering thread-safe - #5751
Merged
Clemens Koprolin (clemenskoprolin) merged 3 commits intoOct 9, 2026
Merged
Clemens Koprolin (clemenskoprolin) merged 3 commits into
Clemens Koprolin (clemenskoprolin) merged 3 commits into
Conversation
Pool renderers by key
Pool renderers by key
| @Measurement(iterations = 3, time = 1) | ||
| @Fork(value = 2, jvmArgsAppend = {"-Xms256m", "-Xmx256m"}) | ||
| @Threads(4) | ||
| public class RendererPoolBenchmark { |
There was a problem hiding this comment.
Can this benchmark be written in Kotlin rather than Java?
Collaborator
Author
There was a problem hiding this comment.
Yes, I migrated the benchmark to Kotlin using kotlinx-benchmark.
| return renderer.render(hydratable, requireHtmlDocumentRoot, chunkSink, chunkSize, prefix, content) | ||
| if (chunkSink != null) require(chunkSize > 0) { "chunkSize must be positive" } | ||
|
|
||
| val pool = key?.let(::getHtmlRendererPool) |
Member
There was a problem hiding this comment.
Let's use a more straightforward syntax:
val pool = getHtmlRendererPool(key)internal fun getHtmlRendererPool(key: String?): HtmlRendererPool? = if (key == null) null else renderers[key]Simplify nullable renderer pool lookup, correct Kdocs
Oleksandr Karpovich (eymar)
approved these changes
Oct 9, 2026
Clemens Koprolin (clemenskoprolin)
deleted the
clemenskoprolin/compose-html-concurrency
branch
October 9, 2026 13:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes keyed Compose HTML EAP string and streaming rendering thread-safe. Concurrent and nested calls, including calls with the same key, borrow separate renderers from a shared pool. Rendering storage can be reused across threads.
The JVM pool uses preallocated atomic slots to avoid allocating queue nodes when returning renderers. Attribute builders and logical output contents are cleared after each use. Pool retention is limited by the number of keys and idle renderers and oversized JVM output buffers are not retained.
The PR also:
renderHydratedDocumentand bothrenderHydratedDocumentToStreamvariants.Fixes CMP-10919
Testing
Run from the
htmldirectory:Run the JVM benchmarks:
Release Notes
N/A