Skip to content

perf(reader): кэш дескриптора сеттера в TransformationUtils#643

Merged
nixel2007 merged 1 commit into
developfrom
perf/transformationutils-setter-cache
Jul 15, 2026
Merged

perf(reader): кэш дескриптора сеттера в TransformationUtils#643
nixel2007 merged 1 commit into
developfrom
perf/transformationutils-setter-cache

Conversation

@nixel2007

Copy link
Copy Markdown
Member

Описание

Профилирование чтения метаданных (mdclasses даёт ~42 % CPU при analyze большой конфигурации)
показало, что TransformationUtils.setValue на каждый XML-узел заново вычислял тип параметра
сеттера — method.getGenericParameterTypes() аллоцирует Type[] на каждый вызов — и, для
параметризованных свойств, склеивал "add" + methodName и делал повторный поиск метода.

Кэшируем разобранный сеттер в дескриптор (setter, parameterized, singularAdder) по паре
(класс, свойство). setValue теперь только выбирает целевой метод и вызывает его — без повторной
интроспекции и аллокаций на каждый вызов. Поведение идентично.

Замеры

JMH MDClassesBenchmark.test_Designer_CreateConfiguration_SkipSupport_False, направленный на
реальную конфигурацию (cpm, ~13k файлов) через -Dbench.designer.path, -f 2 -wi 2 -i 5 -prof gc
(один op = полное чтение конфигурации):

метрика before after
gc.alloc.rate.norm 5155.0 МБ/чтение ± 4.3 5078.1 МБ/чтение ± 6.1
дельта аллокаций −77 МБ (−1.5 %)
wall (avgt) 13.57 с ± 3.2 12.59 с ± 3.6 (в пределах шума)

Снижение аллокационной нагрузки чистое и стабильное (погрешность ±4–6 МБ при дельте 77 МБ). Wall —
в пределах шума (чтение 13k файлов + GC 5 ГБ/op), регрессии нет.

Связанные задачи

Closes

Чеклист

Общие

  • Ветка PR обновлена из develop
  • Отладочные, закомментированные и прочие, не имеющие смысла участки кода удалены
  • Изменения покрыты тестами (TransformationUtilsTest; интеграционные MDOReaderTest зелёные)
  • Обязательные действия перед коммитом выполнены (gradlew precommit) — прогонял reader-тесты

Дополнительно

Поведение setValue сохранено 1:1 (сеттер / одиночный add-метод для параметризованных свойств).

Профилирование чтения метаданных (mdclasses — ~42% CPU при analyze большой
конфигурации) показало, что TransformationUtils.setValue на каждый узел XML заново
вычислял тип параметра сеттера (getGenericParameterTypes() аллоцирует Type[]) и, для
параметризованных свойств, склеивал "add" + methodName и делал повторный поиск метода.

Кэшируем разобранный сеттер в дескриптор (setter, parameterized, singularAdder) по паре
(класс, свойство). setValue теперь только выбирает целевой метод и вызывает его —
без повторной интроспекции и аллокаций на каждый вызов. Поведение не меняется.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HLvkKQCwBjTHwuZ4EGBQK6
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@nixel2007, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a8d6e834-fc7d-485c-9836-d7cae2daef83

📥 Commits

Reviewing files that changed from the base of the PR and between 5f0aafd and 4c3abce.

📒 Files selected for processing (1)
  • src/main/java/com/github/_1c_syntax/bsl/reader/common/TransformationUtils.java
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/transformationutils-setter-cache

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

  516 files  ±0    516 suites  ±0   12m 51s ⏱️ +50s
1 256 tests ±0  1 253 ✅ ±0   3 💤 ±0  0 ❌ ±0 
7 560 runs  ±0  7 542 ✅ ±0  18 💤 ±0  0 ❌ ±0 

Results for commit 4c3abce. ± Comparison against base commit 5f0aafd.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes metadata reading by reducing per-node reflection overhead in TransformationUtils.setValue, which is a hot path during XML/EDT unmarshalling. It introduces a cached “setter descriptor” so repeated calls no longer re-allocate Type[] via getGenericParameterTypes() nor repeatedly search for a singular add<Property> method.

Changes:

  • Added a SETTERS cache keyed by (class, property) to store a parsed (setter, isParameterized, singularAdder) descriptor.
  • Reworked setValue to early-return on null and invoke the cached target method (setter vs singularAdder) without repeated introspection.
  • Introduced SetterDescriptor record encapsulating the method-selection logic.

@nixel2007
nixel2007 merged commit 109b5ea into develop Jul 15, 2026
20 checks passed
@nixel2007
nixel2007 deleted the perf/transformationutils-setter-cache branch July 15, 2026 19:11
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