Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement stream pooling and more fine grained lock #79

Merged
merged 2 commits into from
Mar 3, 2024

Conversation

Soreepeong
Copy link
Contributor

When using multiple threads to call GetFile<T>, the lock was being held per SqPack, which effectively is a .dat file. Changed that to lock per file inside a .dat file, and added SqPackStreamPool? GameData.StreamPool which will reuse already opened file handles to avoid performance hit from creating handle per every file accessed.

The attached test code iterates 800,054 paths from 040000. The test was done on 16 P-threads on 13900k.

  • Before: 30s
  • After: 7.9s
  • After + StreamPool: 6.8s

SqPackStreamPool_TestCode.txt
SqPackStreamPool_TestResult.txt

Notes

  • Microsoft.Extensions.ObjectPool has been added as a dependency.
  • GameData is now implements IDisposable, so that it disposes InstanceOfGameData.StreamPool along with it.
  • SqPack.FileCache and SqPack.CacheLock are now obsolete, and they do nothing.

@NotAdam NotAdam merged commit 77cc729 into NotAdam:master Mar 3, 2024
2 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