ss14-standard-optimizations
Practical skill in standard optimizations of Space Station 14: caching, reduction of allocations, abandonment of LINQ in hot-path, ActiveComponent approach…
от makura-games★ 74 звезды на GitHub
Установить ss14-standard-optimizations в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
SS14 Standard Optimizations
The goal of the skill: quickly select the correct optimization for ECS code without degradation of readability and without outdated techniques :) The main reference: the current behavior of the code. Documentation is an auxiliary layer.
When to use
- Optimize
Update, frequent event handlers, visual overlays, mass checks. - You do a code review and see frequent
TryComp/HasComp, LINQ in the hot-path, and unnecessary state components. - Looking for the source of lags/GC spikes in server/shared/client.
When not to use
- The code is rarely executed and is not in the hot path.
- Optimization complicates the code more than it provides benefits.
- No measurable symptom (frame time, GC, network delta size).
Reading order of resources
- Open
references/optimization-patterns.md- quick selection matrix. - Open
references/annotated-code-examples.md- live examples with comments. - Open
references/docs-reconciliation.md- comparison of docs and actual code.
Source of truth and boundaries of trust
- True - actual code of subsystems.
- Use Docs as a context for intentions and terms.
- If there is a conflict between docs and code, choose the code and explicitly record this in the reasoning.
- Don't rely on old pieces without checking for freshness and without the context of the changes.
Workflow optimization
- Find the hot-path and record the symptom.
- Choose the minimum technique from the cards below.
- Compare before/after: number of iterations, allocations, network deltas, behavior.
- Add a short explanation to your PR: “what was accelerated” and “why it’s safe.”
Optimization cards
1) Caching invariants and aggregates before hot-loop ⏱️
Pattern
- Compute expensive invariants before nested loops (shapes, set of angles, fast-path flags).
- Maintain aggregates incrementally (for example,
TargetCount,BurstShotsCount), rather than recalculating collections every tick. - Для частых проверок компонентов в
EntitySystemдополнительно использовать dependencyEntityQuery<T>.
Anti-pattern
- Call an expensive computation inside the inner loop.
- Each time, re-calculate “how much is already there/made”, going through the collections.
- Receive query/accessor in every hot-path call.
Code example
var itemShape = ItemSystem.GetItemShape(itemEnt); // One shape calculation before cycles.
var fastAngles = itemShape.Count == 1;
var angles = new ValueList<Angle>();
if (!fastAngles)
{
for (var angle = startAngle; angle <= Angle.FromDegrees(360 - startAngle); angle += Math.PI / 2f)
angles.Add(angle); // We precalculated the allowable angles once.
}
else
{
angles.Add(startAngle);
if (itemShape[0].Width != itemShape[0].Height)
angles.Add(startAngle + Angle.FromDegrees(90));
}
// In the inner loop we use only prepared data.
foreach (var angle in angles)
{
// Heavy placement/collision checking.
}
// Incremental aggregate instead of set recalculation:
if (gun.BurstActivated)
{
gun.BurstShotsCount += shots;
if (gun.BurstShotsCount >= gun.ShotsPerBurstModified)
{
gun.BurstActivated = false;
gun.BurstShotsCount = 0;
}
}
Why is it faster
- The number of repeated calculations in a deep loop is greatly reduced.
- The number of traversals of collections for the sake of one aggregate is reduced.
- The hot path works on already prepared data.
Limits of applicability
- The greatest effect is in algorithms with 2+ levels of cycles.
- For rare code, choose simplicity over micro-optimization.
2) Reduced allocations ♻️
Pattern
- Create working collections once as system/UI fields and clear them via
Clear(). - Pass existing lists/spans to the method instead of creating new ones.
- For temporary buffers in the hot-path, use a pool (
ArrayPool<T>) and a guaranteedReturn.
Anti-pattern
new List<T>()per frame/each call.- Copying large collections for one iteration.
- Ignoring the pool for repeated short-lived buffers.
Code example
private ValueList<EntityUid> _toRemove = new();
public override void Update(float frameTime)
{
var query = AllEntityQuery<ColorFlashEffectComponent>();
_toRemove.Clear(); // We will reuse without new allocation.
while (query.MoveNext(out var uid, out _))
{
if (_animation.HasRunningAnimation(uid, AnimationKey))
continue;
_toRemove.Add(uid);
}
foreach (var ent in _toRemove)
RemComp<ColorFlashEffectComponent>(ent);
}
Why is it faster
- The pressure on the GC is reduced.
- Jitter disappears due to frequent short-lived objects.
Limits of applicability
- Ensure collections are cleaned before reuse.
- The pool should always have a symmetrical return.
3) Refusal of LINQ in hot-path 🚫
Pattern
- In hot spots, use
for/foreachand explicit early exits. - Leave LINQ for rare/offline operations
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/annotated-code-examples.md
- references/docs-reconciliation.md
- references/optimization-patterns.md
FAQ
Что делает скилл ss14-standard-optimizations?
Practical skill in standard optimizations of Space Station 14: caching, reduction of allocations, abandonment of LINQ in hot-path, ActiveComponent approach, EntityQuery, order of components in EntityQueryEnumerator, ByRef events, DirtyField, early exits and cleaning of unnecessary components. Use it when designing, reviewing and optimizing ECS code in server/shared/client.
Как установить скилл ss14-standard-optimizations?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ss14-standard-optimizations запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…