GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MarkdownWriter: append unescaped spans in bulk by tballison · Pull Request #456 · commonmark/commonmark-java

Conversation

@tballison

@tballison tballison commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

During profiling after the release of Tika 4.0.0, we found we could improve write speed quite a bit in cases where there weren't a lot of characters that needed to be escaped.

🤖

text() always passes a CharMatcher, so every text literal was written 
to the Appendable one character at a time. Scan for the next character 
that needs escaping and append the clean span in one call instead.

JMH, whole CommonMark spec (SpecBenchmark, JDK 17, -f 3 -wi 8 -i 12)

Benchmark before after
renderMarkdownWholeSpec (to StringBuilder) 836.5 ± 34.3 ops/s 956.7 ± 11.3 ops/s +14%
renderMarkdownWholeSpecToWriter 401.9 ± 2.5 ops/s 837.2 ± 20.1 ops/s 2.08x

Rendering 4.7 MB of plain prose (best-of-22 after warmup, JDK 17)

Target Appendable before after
OutputStreamWriter 107 ms 14.5 ms 7.4x
StringWriter 75 ms 12.3 ms 6.1x
StringBuilder 26 ms 12.7 ms 2.0x

Same measurement, 4.0 MB of the spec (escape-dense, closer to a worst case)

Target Appendable before after
OutputStreamWriter 54.9 ms 25.8 ms 2.1x
StringWriter 46.1 ms 21.5 ms 2.1x
StringBuilder 24.2 ms 20.8 ms 1.2x

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tballison
MarkdownWriter: append unescaped spans in bulk
e7daa8a
roxspring
roxspring reviewed Sep 7, 2026
View reviewed changes
Comment thread commonmark/src/main/java/org/commonmark/renderer/markdown/MarkdownWriter.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@tballison
MarkdownWriter: extract append(String, CharMatcher)
5d529c6
robinst
robinst approved these changes Oct 10, 2026
View reviewed changes

@robinst robinst left a comment

Copy link
Copy Markdown
Collaborator

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.

Nice, LGTM, thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tballison reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@robinst
robinst merged commit 73d76d0 into commonmark:main Oct 10, 2026
5 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@robinst

robinst commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Released in 0.30.1: https://github.com/commonmark/commonmark-java/blob/main/CHANGELOG.md#0301---2026-10-11

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@WebReflection WebReflection mentioned this pull request Oct 28, 2026
chore(jetbrains): bump commonmark to 0.30.1 Kilo-Org/kilocode#15538
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@robinst robinst robinst approved these changes
+1 more reviewer
@roxspring roxspring roxspring left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@tballison @robinst @roxspring
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.