Command Palette

Search for a command to run...

Назад к скиллам
скилл № 38701

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от 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

  1. Optimize Update, frequent event handlers, visual overlays, mass checks.
  2. You do a code review and see frequent TryComp/HasComp, LINQ in the hot-path, and unnecessary state components.
  3. Looking for the source of lags/GC spikes in server/shared/client.

When not to use

  1. The code is rarely executed and is not in the hot path.
  2. Optimization complicates the code more than it provides benefits.
  3. No measurable symptom (frame time, GC, network delta size).

Reading order of resources

  1. Open references/optimization-patterns.md - quick selection matrix.
  2. Open references/annotated-code-examples.md - live examples with comments.
  3. Open references/docs-reconciliation.md - comparison of docs and actual code.

Source of truth and boundaries of trust

  1. True - actual code of subsystems.
  2. Use Docs as a context for intentions and terms.
  3. If there is a conflict between docs and code, choose the code and explicitly record this in the reasoning.
  4. Don't rely on old pieces without checking for freshness and without the context of the changes.

Workflow optimization

  1. Find the hot-path and record the symptom.
  2. Choose the minimum technique from the cards below.
  3. Compare before/after: number of iterations, allocations, network deltas, behavior.
  4. 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

  1. Compute expensive invariants before nested loops (shapes, set of angles, fast-path flags).
  2. Maintain aggregates incrementally (for example, TargetCount, BurstShotsCount), rather than recalculating collections every tick.
  3. Для частых проверок компонентов в EntitySystem дополнительно использовать dependency EntityQuery<T>.

Anti-pattern

  1. Call an expensive computation inside the inner loop.
  2. Each time, re-calculate “how much is already there/made”, going through the collections.
  3. 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

  1. The number of repeated calculations in a deep loop is greatly reduced.
  2. The number of traversals of collections for the sake of one aggregate is reduced.
  3. The hot path works on already prepared data.

Limits of applicability

  1. The greatest effect is in algorithms with 2+ levels of cycles.
  2. For rare code, choose simplicity over micro-optimization.

2) Reduced allocations ♻️

Pattern

  1. Create working collections once as system/UI fields and clear them via Clear().
  2. Pass existing lists/spans to the method instead of creating new ones.
  3. For temporary buffers in the hot-path, use a pool (ArrayPool<T>) and a guaranteed Return.

Anti-pattern

  1. new List<T>() per frame/each call.
  2. Copying large collections for one iteration.
  3. 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

  1. The pressure on the GC is reduced.
  2. Jitter disappears due to frequent short-lived objects.

Limits of applicability

  1. Ensure collections are cleaned before reuse.
  2. The pool should always have a symmetrical return.

3) Refusal of LINQ in hot-path 🚫

Pattern

  1. In hot spots, use for/foreach and explicit early exits.
  2. Leave LINQ for rare/offline operations
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • 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), без исполняемых скриптов.

Похожие скиллы

Сравнить ss14-standard-optimizations с