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

chore: common linq loop allocations, add small optimisations #555

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

TimothyMakkison
Copy link
Collaborator

@TimothyMakkison TimothyMakkison commented Jul 11, 2023

Remove linq allocations, add small optimisations

Description

Slightly microbenchmarky improvements, not sure about the manual foreach loops

  • Remove FirstOrDefault allocation from SymbolExtensions.ImplementsGeneric - 106KB - Func<INamedTypeSymbol, Boolean>
  • Remove Where allocation from SymbolAccessor.GetMappableMembers - 76KB - Func<ISymbol, Boolean>
  • Remove Where allocation from SymbolAccessor.GetAttributes - 150KB - Func<AttributeData, Boolean>
  • Use non string comparison NonNullableValueType check
  • Add IsRefLike check to GetEnumeratedType
  • Remove unneeded types.Get<int>() call from CollectionInfoBuilder.FindCountProperty

Related to #530

Benchmarks

200 KB saved, little change in speed.

Method Mean Error StdDev Gen0 Gen1 Allocated
Compile 1.441 ms 0.0206 ms 0.0237 ms 78.1250 15.6250 162.41 KB
LargeCompile 56.606 ms 1.1015 ms 1.4323 ms 1428.5714 428.5714 9367.77 KB

Original

Method Mean Error StdDev Gen0 Gen1 Allocated
Compile 1.450 ms 0.0288 ms 0.0374 ms 78.1250 19.5313 167.37 KB
LargeCompile 55.899 ms 1.0530 ms 1.3318 ms 1428.5714 428.5714 9579.64 KB

Changes

Checklist

  • The existing code style is followed
  • The commit message follows our guidelines
  • Performed a self-review of my code
  • Hard-to-understand areas of my code are commented

@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #555 (1f0c659) into main (85347e4) will decrease coverage by 0.27%.
The diff coverage is 91.17%.

❗ Current head 1f0c659 differs from pull request most recent head 8443d3d. Consider uploading reports for the commit 8443d3d to get more accurate results

@@            Coverage Diff             @@
##             main     #555      +/-   ##
==========================================
- Coverage   91.96%   91.70%   -0.27%     
==========================================
  Files         147      158      +11     
  Lines        4656     5448     +792     
  Branches      588      698     +110     
==========================================
+ Hits         4282     4996     +714     
- Misses        254      306      +52     
- Partials      120      146      +26     
Impacted Files Coverage Δ
.../Riok.Mapperly/Helpers/NullableSymbolExtensions.cs 92.98% <0.00%> (-2.02%) ⬇️
...numerables/EnsureCapacity/EnsureCapacityBuilder.cs 45.94% <42.10%> (-32.32%) ⬇️
...ok.Mapperly/Configuration/AttributeDataAccessor.cs 68.88% <64.58%> (-7.93%) ⬇️
...lders/NewInstanceObjectMemberMappingBodyBuilder.cs 79.58% <78.94%> (+0.79%) ⬆️
.../Descriptors/MappingBuilders/SpanMappingBuilder.cs 80.00% <80.00%> (ø)
...iptors/MappingBuilders/DictionaryMappingBuilder.cs 90.98% <85.00%> (+4.02%) ⬆️
...scriptors/InlineExpressionMappingBuilderContext.cs 95.91% <85.71%> (+0.79%) ⬆️
...Mapperly/Descriptors/UserMethodMappingExtractor.cs 93.77% <85.71%> (+0.08%) ⬆️
...escriptors/MappingBuilders/MemoryMappingBuilder.cs 88.46% <88.46%> (ø)
...rc/Riok.Mapperly/Configuration/StringMemberPath.cs 88.88% <88.88%> (ø)
... and 46 more

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@TimothyMakkison TimothyMakkison force-pushed the minor_optimisations branch 2 times, most recently from 954104a to ee67f5a Compare July 11, 2023 12:56
@latonz latonz enabled auto-merge (squash) July 12, 2023 08:37
@latonz latonz merged commit 8c8b5b5 into riok:main Jul 12, 2023
12 of 14 checks passed
@TimothyMakkison TimothyMakkison deleted the minor_optimisations branch July 12, 2023 13:07
@github-actions
Copy link

🎉 This PR is included in version 2.9.0-next.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

github-actions bot commented Aug 7, 2023

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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