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

Object Pooling #822

Merged
merged 6 commits into from
Jan 15, 2025
Merged

Object Pooling #822

merged 6 commits into from
Jan 15, 2025

Conversation

nbollis
Copy link
Member

@nbollis nbollis commented Jan 14, 2025

PR Classification

New feature to improve performance by reducing memory allocations.

PR Summary

Introduced object pooling for Dictionary, HashSet, and List instances.

  • Added DictionaryPool<TKey, TValue>, HashSetPool<T>, and ListPool<T> classes in respective files.
  • Modified DigestionAgent.cs to use HashSetPool<int> for pooling HashSet instances.
  • Added unit tests in ObjectPoolTests.cs for the new pooling classes.

Added `using` directive for `MzLibUtil`. Introduced a static readonly `HashSetPool<int>` named `HashSetPool` to manage a pool of hash sets. Updated `DigestionAgent` constructor to initialize `HashSetPool`. Refactored `GetDigestionSiteIndices` to use a hash set from `HashSetPool` for storing indices, ensuring no duplicates. Explicitly added start and end of protein sequence as cleavage sites. Implemented `try-finally` block to return hash set to pool after use. Final list of indices is now sorted before returning.
@nbollis nbollis added Maintenance The user isn't impacted by it, it's purely behind the scenes New Feature labels Jan 14, 2025
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.41%. Comparing base (5443e36) to head (81aefc5).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #822      +/-   ##
==========================================
+ Coverage   77.37%   77.41%   +0.04%     
==========================================
  Files         220      223       +3     
  Lines       33197    33263      +66     
  Branches     3441     3444       +3     
==========================================
+ Hits        25686    25752      +66     
  Misses       6939     6939              
  Partials      572      572              
Files with missing lines Coverage Δ
mzLib/MzLibUtil/ObjectPools/DictionaryPool.cs 100.00% <100.00%> (ø)
mzLib/MzLibUtil/ObjectPools/HashSetPool.cs 100.00% <100.00%> (ø)
mzLib/MzLibUtil/ObjectPools/ListPool.cs 100.00% <100.00%> (ø)
mzLib/Omics/Digestion/DigestionAgent.cs 90.32% <100.00%> (+0.84%) ⬆️

@nbollis nbollis marked this pull request as ready for review January 14, 2025 02:52
RayMSMS
RayMSMS previously approved these changes Jan 15, 2025
trishorts
trishorts previously approved these changes Jan 15, 2025
@nbollis nbollis dismissed stale reviews from trishorts and RayMSMS via 81aefc5 January 15, 2025 21:19
@nbollis nbollis merged commit 331ee1d into smith-chem-wisc:master Jan 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance The user isn't impacted by it, it's purely behind the scenes New Feature ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants