General library improvements#17
Conversation
Correction based on Copilot's comments
perf(Simplified the cycle in the method 'ReadMap') perf(Duplicate error message lines have been removed)
perf(Properties are extracted from types in a separate class); perf(Improved retrieval of an object by MessagePack data type); perf(Duplicate and unused code has been removed); perf(Improved information about MessagePack data type errors in converters);
perf(The data for comparing serialization and deserialization speeds has been replaced with more relevant data);
|
@RelaxSpirit I've fixed the checklist for you. |
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (57)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@RelaxSpirit thank you for improving the library. In the future, please make smaller PRs with targeted changes (like moving all using declaration to the top of the files). It makes so much easier to review then. Bulk changes make it harder to review. In case there are many PRs in the same batch, it's OK to have a working branch and PR against it. When completed, we can merge the branch into main. 😉 |
|
There was a problem hiding this comment.
Pull request overview
This pull request implements a comprehensive set of improvements to the nanoFramework MessagePack library focused on performance optimization and code quality. The PR addresses performance bottlenecks identified through profiling, including inefficient type comparisons, redundant reflection operations, and suboptimal data type handling.
Changes:
- Refactored type comparison from hash code-based to direct type comparison for better performance
- Optimized MessagePack data type handling with grouped processing and delegation pattern
- Extracted property handling logic into a dedicated
MemberPropertyInfoclass for nanoFramework - Enhanced error messages in converters with specific type information
- Added unit tests for class inheritance scenarios and type comparison benchmarks
- Updated benchmark test data to more realistic scenarios and added comprehensive device-specific results
Reviewed changes
Copilot reviewed 57 out of 57 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| TypeCompareBenchmark.cs | New benchmark comparing type comparison methods (hash vs direct) |
| ComparativeTestObjects.cs | Replaced complex nested test object with simpler, more realistic benchmark data |
| Program.cs | Enhanced benchmark output with device-specific information and improved formatting |
| BaseIterationBenchmark.cs | Centralized iteration count logic based on device type (virtual vs physical) |
| TestInheritorClass.cs, TestBaseClass.cs | New test classes for validating property inheritance serialization |
| UnitTests.cs | Added test for inherited class serialization/deserialization |
| PropertyUtility.cs | Refactored to use new MemberPropertyInfo class for nanoFramework property extraction |
| FieldUtility.cs | Improved null handling and code clarity |
| ExceptionUtility.cs | Consolidated number serialization exceptions and improved error messages |
| MemberPropertyInfo.cs | New class extracting property information from MethodInfo in nanoFramework |
| TypeValueDictionary.cs | New type-keyed dictionary replacing Hashtable for converter storage |
| MemberMapping.cs | Simplified property/field handling with clearer API |
| MemoryStreamReader.cs | Added leaveOpen parameter for stream disposal control |
| MessagePackSerializer.cs | Added leaveOpen parameter to Deserialize method |
| All Converters | Added null/type validation, improved error messages, removed duplicate code |
| ObjectTokenHelper.cs | Fixed typo in method name (GetMassagePackObjectTokens → GetMessagePackObjectTokens) |
| NumberConverterHelper.cs | Removed redundant helper methods, simplified byte value handling |
| ConverterContext.cs | Replaced Hashtable with TypeValueDictionary, optimized data type handling with delegation pattern |
| README.md | Updated with new benchmark results across multiple devices |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
josesimoes
left a comment
There was a problem hiding this comment.
@RelaxSpirit please address Copilot review comments. If you disagree with something, let's discuss it.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@josesimoes Please forgive me for such a big PR. I corrected all of the Copilot comments and what he missed. |
RelaxSpirit
left a comment
There was a problem hiding this comment.
Corrections based on Copilot comments



Description
Motivation and Context
Using the library showed that the deserialization time is significantly different from the serialization time.
Performance measurements revealed a number of places with suboptimal code:
How Has This Been Tested?
Tested with all existing tests in the solution + a new one has been added.
Screenshots
Types of changes
Checklist: