Skip to content

Commit

Permalink
Streamline rent/return on ArrayPool (#55710)
Browse files Browse the repository at this point in the history
* Streamline rent/return on ArrayPool

- Stop storing and using a _bucketArraySizes.  It's cheaper to recompute the shift on each use than it is to index into the array (with a bounds check).  Plus less memory.
- The 99% case is renting a positive length for pooled array sizes (especially now that we've bumped the limit up to a gig).  Move the checks for lengths <= 0 to after the check for whether the length is poolable.
- Move arrays into locals to enable the JIT to eliminate some bounds checks.
- Use ThrowHelpers where we already have them
- Move non-generic helpers out of generic class into Utilities
- Consolidate buffer allocation in Rent to a single line
- Reorganize TLS checks to be as early as possible
- Use FastMod instead of % in per-core stacks

* Address PR feedback
  • Loading branch information
stephentoub authored Jul 16, 2021
1 parent 145e588 commit d4dcde1
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 179 deletions.
Loading

0 comments on commit d4dcde1

Please sign in to comment.