Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cardinal/bench_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ func newBenchWorld() *World {

func mustInitSystemFields[T any](b testing.TB, world *World, state *T) {
b.Helper()
_, _, err := initSystemFields(state, world)
err := initSystemFields(state, world)
if err != nil {
b.Fatalf("failed to initialize system fields: %v", err)
}
Expand Down
13 changes: 1 addition & 12 deletions pkg/cardinal/cardinal.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/argus-labs/world-engine/pkg/cardinal/internal/command"
"github.com/argus-labs/world-engine/pkg/cardinal/internal/ecs"
"github.com/argus-labs/world-engine/pkg/cardinal/internal/event"
"github.com/argus-labs/world-engine/pkg/cardinal/internal/performance"
"github.com/argus-labs/world-engine/pkg/cardinal/snapshot"
"github.com/argus-labs/world-engine/pkg/micro"
"github.com/argus-labs/world-engine/pkg/telemetry"
Expand Down Expand Up @@ -121,16 +120,6 @@ func NewWorld(opts WorldOptions) (*World, error) {
if *options.Debug {
debug := newDebugModule(world)
world.debug = &debug

world.world.OnSystemRun(func(name string, hook ecs.SystemHook, startTime, endTime time.Time) {
world.debug.recordSpan(performance.TickSpan{
TickHeight: world.currentTick.height,
SystemName: name,
SystemHook: uint8(hook),
StartTime: startTime,
EndTime: endTime,
})
})
}

return world, nil
Expand Down Expand Up @@ -161,7 +150,7 @@ func (w *World) StartGame() {
}

func (w *World) run(ctx context.Context) error {
// Initialize world schedulers and run init systems.
// Initialize world and run init systems.
w.world.Init()

if err := w.restore(ctx); err != nil {
Expand Down
20 changes: 8 additions & 12 deletions pkg/cardinal/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (d *debugModule) Introspect(
}), nil
}

// buildSchedules converts the ECS scheduler dependency graphs to proto messages.
// buildSchedules converts the ECS system lists to proto messages.
func (d *debugModule) buildSchedules() []*cardinalv1.SystemSchedule {
ecsSchedules := d.world.world.Schedules()
schedules := make([]*cardinalv1.SystemSchedule, 0, len(ecsSchedules))
Expand All @@ -164,14 +164,9 @@ func (d *debugModule) buildSchedules() []*cardinalv1.SystemSchedule {
}
nodes := make([]*cardinalv1.SystemNode, len(s.Systems))
for i, sys := range s.Systems {
deps := make([]uint32, len(sys.Dependents))
for j, dep := range sys.Dependents {
deps[j] = uint32(dep) //nolint:gosec // bounded by system count
}
nodes[i] = &cardinalv1.SystemNode{
Id: uint32(sys.ID), //nolint:gosec // bounded by system count
Name: sys.Name,
Dependents: deps,
Id: uint32(sys.ID), //nolint:gosec // bounded by system count
Name: sys.Name,
}
}
schedules = append(schedules, &cardinalv1.SystemSchedule{
Expand All @@ -182,10 +177,6 @@ func (d *debugModule) buildSchedules() []*cardinalv1.SystemSchedule {
return schedules
}

// -------------------------------------------------------------------------------------------------
// Performance
// -------------------------------------------------------------------------------------------------

func ecsHookToProto(hook uint8) cardinalv1.SystemHook {
mapping := [4]cardinalv1.SystemHook{
cardinalv1.SystemHook_SYSTEM_HOOK_PRE_UPDATE,
Expand All @@ -199,6 +190,10 @@ func ecsHookToProto(hook uint8) cardinalv1.SystemHook {
return cardinalv1.SystemHook_SYSTEM_HOOK_UNSPECIFIED
}

// -------------------------------------------------------------------------------------------------
// Performance
// -------------------------------------------------------------------------------------------------

// StreamPerf streams batches of per-tick timing data to connected clients.
func (d *debugModule) StreamPerf(
ctx context.Context,
Expand Down Expand Up @@ -387,6 +382,7 @@ func (d *debugModule) Reset(
return connect.NewResponse(&cardinalv1.ResetResponse{}), nil
}

// TODO: this does unsynchronized concurrent access to ToProto. fix after snapshot rework.
// GetState returns the current world state snapshot.
func (d *debugModule) GetState(
_ context.Context,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cardinal/dst.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func newDSTFixture(t *testing.T, cfg dstConfig, setup DSTSetupFunc) *dstFixture
storage := &memSnapshotStorage{t: t}
w.snapshotStorage = storage

// Initialize ECS schedulers and run init systems.
// Initialize ECS and run init systems.
w.world.Init()

// Cache concrete payload types for random command generation.
Expand Down
30 changes: 18 additions & 12 deletions pkg/cardinal/internal/ecs/archetype_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,27 @@ func TestArchetype_ModelFuzz(t *testing.T) {
eid := entities[prng.IntN(len(entities))]
src := model[eid]
dst := pool[prng.IntN(len(pool))]
for dst == src { // Make sure dst != src
dst = pool[prng.IntN(len(pool))]
}

src.moveEntity(dst, eid)
model[eid] = dst

// Property: entity no longer exists in source.
_, exists := src.rows.get(eid)
assert.False(t, exists)

// Property: entity exists in destination and bijection holds.
row, exists := dst.rows.get(eid)
assert.True(t, exists)
assert.Equal(t, eid, dst.entities[row])
if src == dst {
// Property: self move is a no-op and the model remains unchanged.
row, exists := src.rows.get(eid)
assert.True(t, exists)
assert.Equal(t, eid, src.entities[row])
assert.Same(t, src, model[eid])
} else {
model[eid] = dst

// Property: entity no longer exists in source.
_, exists := src.rows.get(eid)
assert.False(t, exists)

// Property: entity exists in destination and bijection holds.
row, exists := dst.rows.get(eid)
assert.True(t, exists)
assert.Equal(t, eid, dst.entities[row])
}

default:
panic("unreachable")
Expand Down
206 changes: 0 additions & 206 deletions pkg/cardinal/internal/ecs/scheduler.go

This file was deleted.

Loading
Loading