Skip to content

[BUG]:The server profiler (Spark) consistently reports that ServerEvents.handleSunExposure() consumes a significant amount of server tick time. #186

Description

@1402305179-pixel

Description

The server profiler (Spark) consistently reports that ServerEvents.handleSunExposure() consumes a significant amount of server tick time.

The profiler shows the following call stack:

ServerEvents.handleSunExposure()
└─ Entity.pick()
└─ BlockGetter.clip()
└─ Level.getChunk()
└─ ServerChunkCache.getChunk()
└─ managedBlock()
└─ waitForTasks()

Approximately 42% of the server tick time is spent in this path.

On my server this results in:

TPS around 16
MSPT around 50 ms
CPU usage remains relatively low, suggesting the server thread is spending a significant amount of time waiting during the Sun Exposure checks.

This occurs even with only one player online.

I'm not sure whether this is intended behavior or a performance issue, but it appears that the Sun Exposure system performs an expensive ray trace (Entity.pick()) every server tick, which may end up waiting for chunk access (ServerChunkCache.getChunk() → managedBlock() → waitForTasks()).

If this is expected, would it be possible to optimize the implementation, reduce the check frequency, or provide a configuration option to disable the Sun Exposure system on dedicated servers?

Minecraft Version

1.21.1

ProjectExpansion Version

1.06

Mod Loader and Version

NeoForge 21.1.233

Reproduction Steps

Start a dedicated server.
Join the server with a player.
Let the server run for about one minute.
Generate a Spark profile.
Observe that ServerEvents.handleSunExposure() accounts for a large percentage of the server tick time.

Crash Report/Logs

No crash occurs.

Spark profiler output indicates:

ServerEvents.handleSunExposure()
└─ Entity.pick()
└─ BlockGetter.clip()
└─ Level.getChunk()
└─ ServerChunkCache.getChunk()
└─ managedBlock()
└─ waitForTasks()

The profile shows approximately 42% of the server tick time spent in this call chain.

I can provide the complete Spark profile if needed.

Other Mods

This was observed in a larger modpack.

If necessary, I can also test with only ProjectExpansion and its required dependencies to help isolate the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions