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: add member, mappable member and attribute caching #537

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

TimothyMakkison
Copy link
Collaborator

@TimothyMakkison TimothyMakkison commented Jul 4, 2023

Add member, mappable member and attribute caching

Description

Added member, mappable member and attribute caching to improve performance and reduce memory usage.

Splitting up changes from #530

Benchmarks

10ms time and 3000KB memory savings

Cache

Method Mean Error StdDev Gen0 Gen1 Allocated
Compile 2.491 ms 0.0391 ms 0.0366 ms 156.2500 31.2500 284.15 KB
LargeCompile 64.276 ms 1.2297 ms 1.2628 ms 1714.2857 714.2857 10713.9 KB

Original

Method Mean Error StdDev Gen0 Gen1 Allocated
Compile 2.640 ms 0.0524 ms 0.0490 ms 179.6875 46.8750 320.39 KB
LargeCompile 75.350 ms 1.4524 ms 1.3586 ms 2333.3333 833.3333 14283.01 KB
Method Mean Error StdDev Gen0 Gen1 Allocated
------------- ----------: ----------: ----------: ----------: ---------: ------------:
Compile 2.627 ms 0.0428 ms 0.0379 ms 179.6875 39.0625 326.46 KB
LargeCompile 72.979 ms 1.1195 ms 0.8740 ms 2285.7143 571.4286 14280.24 KB

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
  • The documentation is updated (as applicable)
  • Unit tests are added/updated
  • Integration tests are added/updated (as applicable, especially if feature/bug depends on roslyn or framework version in use)

@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Merging #537 (8bce46c) into main (85347e4) will decrease coverage by 0.26%.
The diff coverage is 91.15%.

❗ Current head 8bce46c differs from pull request most recent head 25e2b6f. Consider uploading reports for the commit 25e2b6f to get more accurate results

@@            Coverage Diff             @@
##             main     #537      +/-   ##
==========================================
- Coverage   91.96%   91.71%   -0.26%     
==========================================
  Files         147      158      +11     
  Lines        4656     5432     +776     
  Branches      588      693     +105     
==========================================
+ Hits         4282     4982     +700     
- Misses        254      305      +51     
- Partials      120      145      +25     
Impacted Files Coverage Δ
...numerables/EnsureCapacity/EnsureCapacityBuilder.cs 45.94% <42.10%> (-32.32%) ⬇️
...ok.Mapperly/Configuration/AttributeDataAccessor.cs 69.23% <64.58%> (-7.59%) ⬇️
...lders/NewInstanceObjectMemberMappingBodyBuilder.cs 79.58% <78.94%> (+0.79%) ⬆️
.../Descriptors/MappingBuilders/SpanMappingBuilder.cs 80.00% <80.00%> (ø)
src/Riok.Mapperly/Helpers/SymbolExtensions.cs 86.02% <83.33%> (-5.29%) ⬇️
...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 45 more

... and 2 files with indirect coverage changes

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

src/Riok.Mapperly/Helpers/SymbolExtensions.cs Outdated Show resolved Hide resolved
src/Riok.Mapperly/Helpers/SymbolExtensions.cs Outdated Show resolved Hide resolved
src/Riok.Mapperly/Descriptors/WellKnownTypes.cs Outdated Show resolved Hide resolved
src/Riok.Mapperly/Descriptors/WellKnownTypes.cs Outdated Show resolved Hide resolved
src/Riok.Mapperly/Descriptors/WellKnownTypes.cs Outdated Show resolved Hide resolved
@TimothyMakkison
Copy link
Collaborator Author

TimothyMakkison commented Jul 5, 2023

Thanks for the feedback, added SymbolAccessor etc.
Ran a quick check and memory usage is now 292.5 KB & 10715.43 KB not 100% sure why

src/Riok.Mapperly/Descriptors/SymbolAccessor.cs Outdated Show resolved Hide resolved
src/Riok.Mapperly/Descriptors/SymbolAccessor.cs Outdated Show resolved Hide resolved
@TimothyMakkison
Copy link
Collaborator Author

Thanks for the help. I've resolved the issues 😂

Benchmark

Method Mean Error StdDev Gen0 Gen1 Allocated
Compile 2.367 ms 0.0454 ms 0.0606 ms 152.3438 35.1563 273.75 KB
LargeCompile 61.346 ms 1.1614 ms 1.1407 ms 1714.2857 571.4286 10581.14 KB

@latonz latonz merged commit ff51d7d into riok:main Jul 11, 2023
12 checks passed
@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