Потокобезопасные общие кэши маршаллинга перечислений и нативного компилятора - #1755
Conversation
…илятора SimpleEnumsMarshaller._gettersCache был статическим LruCache без блокировки, а LruCache даже при чтении переставляет узлы списка. При параллельном чтении свойства-перечисления из фоновых заданий падали исключения LinkedList/Dictionary, после чего чтение перечислений могло падать и в одном потоке. Так же были устроены статические кэши ExpressionHelpers нативного компилятора. Кэш перечислений теперь ConcurrentDictionary, ReflectedMembersCache берет блокировку. LruCache остался без блокировки: кэш MachineInstance у каждой машины свой. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe changes document that LRU caches are not thread-safe, synchronize reflected-member cache lookups, and replace the enum getter LRU cache with a ChangesConcurrent cache access
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No actionable risk remains from the supplied evidence; the PR is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Synchronizing shared lookups reduces the risk of cache corruption. The trade-off is that enum getters are no longer evicted, so memory use can grow with the number of enum types a host loads and uses. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| @@ -10,6 +10,10 @@ This Source Code Form is subject to the terms of the | |||
|
|
|||
| namespace ScriptEngine.Machine | |||
| { | |||
There was a problem hiding this comment.
А зачем у нас два LruCache? Кажется один из них это атавизм и надо испоьзовать везде тот, который из Commons
There was a problem hiding this comment.
Да, копия в ScriptEngine.Machine появилась позже, для кэша Выполнить/Вычислить, и использовалась только в MachineInstance. Убрал её в #1756.
SimpleEnumsMarshaller._gettersCacheбыл статическимLruCacheбез блокировки, аLruCacheдаже при чтении переставляет узлы списка. При параллельном чтении свойства-перечисления, напримерЗадание.Состояниеиз нескольких фоновых заданий, падалиThe LinkedList node does not belong to current LinkedList, NRE и порчаDictionary. После этого чтение перечислений могло падать уже и в одном потоке, до перезапуска процесса. Так же устроены статические кэшиExpressionHelpersв нативном компиляторе.Кэш перечислений теперь
ConcurrentDictionary,ReflectedMembersCacheберет блокировку. СамLruCacheоставил без блокировки: кэшMachineInstanceу каждой машины свой, аlockв нем давал +3% наВычислить. Новые тесты вtasks.osиReflectedMembersCacheTestбез исправления падают.Замеры, Release, медиана
Задание.СостояниеВычислить("1 + 1")Отдельные процессы, 4 прогрева и 4 замера, 5 раундов с чередованием. Шум по контролю около 2%. Чтение перечисления быстрее и в прошлой серии (0,957).
🤖 Generated with Claude Code
Summary by CodeRabbit