Skip to content

Описание переменной хранит отдельный подкласс, а не поле каждой переменной - #4685

Merged
nixel2007 merged 1 commit into
developfrom
perf/context-variable-symbol-lean
Nov 1, 2026
Merged

nixel2007 merged 1 commit into
developfrom
perf/context-variable-symbol-lean

Conversation

@sfaqer

@sfaqer sfaqer commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Стековый PR поверх #4691 (файл символа переменной берётся из области). Разделён по просьбе: здесь только описание.

Что

Описание переменной (Optional<VariableDescription>) больше не поле каждого символа переменной. Его хранит новый подкласс DescribedVariableSymbol (на int-координатах, как IntBasedVariableSymbol); построитель выбирает его, только когда описание есть, а у остальных getDescription() отдаёт пустой Optional. AnnotatedVariableSymbol наследуется от него и описание сохраняет. description в построителе остался — теперь это его собственное поле.

Описана малая доля переменных: на ERP 36 тыс. из 2,8 млн.

Замер

Размер экземпляра по GC.class_histogram на ERP (LSP, -Xmx12g, после всех фаз), относительно #4691:

обычные заголовки компактные заголовки
ShortBasedVariableSymbol 48 → 40 Б 40 → 40 Б
IntBasedVariableSymbol 64 → 56 Б 56 → 56 Б
DescribedVariableSymbol (36 тыс.) — / 64 Б — / 56 Б

С обычными заголовками (запуск через java -jar) символ проходит границу выравнивания только без обоих полей — файла (#4691) и описания: −8 байт на переменную, на 2,82 млн переменных ERP это −22,6 МБ. С компактными заголовками (jpackage) весь выигрыш уже дал #4691, здесь размер прежний.

Тесты

Тесты context.*, *VariableSymbol*, *Hover* зелёные; полный check — 4558 тестов, 0 падений.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Variable descriptions are now available for variables that include them, including annotated variables. Variables without descriptions continue to report no description.
  • Refactor
    • Variable metadata handling has been streamlined while preserving the existing selection of compact representations based on source position ranges.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between a17896d and edd5d94.

Files selected for processing: 4
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractVariableSymbol.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AnnotatedVariableSymbol.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/IntBasedVariableSymbol.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ShortBasedVariableSymbol.java

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

Walkthrough

Variable descriptions are now stored by DescribedVariableSymbol rather than every variable symbol. The builder selects that subtype when a description is present and otherwise retains the short- or int-based range selection. AnnotatedVariableSymbol now extends DescribedVariableSymbol.

Changes: Variable symbol descriptions

Layer / File(s) Summary
Description storage and symbol construction
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/*
AbstractVariableSymbol returns an empty description by default. DescribedVariableSymbol stores descriptions, and the builder selects it when a description is present. The range-based constructors no longer accept descriptions, and AnnotatedVariableSymbol extends DescribedVariableSymbol.

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

Change: Refactor

Suggested reviewers: nixel2007, theshadowco

Merge Risk: Minimal · up to edd5d

Descriptions move to a dedicated symbol subtype. No actionable merge-blocking risk is established.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title says that a variable description is stored by a separate subclass instead of a field on every variable. The raw summary matches this: DescribedVariableSymbol is added as a subclass of IntBas…
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
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.
Full details: Title check

Explanation

The title says that a variable description is stored by a separate subclass instead of a field on every variable. The raw summary matches this: DescribedVariableSymbol is added as a subclass of IntBasedVariableSymbol, the description field is removed from AbstractVariableSymbol, and the builder selects the subclass only when a description exists. The title names the main change. It is written in Russian, which is the language of the PR objectives. The title is 74 characters and 10 words, so it is short enough.

Finishing Touches
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

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

 4 344 files  ±0   4 344 suites  ±0   1h 14m 45s ⏱️ - 2m 49s
 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 edd5d94. ± Comparison against base commit 2a66b75.

♻️ This comment has been updated with latest results.

@nixel2007

Copy link
Copy Markdown
Member

Деревья символов от прогона к прогону попадают в снимок в разном количестве

ЧЕГОООО??????? Деревья символов должны быть на одинаковой кодовой базе абсолютно статичны!

@nixel2007

Copy link
Copy Markdown
Member

раздели PR на два stucked pr - отдельно owner, отдельно description

…ле каждой переменной

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sfaqer
sfaqer force-pushed the perf/context-variable-symbol-lean branch from a17896d to edd5d94 Compare October 15, 2026 10:03
@sfaqer sfaqer changed the title Символ переменной не хранит файл и пустое описание Описание переменной хранит отдельный подкласс, а не поле каждой переменной Oct 15, 2026
@sfaqer
sfaqer changed the base branch from develop to perf/context-variable-owner-from-scope October 15, 2026 10:03
@sfaqer

sfaqer commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Деревья символов от прогона к прогону попадают в снимок в разном количестве

Да, сами деревья статичны: один и тот же текст даёт одно и то же дерево. Плавало не дерево, а число его устаревших копий в куче. Документ, перечитанный с тем же текстом (дорасчёт после наполнения так перечитывает тысячи модулей, иные по нескольку раз), получает новое дерево, а SymbolTypeIndex и MethodReturnTypeIndexer держали записи по ключу-символу прежнего дерева — и через родителя этого символа всё прежнее дерево целиком. Сколько копий доживало до снимка, зависело от того, какой документ когда перечитан и чей символ первым лёг ключом, — отсюда разница между прогонами.

Сегодня нашёл это разбором дампа ERP: 8 341 устаревшее дерево, 3,24 млн символов при 3,7 млн в текущих деревьях. Исправление — #4688: ключ записи о методе больше не держит символ (класс, документ, имя, место имени), а там, где нужен сам символ, при перечитывании подставляется символ нового дерева. На ERP −393 МБ живой кучи, UnknownMember тот же. Фразу из описания убрал: теперь там размеры экземпляров и число переменных только в текущих деревьях (2,82 млн).

Разделил: #4691 — файл символа из области (база develop), этот PR — описание, стеком поверх #4691. Замер заодно показал, что выигрыш у них не складывается, а зависит от заголовков: с компактными заголовками (jpackage) 8 байт на переменную даёт уже #4691, с обычными (java -jar) — только оба вместе.

@sonarqubecloud

Copy link
Copy Markdown

Base automatically changed from perf/context-variable-owner-from-scope to develop October 31, 2026 17:08
@nixel2007
nixel2007 merged commit c8206da into develop Nov 1, 2026
38 checks passed
@nixel2007
nixel2007 deleted the perf/context-variable-symbol-lean branch November 1, 2026 09: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