Skip to content

[Code] Optimize PCH Config (Faster Builds)#4951

Merged
Akkadius merged 1 commit intomasterfrom
akkadius/pch-adjustments
Jun 22, 2025
Merged

[Code] Optimize PCH Config (Faster Builds)#4951
Akkadius merged 1 commit intomasterfrom
akkadius/pch-adjustments

Conversation

@Akkadius
Copy link
Copy Markdown
Contributor

Description

This is based off of efforts to cleanup the codebase, modernize and make it more efficient.

I have a branch called build-analyze that runs a trace of what takes up all of the build time (example here http://drone.akkadius.com/EQEmu/Server/18259/1/2)

The headers in zone included in PCH are some of the most commonly included and biggest sources of compile time overhead.

This PR enables application level PCH for Linux builds, does not utilize STD library PCH's for Linux as it slows down builds significantly and ccache handles standard library caching better. For application level headers, it has shown a 17-30% improvement in benchmarks.

**** Expensive headers:
636911 ms: /drone/src/zone/client.h (included 89 times, avg 7156 ms), included via:
  44x: <direct include>
  11x: bot.h 
  11x: quest_parser_collection.h 
  6x: masterentity.h raids.h 
  6x: guild_mgr.h petitions.h 
  2x: dialogue_window.h 
  ...

279709 ms: /drone/src/common/eqemu_logsys.h (included 233 times, avg 1200 ms), included via:
  65x: <direct include>
  14x: client.h eq_stream_intf.h daybreak_connection.h daybreak_pooling.h 
  8x: bot.h bot_structs.h mob.h data_bucket.h data_buckets_repository.h database.h 
  7x: strings.h eq_stream_intf.h daybreak_connection.h daybreak_pooling.h 
  4x: database_update.h database.h 
  4x: database.h 
  ...

239851 ms: /drone/src/zone/mob.h (included 126 times, avg 1903 ms), included via:
  35x: client.h merc.h npc.h 
  10x: bot.h bot_structs.h 
  8x: quest_parser_collection.h encounter.h 
  8x: zonedb.h bot_database.h bot_structs.h 
  7x: strings.h merc.h npc.h 
  6x: guild_mgr.h petitions.h client.h merc.h npc.h 
  ...

232055 ms: /drone/src/common/strings.h (included 214 times, avg 1084 ms), included via:
  80x: <direct include>
  16x: client.h linked_list.h extprofile.h inventory_profile.h item_instance.h evolving_items.h say_link.h saylink_repository.h 
  9x: bot.h bot_structs.h mob.h data_bucket.h data_buckets_repository.h 
  5x: shareddb.h say_link.h saylink_repository.h 
  5x: worlddb.h shareddb.h say_link.h saylink_repository.h 
  4x: zone.h 
  ...

201402 ms: /drone/src/zone/zone.h (included 104 times, avg 1936 ms), included via:
  40x: client.h 
  11x: bot.h client.h 
  11x: quest_parser_collection.h client.h 
  8x: <direct include>
  7x: strings.h 
  6x: masterentity.h raids.h client.h 
  ...

197244 ms: /usr/include/c++/12/string (included 322 times, avg 612 ms), included via:
  41x: eqemu_logsys.h iostream ostream ios ios_base.h locale_classes.h 
  13x: iostream ostream ios ios_base.h locale_classes.h 
  10x: misc_functions.h 
  9x: luabind.hpp class.hpp 
  9x: client.h timer.h chrono sstream istream ios ios_base.h locale_classes.h 
  9x: rulesys.h 
  ...

195188 ms: /drone/src/zone/npc.h (included 104 times, avg 1876 ms), included via:
  37x: client.h merc.h 
  11x: bot.h client.h merc.h 
  9x: quest_parser_collection.h client.h merc.h 
  8x: zone.h spawn2.h 
  7x: strings.h merc.h 
  6x: guild_mgr.h petitions.h client.h merc.h 
  ...

195038 ms: /drone/src/common/database.h (included 195 times, avg 1000 ms), included via:
  17x: client.h linked_list.h extprofile.h inventory_profile.h item_instance.h evolving_items.h shareddb.h 
  9x: bot.h bot_structs.h mob.h data_bucket.h data_buckets_repository.h 
  8x: worlddb.h shareddb.h 
  7x: strings.h linked_list.h extprofile.h inventory_profile.h item_instance.h evolving_items.h shareddb.h 
  5x: <direct include>
  5x: shareddb.h 
  ...

182297 ms: /drone/src/zone/bot.h (included 47 times, avg 3878 ms), included via:
  35x: <direct include>
  7x: masterentity.h 
  5x: command.h 

173916 ms: /drone/src/zone/merc.h (included 96 times, avg 1811 ms), included via:
  43x: client.h 
  11x: bot.h client.h 
  11x: quest_parser_collection.h client.h 
  7x: strings.h 
  6x: guild_mgr.h petitions.h client.h 
  6x: masterentity.h raids.h client.h 

Type of change

  • Build optimization

Testing

Linux (16c/32t Intel)

Command Used

rm -rf ~/.ccache/* && ninja clean && time ninja -j$(expr $(nproc) - 2)

Master (Current)

1m36.088s

With app PCH

1m19.157s
1m20s

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 Akkadius merged commit 4005b68 into master Jun 22, 2025
2 checks passed
@Akkadius Akkadius deleted the akkadius/pch-adjustments branch June 22, 2025 18:52
This was referenced Jun 22, 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