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

Improve MessageTemplateCache performance #883

Merged
merged 3 commits into from Oct 20, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+69 −67
Diff settings

Always

Just for now

cached perf fix

  • Loading branch information...
Sergey Komisarchik
Sergey Komisarchik committed Oct 19, 2016
commit fda5404b97289656866ee9f6be34d9a8be0e6c5a
@@ -12,35 +12,35 @@ JitModules=clrjit-v4.6.1586.0
Type=MessageTemplateCacheBenchmark_Cached Mode=Throughput
```
Method | Items | MaxDegreeOfParallelism | Median | StdDev | Scaled | Scaled-SD |
----------- |------ |----------------------- |------------ |----------- |------- |---------- |
**Dictionary** | **10** | **-1** | **5.1555 us** | **0.0507 us** | **1.00** | **0.00** |
Hashtable | 10 | -1 | 4.4010 us | 0.0434 us | 0.85 | 0.01 |
Concurrent | 10 | -1 | 4.4323 us | 0.0677 us | 0.86 | 0.02 |
**Dictionary** | **10** | **1** | **2.9110 us** | **0.1116 us** | **1.00** | **0.00** |
Hashtable | 10 | 1 | 2.8101 us | 0.1591 us | 0.97 | 0.07 |
Concurrent | 10 | 1 | 2.8076 us | 0.1195 us | 0.98 | 0.05 |
**Dictionary** | **20** | **-1** | **9.5123 us** | **0.1870 us** | **1.00** | **0.00** |
Hashtable | 20 | -1 | 5.7014 us | 0.0338 us | 0.60 | 0.01 |
Concurrent | 20 | -1 | 5.7452 us | 0.0450 us | 0.60 | 0.01 |
**Dictionary** | **20** | **1** | **4.4900 us** | **0.2552 us** | **1.00** | **0.00** |
Hashtable | 20 | 1 | 3.9176 us | 0.2345 us | 0.89 | 0.07 |
Concurrent | 20 | 1 | 3.8974 us | 0.2235 us | 0.88 | 0.07 |
**Dictionary** | **50** | **-1** | **27.0377 us** | **1.2542 us** | **1.00** | **0.00** |
Hashtable | 50 | -1 | 7.5979 us | 0.0627 us | 0.28 | 0.01 |
Concurrent | 50 | -1 | 7.6123 us | 0.0427 us | 0.28 | 0.01 |
**Dictionary** | **50** | **1** | **8.0037 us** | **0.5410 us** | **1.00** | **0.00** |
Hashtable | 50 | 1 | 7.1405 us | 0.5055 us | 0.90 | 0.08 |
Concurrent | 50 | 1 | 7.2504 us | 0.5599 us | 0.90 | 0.09 |
**Dictionary** | **100** | **-1** | **53.3566 us** | **7.5268 us** | **1.00** | **0.00** |
Hashtable | 100 | -1 | 10.1725 us | 0.0903 us | 0.19 | 0.02 |
Concurrent | 100 | -1 | 10.1390 us | 0.1140 us | 0.19 | 0.02 |
**Dictionary** | **100** | **1** | **13.4704 us** | **0.0694 us** | **1.00** | **0.00** |
Hashtable | 100 | 1 | 11.7881 us | 0.6524 us | 0.88 | 0.05 |
Concurrent | 100 | 1 | 12.0876 us | 0.8071 us | 0.91 | 0.06 |
**Dictionary** | **1000** | **-1** | **482.1057 us** | **17.5977 us** | **1.00** | **0.00** |
Hashtable | 1000 | -1 | 33.1846 us | 0.3355 us | 0.07 | 0.00 |
Concurrent | 1000 | -1 | 32.8517 us | 0.3190 us | 0.07 | 0.00 |
**Dictionary** | **1000** | **1** | **124.2795 us** | **0.7927 us** | **1.00** | **0.00** |
Hashtable | 1000 | 1 | 105.6937 us | 1.1198 us | 0.85 | 0.01 |
Concurrent | 1000 | 1 | 103.0948 us | 0.8157 us | 0.83 | 0.01 |
Method | Items | MaxDegreeOfParallelism | Median | StdDev | Scaled | Scaled-SD |
----------- |------ |----------------------- |-------------- |----------- |------- |---------- |
**Dictionary** | **10** | **-1** | **479.2330 us** | **8.4171 us** | **1.00** | **0.00** |
Hashtable | 10 | -1 | 31.3853 us | 0.9122 us | 0.07 | 0.00 |
Concurrent | 10 | -1 | 30.8517 us | 0.5337 us | 0.06 | 0.00 |
**Dictionary** | **10** | **1** | **118.6307 us** | **2.1275 us** | **1.00** | **0.00** |
Hashtable | 10 | 1 | 101.8377 us | 3.3030 us | 0.86 | 0.03 |
Concurrent | 10 | 1 | 99.8312 us | 2.0072 us | 0.85 | 0.02 |
**Dictionary** | **20** | **-1** | **814.2458 us** | **4.7079 us** | **1.00** | **0.00** |
Hashtable | 20 | -1 | 54.0605 us | 0.8628 us | 0.07 | 0.00 |
Concurrent | 20 | -1 | 54.0682 us | 1.1269 us | 0.07 | 0.00 |
**Dictionary** | **20** | **1** | **247.6677 us** | **3.9224 us** | **1.00** | **0.00** |
Hashtable | 20 | 1 | 212.1726 us | 7.2594 us | 0.85 | 0.03 |
Concurrent | 20 | 1 | 201.6514 us | 7.5841 us | 0.81 | 0.03 |
**Dictionary** | **50** | **-1** | **1,522.8901 us** | **7.7962 us** | **1.00** | **0.00** |
Hashtable | 50 | -1 | 123.5203 us | 2.2916 us | 0.08 | 0.00 |
Concurrent | 50 | -1 | 121.7588 us | 2.8585 us | 0.08 | 0.00 |
**Dictionary** | **50** | **1** | **591.6731 us** | **5.2648 us** | **1.00** | **0.00** |
Hashtable | 50 | 1 | 515.3277 us | 10.1826 us | 0.87 | 0.02 |
Concurrent | 50 | 1 | 493.4330 us | 4.9567 us | 0.83 | 0.01 |
**Dictionary** | **100** | **-1** | **2,469.4364 us** | **10.4088 us** | **1.00** | **0.00** |
Hashtable | 100 | -1 | 237.0286 us | 2.6360 us | 0.10 | 0.00 |
Concurrent | 100 | -1 | 238.5870 us | 3.0985 us | 0.10 | 0.00 |
**Dictionary** | **100** | **1** | **1,157.9635 us** | **8.0010 us** | **1.00** | **0.00** |
Hashtable | 100 | 1 | 982.2426 us | 16.9287 us | 0.85 | 0.02 |
Concurrent | 100 | 1 | 964.2989 us | 19.8753 us | 0.84 | 0.02 |
**Dictionary** | **1000** | **-1** | **2,479.2089 us** | **10.0258 us** | **1.00** | **0.00** |
Hashtable | 1000 | -1 | 244.9505 us | 3.0286 us | 0.10 | 0.00 |
Concurrent | 1000 | -1 | 239.5800 us | 3.2452 us | 0.10 | 0.00 |
**Dictionary** | **1000** | **1** | **1,164.8552 us** | **6.4559 us** | **1.00** | **0.00** |
Hashtable | 1000 | 1 | 1,002.4865 us | 10.4370 us | 0.86 | 0.01 |
Concurrent | 1000 | 1 | 973.6633 us | 13.2212 us | 0.84 | 0.01 |
@@ -12,35 +12,35 @@ dotnet cli version: 1.0.0-preview2-003131
Type=MessageTemplateCacheBenchmark_Cached Mode=Throughput
```
Method | Items | MaxDegreeOfParallelism | Median | StdDev | Scaled | Scaled-SD |
----------- |------ |----------------------- |------------ |----------- |------- |---------- |
**Dictionary** | **10** | **-1** | **5.4201 us** | **0.0512 us** | **1.00** | **0.00** |
Hashtable | 10 | -1 | 4.9545 us | 0.0347 us | 0.91 | 0.01 |
Concurrent | 10 | -1 | 4.9253 us | 0.0159 us | 0.91 | 0.01 |
**Dictionary** | **10** | **1** | **2.0893 us** | **0.0253 us** | **1.00** | **0.00** |
Hashtable | 10 | 1 | 1.9488 us | 0.0386 us | 0.93 | 0.02 |
Concurrent | 10 | 1 | 1.9073 us | 0.0197 us | 0.91 | 0.01 |
**Dictionary** | **20** | **-1** | **9.7756 us** | **0.2778 us** | **1.00** | **0.00** |
Hashtable | 20 | -1 | 6.0307 us | 0.0230 us | 0.61 | 0.02 |
Concurrent | 20 | -1 | 5.9965 us | 0.0173 us | 0.60 | 0.02 |
**Dictionary** | **20** | **1** | **3.4780 us** | **0.0507 us** | **1.00** | **0.00** |
Hashtable | 20 | 1 | 3.2690 us | 0.0749 us | 0.94 | 0.02 |
Concurrent | 20 | 1 | 3.0224 us | 0.0822 us | 0.87 | 0.03 |
**Dictionary** | **50** | **-1** | **29.9933 us** | **1.9805 us** | **1.00** | **0.00** |
Hashtable | 50 | -1 | 7.3773 us | 0.0626 us | 0.25 | 0.02 |
Concurrent | 50 | -1 | 7.2335 us | 0.0518 us | 0.24 | 0.02 |
**Dictionary** | **50** | **1** | **7.4501 us** | **0.0993 us** | **1.00** | **0.00** |
Hashtable | 50 | 1 | 7.0496 us | 0.1044 us | 0.94 | 0.02 |
Concurrent | 50 | 1 | 6.3908 us | 0.0815 us | 0.86 | 0.02 |
**Dictionary** | **100** | **-1** | **66.0669 us** | **10.1367 us** | **1.00** | **0.00** |
Hashtable | 100 | -1 | 9.9072 us | 0.1425 us | 0.15 | 0.02 |
Concurrent | 100 | -1 | 9.6922 us | 0.1097 us | 0.15 | 0.02 |
**Dictionary** | **100** | **1** | **14.1209 us** | **0.2217 us** | **1.00** | **0.00** |
Hashtable | 100 | 1 | 13.1885 us | 0.1276 us | 0.93 | 0.02 |
Concurrent | 100 | 1 | 12.0479 us | 0.2229 us | 0.85 | 0.02 |
**Dictionary** | **1000** | **-1** | **477.3456 us** | **15.2028 us** | **1.00** | **0.00** |
Hashtable | 1000 | -1 | 31.2365 us | 0.3421 us | 0.07 | 0.00 |
Concurrent | 1000 | -1 | 30.6801 us | 0.2434 us | 0.06 | 0.00 |
**Dictionary** | **1000** | **1** | **134.5746 us** | **1.0971 us** | **1.00** | **0.00** |
Hashtable | 1000 | 1 | 126.6081 us | 0.8346 us | 0.94 | 0.01 |
Concurrent | 1000 | 1 | 114.9060 us | 1.3409 us | 0.85 | 0.01 |
Method | Items | MaxDegreeOfParallelism | Median | StdDev | Scaled | Scaled-SD |
----------- |------ |----------------------- |-------------- |----------- |------- |---------- |
**Dictionary** | **10** | **-1** | **471.8337 us** | **12.2518 us** | **1.00** | **0.00** |
Hashtable | 10 | -1 | 30.1689 us | 0.6795 us | 0.06 | 0.00 |
Concurrent | 10 | -1 | 29.0805 us | 0.1960 us | 0.06 | 0.00 |
**Dictionary** | **10** | **1** | **130.2107 us** | **3.1653 us** | **1.00** | **0.00** |
Hashtable | 10 | 1 | 122.2643 us | 2.4861 us | 0.94 | 0.03 |
Concurrent | 10 | 1 | 111.4388 us | 1.5693 us | 0.86 | 0.02 |
**Dictionary** | **20** | **-1** | **807.0063 us** | **2.6482 us** | **1.00** | **0.00** |
Hashtable | 20 | -1 | 52.2398 us | 1.0080 us | 0.06 | 0.00 |
Concurrent | 20 | -1 | 51.2831 us | 0.3521 us | 0.06 | 0.00 |
**Dictionary** | **20** | **1** | **259.5397 us** | **7.4273 us** | **1.00** | **0.00** |
Hashtable | 20 | 1 | 245.7154 us | 7.1712 us | 0.94 | 0.04 |
Concurrent | 20 | 1 | 222.5680 us | 2.6695 us | 0.85 | 0.02 |
**Dictionary** | **50** | **-1** | **1,296.5404 us** | **21.9341 us** | **1.00** | **0.00** |
Hashtable | 50 | -1 | 121.7466 us | 1.9856 us | 0.09 | 0.00 |
Concurrent | 50 | -1 | 117.7603 us | 0.9613 us | 0.09 | 0.00 |
**Dictionary** | **50** | **1** | **650.9873 us** | **8.5592 us** | **1.00** | **0.00** |
Hashtable | 50 | 1 | 615.8303 us | 11.6568 us | 0.94 | 0.02 |
Concurrent | 50 | 1 | 557.0763 us | 6.8188 us | 0.86 | 0.02 |
**Dictionary** | **100** | **-1** | **2,330.0390 us** | **10.0342 us** | **1.00** | **0.00** |
Hashtable | 100 | -1 | 235.0997 us | 3.6531 us | 0.10 | 0.00 |
Concurrent | 100 | -1 | 227.1950 us | 2.0706 us | 0.10 | 0.00 |
**Dictionary** | **100** | **1** | **1,306.6364 us** | **60.9756 us** | **1.00** | **0.00** |
Hashtable | 100 | 1 | 1,214.4314 us | 18.8564 us | 0.92 | 0.04 |
Concurrent | 100 | 1 | 1,113.6760 us | 8.7944 us | 0.84 | 0.04 |
**Dictionary** | **1000** | **-1** | **2,338.3248 us** | **20.7148 us** | **1.00** | **0.00** |
Hashtable | 1000 | -1 | 238.6618 us | 1.8611 us | 0.10 | 0.00 |
Concurrent | 1000 | -1 | 232.2733 us | 1.5743 us | 0.10 | 0.00 |
**Dictionary** | **1000** | **1** | **1,311.6107 us** | **12.7315 us** | **1.00** | **0.00** |
Hashtable | 1000 | 1 | 1,246.3194 us | 8.1155 us | 0.95 | 0.01 |
Concurrent | 1000 | 1 | 1,136.7721 us | 15.0574 us | 0.87 | 0.01 |
@@ -63,11 +63,13 @@ public void Concurrent()
void Run<T>(Func<T> cacheFactory) where T : IMessageTemplateParser
{
var cache = cacheFactory();
var iterations = Math.Min(10000, Items * 100);

Parallel.ForEach(
_templateList,
Parallel.For(
0,
iterations,
new ParallelOptions() { MaxDegreeOfParallelism = MaxDegreeOfParallelism },
t => cache.Parse(t));
idx => cache.Parse(_templateList[idx % Items]));
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.