Skip to content

Start-time optimizations - #153

Merged
marchc1 merged 4 commits into
SourceDotNET:mainfrom
marchc1:optimizations
Oct 11, 2026
Merged

marchc1 merged 4 commits into
SourceDotNET:mainfrom
marchc1:optimizations

Conversation

@marchc1

@marchc1 marchc1 commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

This fixes a couple of the largest issues I could find with initialization:

  • SoundEmitterSystem using LinkedList.Find to find a node; this replaces those operations with a dictionary lookup (was nearly 25% of startup!!)
  • VPK indices don't read one byte at a time now
  • VPK's aren't read twice (another packstore can reuse the same vpk data)
  • FilenameAndExtension is lazy initialized
  • Overall, VPK mounting should be ~4x faster
  • FindExcludeProp was checking all slots, not just filled in ones, accidentally missed that (nearly 10x faster I think)

A lot of the remaining overhead is likely JIT and other factors, of which I will continue to look into later, but I'm sure there's some other very silly things I'm doing that need to be checked as well. For later:

ConVar_Register is probably the biggest one since it does a huge amount of reflection. [ConCommandAttribute] could probably be turned into a code generator. I am unsure if source generators could work without attributes on the convars, but perhaps we could even compile those rather than relying on reflection.

The field accessors are also pretty meh
PostBuildAllForms is also very reflection heavy
may also want to look into reworking the file find API

@marchc1
marchc1 merged commit 2c09edf into SourceDotNET:main Oct 11, 2026
4 checks passed
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