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

NLog - ValueSerializer - Faster integer and enum #2326

Merged
merged 1 commit into from
Oct 10, 2017

Conversation

snakefoot
Copy link
Contributor

Trying to resolve #2323

@@ -59,6 +59,8 @@ private ValueSerializer()
private const int MaxValueLength = 512 * 1024;
private const string LiteralFormatSymbol = "l";

private readonly MruCache<Enum, string> _enumCache = new MruCache<Enum, string>(10000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that a bit big? (10000)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea. Just chose the same as for the DefaultJsonSerializer. Maybe there are more than 10000 enums in the world?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change it to 5000 for the both of them ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was more thinking of 1000. Or even lower. Could not image your using 1000 different enum values in 1 project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now changed it to 1500 (also for the Json-Converter)

@snakefoot
Copy link
Contributor Author

snakefoot commented Oct 9, 2017

@304NotModified Have cheated a little, since Integer.ToString is pretty much the same in all languages (when no format-string). And have also performed the same cheating for Enum (when no format string).

@snakefoot snakefoot force-pushed the StructuredTemplateEnumerator branch 2 times, most recently from ce9df47 to 8a42888 Compare October 9, 2017 22:43
@304NotModified
Copy link
Member

@304NotModified Have cheated a little as Integer.ToString is pretty much the same in all languages (when no format-string). And have also performed the same cheating for Enum (when no format string).

No problem if it's document in the source ;)

Otherwise it could get lost in refactoring

@snakefoot
Copy link
Contributor Author

No problem if it's document in the source ;)

Added a comment about the special optimization.

@snakefoot snakefoot force-pushed the StructuredTemplateEnumerator branch 2 times, most recently from 6878b1c to 394cb85 Compare October 9, 2017 23:09
@304NotModified 304NotModified added this to the 4.5 milestone Oct 9, 2017
@304NotModified
Copy link
Member

do we need to pref test this? Or are you sure it's faster?

@codecov
Copy link

codecov bot commented Oct 10, 2017

Codecov Report

Merging #2326 into master will decrease coverage by <1%.
The diff coverage is 62%.

@@           Coverage Diff           @@
##           master   #2326    +/-   ##
=======================================
- Coverage      82%     82%   -<1%     
=======================================
  Files         317     317            
  Lines       22676   22716    +40     
  Branches     2780    2784     +4     
=======================================
+ Hits        18588   18611    +23     
- Misses       3386    3404    +18     
+ Partials      702     701     -1

@snakefoot
Copy link
Contributor Author

snakefoot commented Oct 10, 2017

do we need to pref test this?

The enum printing is 100 pct faster, and the integer printing is 50 pct. faster (and both without allocations).

@snakefoot
Copy link
Contributor Author

@304NotModified Should be ready for review (again) :)

@304NotModified 304NotModified merged commit ca3c9b2 into NLog:master Oct 10, 2017
@304NotModified
Copy link
Member

great! Merged!

@304NotModified 304NotModified modified the milestones: 4.5, 4.5 beta 4 Oct 10, 2017
@snakefoot snakefoot deleted the StructuredTemplateEnumerator branch April 4, 2020 17:42
@snakefoot snakefoot modified the milestones: 4.5 beta 4, 4.5 Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants