Skip to content

Плоские списки дерева символов хранятся точного размера, без запаса от роста - #4704

Merged
nixel2007 merged 1 commit into
developfrom
perf/context-symbol-tree-lists-exact-size
Oct 16, 2026
Merged

nixel2007 merged 1 commit into
developfrom
perf/context-symbol-tree-lists-exact-size

Conversation

@sfaqer

@sfaqer sfaqer commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Плоские списки дерева символов — childrenFlat, methods и variables — живут, пока живо дерево, а собирались в ArrayList с запасом от роста: список растёт с ёмкости 10 в полтора раза, и в среднем у такого списка пустует около четверти ячеек. Деревьев на ERP 26 тыс., списки в них — сотни символов.

Теперь childrenFlat после сборки обрезается по размеру (trimToSize), а methods и variables собираются Stream.toList() — неизменяемым списком точного размера. Снаружи эти списки никто не меняет.

Замер

Дамп живой кучи после старта LSP на ERP (-Xmx12g), владельцы массивов и списков по полям SymbolTree (perf-tools/HprofOwners). develop — 2a66b751150 (база ветки), PR — d9335580925. Деревьев в обоих дампах около 24 тыс.

поле SymbolTree develop PR разница
childrenFlat: массив ArrayList 17,5 МБ 14,3 МБ −3,2 МБ
variables: массив + список 13,6 + 0,6 МБ 11,2 + 0,5 МБ −2,5 МБ
methods: массив + список 3,9 + 0,6 МБ 3,1 + 0,5 МБ −0,9 МБ

Итого −6,6 МБ. Лишняя работа — одно копирование массива childrenFlat при построении дерева; methods и variables и раньше копировались из плоского списка, только в растущий ArrayList.

Проверка

./gradlew check на d9335580925: 4558 тестов, 0 падений.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved how method and variable symbols are organized after construction. No user-facing behavior changes are noted.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: 1c-syntax/bsl-language-server/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b285d784-3ccf-4d20-bfa9-9493bdf207a1
📥 Commits

Reviewing files that changed from the base of the PR and between 2a66b75 and d933558.

📒 Files selected for processing: 1
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SymbolTree.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

📝 Walkthrough

SymbolTree trims the flattened child list after construction. It uses a shared helper to create method and variable lists with Stream.toList().

Changes: Symbol tree list construction

Layer / File(s) Summary
Flattened symbol lists
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SymbolTree.java
createChildrenFlat trims its backing list. createMethods and createVariables use flatOfExactSize to collect matching symbols into lists returned by Stream.toList().

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to d9335

The optimization trims retained symbol-list storage and returns immutable method and variable lists. Inspected consumers only read these lists, so no concrete user-facing regression remains and the PR appears mergeable.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: storing the flat symbol-tree lists at exact size without extra capacity.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 4 344 files  ±0   4 344 suites  ±0   1h 12m 33s ⏱️ - 5m 1s
 4 558 tests ±0   4 468 ✅ ±0   90 💤 ±0  0 ❌ ±0 
27 348 runs  ±0  26 796 ✅ ±0  552 💤 ±0  0 ❌ ±0 

Results for commit d933558. ± Comparison against base commit 2a66b75.

@nixel2007
nixel2007 merged commit 598fe55 into develop Oct 16, 2026
37 checks passed
@nixel2007
nixel2007 deleted the perf/context-symbol-tree-lists-exact-size branch October 16, 2026 13:53
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