Skip to content

perf(core): 옵시디언 위키링크를 찾을 때 같은 줄을 다시 훑지 않는다 - #125

Merged
minjun0219 merged 1 commit into
mainfrom
claude/project-thread-31up5c
Oct 17, 2026
Merged

minjun0219 merged 1 commit into
mainfrom
claude/project-thread-31up5c

Conversation

@minjun0219

Copy link
Copy Markdown
Owner

Requested by 민준 · project thread

Before: obsidian-markdown 채널이 닫히지 않은 [[ 가 많은 줄에서 O(n²) 으로 느려졌다. [ 만 있는 한 줄을 release CLI 로 돌리면 1만 자 28ms, 2만 자 102ms, 4만 자 389ms, 8만 자 1,650ms 였고(Go CLI 는 8만 자 2,304ms), 같은 입력의 github-markdown 은 5ms 안팎이었다. 안 닫힌 위키링크가 이어진 [[a × 2만(8만 자)도 357ms 였고, --stream 도 같았다([ 4만 자 394ms). #121 에서 들어와 release PR #124 에 들어 있다.

After: 같은 입력이 다른 채널처럼 선형으로 돈다. [ 8만 자가 8ms(Go 14ms), [[a × 2만이 9ms(--stream 7ms)다. 출력은 바뀌지 않는다.

How: [[ 마다 wikilink_len(Go wikilinkLen)이 같은 줄의 ]] 를 찾는데, 못 찾으면 줄 끝까지 훑은 결과를 버리고 다음 [[ 에서 다시 훑었다. 이제 훑다 멈춘 자리(줄바꿈 · 줄 끝 · 빈 [[]] 의 ]])를 돌려받아 render 안에서 기억하고, 그 앞에서 시작하는 [[ 는 다시 훑지 않는다. 그 [[ 가 볼 꼬리는 이미 본 꼬리의 일부라 역시 닫히지 않는다. 줄바꿈은 되돌린 코드 스팬을 다시 읽을 때만 render 에 들어오는데, 줄바꿈 뒤의 [[ 는 다시 찾는다. #111 이 링크 쪽에서 막은 것과 같은 모양의 입력인데, 그 시험(long_unclosed_brackets_preserve_text)과 벤치(BenchmarkUnclosedBrackets)가 html 채널만 돌아서 드러나지 않았다.

  • 시험: Rust long_unclosed_wikilinks_preserve_text, Go TestLongUnclosedWikilinksPreserveText. [ 10만 자와 [[a × 2.5만을 완성본과 스트리밍으로 돌리고, 줄바꿈 뒤와 빈 [[]] 뒤에서는 다시 찾는 것을 본다. 고치기 전 코어로는 이 시험이 release 빌드에서 10.7초, 고친 뒤 0.02초다.
  • 벤치: Go BenchmarkUnclosedWikilinks. 1만 · 2만 · 4만 자가 고치기 전 102 · 409 · 1,586 ms/op, 고친 뒤 0.56 · 1.04 · 2.14 ms/op 로 BenchmarkUnclosedBrackets 와 같은 수준이다.
  • 할당 게이트: Rust obsidian_prose_streaming_is_allocation_free_once_warm, Go TestObsidianProseStreamingIsAllocationFreeOnceWarm. 위키링크 · 첨부([[…]]) · 안 닫힌 [[ 를 흘린다. 위키링크 경로에 할당을 일부러 넣으면 Rust 게이트가 실패하는 것(84회)을 확인했다.

코퍼스에는 넣지 않았다. 출력이 바뀌지 않는 성능 회귀라 실제로 겪은 고장 케이스가 아니고, #111 처럼 단위 시험과 벤치로 고정했다. 고치기 전후 Rust CLI 를 대괄호 · 백틱 · 줄바꿈 · 물결표가 섞인 무작위 입력 3,000개(완성본과 --stream)에 돌려 출력이 모두 같은 것도 확인했다.

검증(로컬): ./scripts/readme-sync.sh, cargo test --workspace --locked, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo build -p mdwire-wasm --target wasm32-unknown-unknown --locked, gofmt · go vet · MDWIRE_RUST=../target/debug/mdwire go test ./...(TestParityWithRustCore 포함), ./scripts/build-npm.sh && CI=1 ./scripts/smoke.sh(Node · Bun · lezer · Workers · TypeScript), examples/react-streaming 빌드. context7.json 스키마 단계는 이 환경에서 context7.com 에 닿지 않아 돌리지 못했다(파일은 바꾸지 않았다). 사이트는 바꾸지 않았다.


Generated by Claude Code

옵시디언 채널은 `[[` 를 만날 때마다 같은 줄에서 `]]` 를 찾는다. 닫히지 않으면 줄 끝까지 훑은
결과를 버리고 다음 `[[` 에서 다시 훑어서, `[` 만 있는 줄이나 안 닫힌 `[[` 가 이어진 줄이 O(n²)
이었다. release CLI 로 `[` 8만 자 한 줄이 1,650ms(Go 2,304ms)였고, 같은 입력의 github-markdown 은
5ms 안팎이다. #111 이 링크 쪽에서 막은 입력과 같은 모양인데, 그 시험과 벤치가 html 채널만 돌았다.

훑다 멈춘 자리를 돌려받아 기억하고, 그 앞에서 시작하는 `[[` 는 다시 훑지 않는다. 그 `[[` 도 같은
꼬리를 보니 닫히지 않는다. 줄바꿈(되돌린 코드 스팬을 다시 읽을 때)과 빈 `[[]]` 에서는 그 자리까지만
건너뛴다. 출력은 그대로다.

- Rust `wikilink_len` · Go `wikilinkLen` 이 멈춘 자리를 돌려준다
- 시험: `long_unclosed_wikilinks_preserve_text` · `TestLongUnclosedWikilinksPreserveText`
- 벤치: Go `BenchmarkUnclosedWikilinks`
- 할당 게이트: `obsidian_prose_streaming_is_allocation_free_once_warm` · Go 같은 이름

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0183TGUjmyUtZXhyCSeRS3qj
@minjun0219 minjun0219 self-assigned this Oct 17, 2026
@minjun0219
minjun0219 marked this pull request as ready for review October 17, 2026 11:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T11:34:10.944296Z 2d74b66 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@minjun0219
minjun0219 merged commit 3913c23 into main Oct 17, 2026
10 checks passed
@minjun0219
minjun0219 deleted the claude/project-thread-31up5c branch October 17, 2026 11:39
@github-actions github-actions Bot mentioned this pull request Oct 17, 2026
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.

2 participants