Skip to content

feat(infrastructure): виртуальные потоки для исполнителей запросов LSP#4140

Merged
nixel2007 merged 1 commit into
developfrom
feature/virtual-threads
Jun 18, 2026
Merged

feat(infrastructure): виртуальные потоки для исполнителей запросов LSP#4140
nixel2007 merged 1 commit into
developfrom
feature/virtual-threads

Conversation

@nixel2007

@nixel2007 nixel2007 commented Jun 17, 2026

Copy link
Copy Markdown
Member

Что

Cached-пулы обработчиков запросов LSP (textDocumentServiceExecutor, workspaceServiceExecutor, sentryExecutor) переведены с ThreadPoolTaskExecutor на SimpleAsyncTaskExecutor в режиме виртуальных потоков (setVirtualThreads(true)). Это I/O-bound задачи «один запрос — одна задача», для которых виртуальные потоки оптимальны; TaskDecorator (Sentry + micrometer) для переноса контекста сохранён.

Добавлен глобальный флаг spring.threads.virtual.enabled=true (веб-контейнер websocket/MCP, планировщик, дефолтный @Async).

Чего здесь намеренно НЕТ

Тяжёлые ForkJoinPool-исполнители (диагностики, парсинг, populate, semantic tokens, CLI) оставлены на ForkJoinPool. Перевод их на VT-fan-out был испробован и откатан: их вложенный мелкозернистый parallelStream — CPU-bound и опирается на work-stealing. Замер SmokyTest:

Вариант Время
ForkJoinPool (как сейчас) 60 с
unbounded VT fan-out 8019 с (×133)
bounded VT fan-out >720 с (starvation на вложенных задачах)

Проверка

./gradlew compileJava, spotlessJavaCheck, SmokyTest (~60 с), BSLWorkspaceServiceTest, BSLTextDocumentServiceTest — зелёные.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Optimized async task execution throughout the language server by adopting virtual threads, enabling more efficient concurrent request handling and reduced resource overhead.
    • Updated executor configuration to leverage modern threading capabilities with improved context propagation for better performance in high-concurrency scenarios.

Cached-пулы обработчиков запросов LSP (textDocumentServiceExecutor,
workspaceServiceExecutor, sentryExecutor) переведены с ThreadPoolTaskExecutor
на SimpleAsyncTaskExecutor в режиме виртуальных потоков (setVirtualThreads(true)).
Это I/O-bound задачи «один запрос — одна задача», для которых виртуальные потоки
оптимальны; TaskDecorator (Sentry + micrometer) для переноса контекста сохранён.

Добавлен глобальный флаг spring.threads.virtual.enabled=true (веб-контейнер
websocket/MCP, планировщик, дефолтный @async).

Тяжёлые ForkJoinPool-исполнители (диагностики, парсинг, populate) намеренно
ОСТАВЛЕНЫ на ForkJoinPool: их вложенный мелкозернистый parallelStream — CPU-bound
и требует work-stealing, на виртуальных потоках деградирует на порядки.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2ce6e4b3-fcf7-48d2-a898-03e7deb7f11e

📥 Commits

Reviewing files that changed from the base of the PR and between 6c985d8 and 2bd9a41.

📒 Files selected for processing (6)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLTextDocumentService.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLWorkspaceService.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/SentryAspect.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/ExecutorConfiguration.java
  • src/main/resources/application.properties
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServerTest.java

📝 Walkthrough

Walkthrough

Three LSP executor beans in ExecutorConfiguration are migrated from ThreadPoolTaskExecutor to SimpleAsyncTaskExecutor with virtual threads enabled, exposed as AsyncTaskExecutor. application.properties enables spring.threads.virtual.enabled=true globally. BSLTextDocumentService, BSLWorkspaceService, and SentryAspect update their injected field types accordingly.

Changes

Virtual Thread Executor Migration

Layer / File(s) Summary
Executor bean factory and Spring config
src/main/java/.../infrastructure/ExecutorConfiguration.java, src/main/resources/application.properties
createThreadPoolExecutor is replaced by createVirtualThreadExecutor which builds a SimpleAsyncTaskExecutor with setVirtualThreads(true) and a TaskDecorator. The three LSP @Bean methods are rewritten to return AsyncTaskExecutor with destroyMethod="shutdown" removed. application.properties adds spring.threads.virtual.enabled=true with notes that custom executors are wired separately.
Consumer injection point updates
src/main/java/.../BSLTextDocumentService.java, src/main/java/.../BSLWorkspaceService.java, src/main/java/.../aop/SentryAspect.java, src/test/java/.../BSLLanguageServerTest.java
Import and injected field type changed from ThreadPoolTaskExecutor to AsyncTaskExecutor in all three service consumers. A test comment is updated to reference the new type name.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • theshadowco

Poem

🐇 Hop, hop, hooray for virtual threads so light,
No pool to fill, just fibers taking flight!
SimpleAsyncTaskExecutor spins with glee,
setVirtualThreads(true) — oh, what a spree!
The rabbit cheers: less overhead, more zoom,
Spring hops along and virtual threads now bloom! 🌸

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: migrating LSP request executors to use virtual threads.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/virtual-threads

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 3 468 files  ±0   3 468 suites  ±0   1h 32m 55s ⏱️ - 2m 41s
 3 482 tests ±0   3 464 ✅ ±0   18 💤 ±0  0 ❌ ±0 
20 892 runs  ±0  20 780 ✅ ±0  112 💤 ±0  0 ❌ ±0 

Results for commit 2bd9a41. ± Comparison against base commit 6c985d8.

@nixel2007
nixel2007 merged commit b201829 into develop Jun 18, 2026
39 of 40 checks passed
@nixel2007
nixel2007 deleted the feature/virtual-threads branch June 18, 2026 05:48
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.

1 participant