Skip to content

[Performance] Character Save Optimizations#4851

Merged
Akkadius merged 1 commit intomasterfrom
akkadius/character-save-transaction
Apr 10, 2025
Merged

[Performance] Character Save Optimizations#4851
Akkadius merged 1 commit intomasterfrom
akkadius/character-save-transaction

Conversation

@Akkadius
Copy link
Copy Markdown
Contributor

@Akkadius Akkadius commented Apr 8, 2025

Description

This change does a few optimizations

  • Wraps the whole Client::Save in a database transaction, shaving time down 3-5x
  • Cuts down 8-10 instant camp saves down to 1
  • Cuts down 5 saves during zone down to 2 (On during Handle_OP_Save and one during client deconstructor)
  • In a few spots where do a full Client::Save we just do a Client::SaveCharacterData where only updating the character row is relevant

Type of change

  • Optimizations

Testing

Tested zoning, saving, camping etc.

During Zoning (Before)

  Zone |    Info    | DoZoneSuccess Here -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.011829743] -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | ResetShutdownTimer Reset to [8 Minutes and 20 Seconds] from original remaining time [8 Minutes and 9 Seconds] duration [8 Minutes and 20 Seconds] zone [PID (144477) The Surefall Glade (3)] -- [qrg] (The Surefall Glade) inst_id [0]
 World | Client Log | SetOnline Online status [test] (12) status [Zoning] (4) 
  Zone |    Info    | Save Save for [Akka] took [0.002534652] -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | SetZone Here -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.002374837] -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | SetZone Here -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.002776915] -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | Handle_OP_Save Here -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | ~Client Here -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.002541117] -- [qrg] (The Surefall Glade) inst_id [0]

(After change) During zoning

  Zone |    Info    | Handle_OP_ZoneChange [Akka] Bypassing zone expansion checks because GM flag is set -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | ResetShutdownTimer Reset to [8 Minutes and 20 Seconds] from original remaining time [8 Minutes and 12 Seconds] duration [8 Minutes and 20 Seconds] zone [PID (144740) The Surefall Glade (3)] -- [qrg] (The Surefall Glade) inst_id [0]
 World | Client Log | SetOnline Online status [test] (12) status [Zoning] (4) 
  Zone |    Info    | Save Save for [Akka] took [0.011667529] -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | Handle_OP_Save Here -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | ~Client Here -- [qrg] (The Surefall Glade) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.00261106] -- [qrg] (The Surefall Glade) inst_id [0]

During Camp (Before)

  Zone |    Info    | Save Save for [Akka] took [0.015700742] -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Process Here camp timer -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.002658649] -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Process Here camp timer -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.01285233] -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Process Here camp timer -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.011525433] -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Process Here camp timer -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.012132406] -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Process Here camp timer -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.003330417] -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Process Here camp timer -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Save Save for [Akka] took [0.011929114] -- [halas] (Halas) inst_id [0]
  Zone |    Info    | Process Here camp timer -- [halas] (Halas) inst_id [0]
  Zone |    Info    | ~Client Here -- [halas] (Halas) inst_id [0]

After only shows 2 saves, OP_Save and ~Client deconstructor

Checklist

  • I have tested my changes
  • I have performed a self-review of my code. Ensuring variables, functions and methods are named in a human-readable way, comments are added only where naming of variables, functions and methods can't give enough context.
  • I own the changes of my code and take responsibility for the potential issues that occur

@Akkadius
Copy link
Copy Markdown
Contributor Author

This has been running on THJ just fine

@Akkadius Akkadius merged commit b883888 into master Apr 10, 2025
2 checks passed
@Akkadius Akkadius deleted the akkadius/character-save-transaction branch April 10, 2025 01:56
@Akkadius Akkadius mentioned this pull request Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants