TGViewer
Everyday Unity Everyday Unity @everydayunity · 1.18K subscribers
Post #2474 1.1K
imkoi/sparse-inject: DI Container forged for game development 

The fastest DI container developed by a friend of mine. I like his engineering approach and the overall high quality of the solution, which you can verify even by checking the benchmarks in the repo, as these are one of the most thorough benches for unity DI containers available online. They are conducted with a deep understanding of how a DI container is used in real games and how to measure performance correctly.

For example, benchmarks that prewarm the code in JIT-compiled environments don’t reflect real use cases, as in your game the registering stage is executed only once—unlike benchmarks where the building stage is run multiple times before measurements are taken. 

Moreover, the results vary significantly between Mono and IL2CPP. I recommend checking the benchmarks and results to remind yourself how crucial it is to profile your code and not blindly trust every claim made online (yes, I’m looking at you, benchmarks in Reflex and VContainer repos). 

Of course, the same applies to the benchmarks by the Sparse Inject author—if you're considering replacing your current DI container with this one, profile your code on the target platform with your existing DI container first. Then, after converting to Sparse Inject, compare the results. Ideally, test on multiple devices—the minimum supported, an average one, and a top-tier one—as performance gains may vary. 

I’ve started porting my pet project from VContainer to Sparse Inject. While I love the minimal API of Sparse Inject, it also means that everything VContainer provided for Unity integration needs to be redone manually. On one hand, VContainer’s Unity integration allows you to kick-start a project quickly, but on the other, it makes switching to another DI container more difficult later as you must redo all of that.
A minimal API of sparse inject requires additional steps now to implement integration features of VContainer I used, but in the future it also makes porting to another DI much easier since you gain complete control and understanding.

Nevertheless, I’ve shared my notes with the author so he can create a migration and quick-start guides. I believe that, sooner or later, a repository with add-ons for quicker Unity integration will be created — avoiding repetitive tasks while maintaining a clean API by keeping these additions separate from the main repo. 

https://github.com/imkoi/sparse-inject 

#di #container #dod
GitHub GitHub - imkoi/sparse-inject: DI Container forged for game development DI Container forged for game development. Contribute to imkoi/sparse-inject development by creating an account on GitHub.
  • 🔥 24
More from @everydayunity
  1. Sep 24, 2026Now you can change the effort mid session in new Claude. So the advice about caching from…
  2. Sep 24, 2026We were wondering in the comments what Claude reset does. Here is the answer https://www.r…
  3. Sep 22, 2026Introducing GPT‑6 Sol and Luna And better & cheaper sol and luna as an immediate response…
  4. Sep 22, 2026Introducing Claude Opus 5.5 \ Anthropic Cost and speed. Opus 5.5 requires less compute to…
  5. Sep 21, 2026Claude Code effort level and model selection effort means more than just "thinking time."…
  6. Sep 19, 2026Netcode for GameObjects 3.0.0 is now available It is preparation for Unity’s shared Netcod…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →