Commit graph

15 commits

Author SHA1 Message Date
Mag-nus
2b61b28147
Cumulative updates (#4180)
* Many lb group performance related updates

* fixes

* tweak partitioner

* Implement LandblockGroupMinSpacingWhenDormant

* More threaddebug

* cleanup
2024-06-28 10:43:53 -04:00
Mag-nus
b708c6e876
ServerPerformance allow toggle cumulative (#3758)
cumulative monitoring can potentially add a bit of server overhead

/serverperformance stop cumulative
/serverperformance start cumulative

ProcessPacket monitoring now also commented out.
2021-12-24 15:28:07 +00:00
Mag-nus
7881dd1942
Multithread Generators (#3333)
This could be worth 1-2 ms on a heavily loaded server
2020-11-16 08:30:29 -06:00
Mag-nus
4d111e6899
Add LootGeneration profiling to ServerPerformanceMonitor (#3200)
* Add LootGeneration profiling to ServerPerformanceMonitor

* Add thread safety. Creature.Death() is multi-threaded
2020-09-02 10:19:46 -05:00
gmriggs
6e0e691f2a
continued porting of 1991 to master branch (#2545)
* continuing to pull functions out of 1991 while retaining existing functionality

* adding command descriptions

* moving /debugcast and /recordcast to Developer commands
2019-12-17 09:21:07 -05:00
Mag-nus
df0b662926
Improve Multi-threaded landblock group ticking (non-physics) (#2383)
* Improve Multi-threaded landblock group ticking (non-physics)

This splits up the previous Landblock Tick() work into two functions:
TickMultiThreadedWork()
TickSingleThreadedWork()

Mainly, this allows multi-threading of the following work:
Landblock.actionQueue.RunActions();
Landblock creatures Monster_Tick()
Landblock Heartbeat
Landblock Database Save

The first two of which are the biggest CPU consumers from the previous Tick(), and, fortunately enough are pretty safe to multi-thread.

* Make player teleports from portal collisions via physics a thread safe action

* Fix an exception raised in debug mode when creating new characters

* Thread safety for player teleports from death

* ThreadSafeTeleport framework

* More ThreadSafeTeleport cleanup

* AdjustDungeonCells fix

* update  AdjustPos comments
2019-11-17 06:54:58 -06:00
Mag-nus
b504cb418f
Multi-thread landblock ticking (Landblock Groups w/Thread Safety) (#2303)
* WIP: Multi-thread landblock ticking

This is the start of "landblock group" ticking.

The idea behind the landblock groups are that each group may contain multiple landblocks that must be ticked on the same thread, but, each group itself can be ticked on independant threads.

The current groups are as follows:
Every outdoor landblock is in a group
Every dungeon landblock is in it's own group (one per dungeon)

This is not ready for public servers yet.

* More changes

* First pass at actual groups

* ObjMaint.KnownPlayers needs to be concurrent

* Removing original PoC code from LandblockManager

* Landblock Tick Cleanup

* VisibleObjects also needs to be concurrent

* DestructionQueue also needs to be concurrent

* KnownObjects needs to be concurrent

* Use a bool to toggle multi-threading

* Add thread safety to SequenceManager

* Move landblock phsyics ticking to LandblockManager

Also

* Cleanup log.Info level messages

Log.info is the default console output and is intended for:
server startup
connection/disconnections
admin initiated command output
server shutdown

Log.Debug is the appropriate level for debug-type messages that are to be logged and audited at a later date, but not output to the console.

* Missed a couple

* Move HandleSalvaging from Warn to Debug

* Add thread safety to Landblock

* More landblock group calc stuff

* couple comments

* Add some thread capping

* Limit database from taking all the threads

This adds limits to the database thread consumption.

It also should allow the world to now consume threads easier.

The way it is done is as follows.

- We determine the number of available threads using Environment.ProcessCount
- We allocate (int)Math.Max(Environment.ProcessorCount * .34, 1) to the World, and the remainder tothe database.

It breaks down as follows
1 vCPU = 1 thread world, 1 thread database
2 vCPU = 1 thread world, 1 thread database
3 vCPU = 1 thread world, 2 thread database
4 vCPU = 1 thread world, 3 thread database
5 vCPU = 1 thread world, 4 thread database
6 vCPU = 2 thread world, 4 thread database
7 vCPU = 2 thread world, 5 thread database
8 vCPU = 2 thread world, 6 thread database
9 vCPU = 3 thread world, 6 thread database
10 vCPU = 3 thread world, 7 thread database

I'd like to get some feedback from this PR on various sized servers.

What you may notice is that loading a player may take slightly longer (very slightly).

What you will probably notice is no discenerable difference in-game.

What I want to make sure happens is that the world doesn't end up feeling more choppy due to the parallel processing of outbound network traffic. Hopefully the more fair thread distriubiton will help prevent thread starvation.

* quit if not enough vCPU

* separate landblock group recal between add/remove

* revert landblockMutex in Landblock.cs

* World Manager AboveNormal thread priority.

* Add some tags

* Couple more

* Create LandBlockGroup entity

* remove space between tags

* Update the log4net examples

* Efficiency improvements

* fix message

* more WIP

* Improve log4net

Add color to console output

Make the default logger use Log4Net.Async

* WIP

* More WIP

* more WIP

* More WIP

* more WIP

* More WIP

* more WIP

* wip

* more WIP

* remove old processor count check

* Create ServerObjectManager

This removes the ServerObjects collection out of ObjectMaint into it's own class.

This paves the way for thread safety that will need to be added to ObjectMaint for the multi-threaded landblock groups.

* Only split if multi-threading is enabled

* remove comment

* ObjMaint refactor

* all obj maint collections are now private

* few more optimizations

* alternate objectmaint thread safety model

* fix

* Remove a couple of comments

* improved ObjectMaint locking

* lock (ThreadConfiguration.WorldLockObject) OnDeath

* progress

* set MultiThreadedLandblockGroupPhysicsTicking to false

* Move a bool

* add lock

* physics ticking thread safety improvement

* use Config.js for thread configuration

* Add config comments

* measure physics ticking performance

* /serverstatus info added

* comments
2019-10-08 20:25:49 -05:00
Mag-nus
e5b074c4eb
ServerPerformanceMonitor Refactor (#2316)
* Refactor RateMonitor and ServerPerformanceMonitor

* Fix Cumulative

* plural
2019-09-23 18:25:34 -05:00
Mag-nus
af4b6ba877
Relocate landblock tick code and add more detailed landblock tick performance measurements (#2253)
* Code relocation

Moves the landblock tick code from WorldManager to LandblockManager

Individual landblock physics code has been moved to Landblock

* add 5m per landblock monitoring

* remove unused var

* limit landblock stats output to 10 entries each

* Adjust total event requirements

* total column is not needed
2019-08-19 18:08:21 -05:00
Ty Conner
4d804e5055
Generator system revamp (#1964)
* Add Landblock_Tick_GeneratorRegeneration

* Split up Generator Regeneration and Heartbeats

* Stop saving Gateway portals to Shard DB

* Add IsGateway to Portal

* Add default sound to Pressure Plates

* Notify Geneator of Pickup of Landblock Stackable

* Add RegenerationTimestamp and GeneratedTreasureItem properties

* Generators 3.0

* Add InitializeGenerator
* Remove IsLinked
* Change SelectProfilesInit to use GetMaxObjects
* Change SelectProfilesMax to use GetMaxObjects
* Update GetMaxObjects
  - -1 MaxCreate == Fill up all slots
* Renamed HandleStatus to HandleStatusStaged
* Restore previous HandleStatus
* Update StartGenerator
  - GeneratorInitialDelay > 0: offset NextGeneratorRegenerationTime
- else if InitCreate > 0: Regen
* Add GetNextRegenerationTime
  - If generator isn't previously loaded, skip delay
* Update DisableGenerator
  -  Add ProcessGeneratorDestructionDirective
  - Support GeneratorDestructionType and GeneratorEndDestructionType
* Update AddGeneratorLinks
  - Increate InitCreate and MaxCreate per profile template spec, per each link added
* Update Generator_HeartBeat
  - Starts/Stops Generator, checks event status
* Add Generator_Regeneration
  - Queues for Respawn and/or/both Spawns objects
* Add ResetGenerator
* Update GetSpawnTime to always return UtcNow
* Update Spawn
  - If TreasureGenerator is used, set GeneratedTreasureItem
  - If profile PaletteId and/or/both Shade have value, use it
* Wire up `@regen` command
* Add `@generatordump` command

* Change EmoteType.Generate to use Generator_Regeneration

* Update OnDeath to call OnGeneratorDeath for Generators

* Update OnActivate

* Move default action to last action to allow other actions to start before
* Change OnGenerate to use Generator_Regeneration

* Update Chests

* Remove ResetGenerator
* If Locked disable timed regen of contents
* Update Reset
* Override ResetGenerator

* cleanup

* Rename Generator to GeneratorProfile

* Rename Generator.cs to GeneratorProfile.cs

* Update GeneratorProfile.cs

* Update WorldObject_Generators.cs

* Skip PlaceHolder object profiles
* Change ProcessGeneratorDestructionDirective to not affect dead/dying creatures

* more cleanup

* Update WorldObject_Generators.cs

Bad data protection

* Update WorldObject_Generators.cs

* Update GeneratorProfile.cs

Catch for bad profile data

* Update WorldObject_Generators.cs

log error for generators with Max < Init

* Update Corpse Logs

* Attempt to curb generator sprawl

* Update WorldObject_Generators.cs

* Update GetRNGInitToMaxObjects

* Update WorldObject_Generators.cs

* Code fix for linkitemgen2minutes

Bad Init/Max for linkable

* Fix issue with spawning treasureDID profiles

* Add GeneratorUpdateTimestamp

* GeneratorHeartbeat renamed to GeneratorUpdate

This matches property found in enum

* Update debug output

* Update Landblock.cs

* Update WorldObject_Generators.cs

* Update DeveloperCommands.cs

* Update ResetInterval resetting

* Update SortedGeneratorRegenerationList when already spawned generator is re-enabled

* More changes

* Container updates

* More Debug Info Added

* Do not change default icon unless Shade or Palette was defined

* Wire up `trophies` command

* Add corpse_decay_tick_logging option

* Add NpcInteractsSilently handling for EmoteType.Give

* Update EmoteManager.cs

* Master change fixes

* Update DeveloperCommands.cs

* Update ServerPerformanceMonitor.cs

* Update DeveloperCommands.cs

* Update changelog.md
2019-06-21 03:16:05 -05:00
Mag-nus
218f717c55
Move network/packet work from WorldManager to NetworkManager (#1929)
* Move network/packet work from WorldManager to NetworkManager

* merge fix
2019-06-02 21:04:15 -05:00
Mag-nus
ade5821174
Monster_Tick profiling additions (#1919)
* Monster_Tick profiling additions

* Changed locations being monitored
2019-05-21 07:55:41 -05:00
Mag-nus
126cfa1da7
Process inbound GameAction packets in order received (#1690)
* Process inbound GameAction packets in order received

This does not change the performance of ACE. It just shifts the processing to a different order in UpdateWorld()

It changes from an ActionQueue per session for these types of messages to a single action queue per world.

It also changes the order in which messages are processed.

Now, they are processed in the order in which they were received. Before, they were processed session by session, starting with the sessions with lower id's first.

Having two separate queues, one for ClientMessage and one for GameActions helps us measure performance metrics more finely. If we wanted to process both sets of these types of packets in order, we could combine these queues into one.

* Might as well just combine them to simplify things

This also better repsects packet order from the clients.
2019-04-12 06:34:22 -05:00
Mag-nus
3c117788e7
ProcessPacket performance added to /serverperformance (#1660)
* Add performance logging to ProcessPacket()

* Add Total Time column to /serverperformance

* Remove comma from Tot column
2019-04-08 19:13:27 -05:00
Mag-nus
759b01ac0c
/serverperformance command (Server Performance Monitor) (#1642)
* /serverperformancemonitor command

Optional parameters are:
start
stop
reset

If no parameters are present, the current performance metrics are spit out.

When disabled, overhead is the cost of some simple function calls and a bool check. When enabled, the additional cost is stopwatch events. In comparisson to the work that ACE does for normal processing, the work done when serverperformance is enabled is nearly 0.

Default is disabled.

Enable it to start up automatically in the config.js. This is recommend for most servers. Enable it at runtime using /serverperformance start

* Fix Reset
2019-04-04 13:38:01 -05:00