|Summary:||ConcurrectDictionary is 100x slower|
|Product:||iOS||Reporter:||Rolf Bjarne Kvinge [MSFT] <rolf>|
|Component:||Mono runtime / AOT compiler||Assignee:||Zoltan Varga <vargaz>|
|Severity:||normal||CC:||brendan.zagaeski, david, Felix.alcala, jon.goldberger, kumpera, mono-bugs+monotouch, Rajneeshk, sebastien|
|Tags:||Is this bug a regression?:||---|
|Last known good build:|
|Bug Depends on:|
Description Rolf Bjarne Kvinge [MSFT] 2016-01-20 18:07:30 UTC
Test case: * https://github.com/rolfbjarne/TestApp - branch: bug37783 Repro: * Run on device. Results: mtouch 220.127.116.11 (monotouch-9.1.0-branch: bae2cdb) > Running ConcurrentDictionary test... > Added in 10ms > Fetched 100000 existing in 9ms > Fetched 100000 non-existing in 8ms > ---- > Running Dictionary test... > Added in 1ms > Fetched 10000000 existing in 737ms > Fetched 10000000 non-existing in 632ms > ---- mtouch 18.104.22.168 (cycle6-xi: b82c335) > Running ConcurrentDictionary test... > Added in 103ms > Fetched 100000 existing in 1156ms > Fetched 100000 non-existing in 1138ms > ---- > Running Dictionary test... > Added in 8ms > Fetched 10000000 existing in 11273ms > Fetched 10000000 non-existing in 10464ms > ---- mtouch master (e6e5d94034420925c40e298971836eed031904dd) > Running ConcurrentDictionary test... > Added in 84ms > Fetched 100000 existing in 1078ms > Fetched 100000 non-existing in 1057ms > ---- > Running Dictionary test... > Added in 3ms > Fetched 10000000 existing in 1808ms > Fetched 10000000 non-existing in 1372ms > ---- ConcurrectDictionary is 100x slower (1s vs 10ms) in master than in 9.1.0 Dictionary is 2.5x slower (1.8s vs 0.7s) in master than in 9.1.0 (interestingly Dictionary was 15x slower in 9.2.1, but that seems to be fixed). An instruments trace seems to indicate this is AOT related: https://www.dropbox.com/s/vxe9cd0oj2gqj5v/Screenshot%202016-01-20%2019.05.54.png?dl=0 (also I have not been able to reproduce this slowdown in the simulator).
Comment 2 Zoltan Varga 2016-01-21 17:52:06 UTC
This is caused by the partial sharing changes, i.e. List<int> is now shared with List<AnEnum> for example.
Comment 3 Zoltan Varga 2016-01-21 19:32:03 UTC
The ConcurrentDictionary slowdown should be fixed by mono 7003343902d700e5f2770dc367be18876d163e50. As for the dictionary slowdown, its somewhat expected, gshared code is slower than non-gshared code. Will seem what more can be done there.
Comment 4 Zoltan Varga 2016-01-21 20:57:08 UTC
The slowdown on dictionary doesn't look easily fixable without disabling sharing or a significant rewrite of the generic sharing code.
Comment 5 Rolf Bjarne Kvinge [MSFT] 2016-01-22 08:29:41 UTC
@Zoltan, I've filed bug #37894 for the dictionary slowdown, since it seems like a separate issue, and I'm closing this bug considering it's about ConcurrentDictionary only. And is this something that can be backported to C6?
Comment 6 Zoltan Varga 2016-01-22 13:18:11 UTC
Comment 8 Zoltan Varga 2016-01-22 17:09:42 UTC
The backport is on this branch: https://github.com/mono/mono/tree/4.2.0-37846
Comment 9 Rolf Bjarne Kvinge [MSFT] 2016-01-22 17:44:15 UTC
Comment 11 Sebastien Pouliot 2016-02-26 22:36:08 UTC
cherrypick in mono/mono-4.2.0-branch 097695ae35f9c684d79a900078e878542e69167b maccore/cycle6-xi bumped in e32859df16b0444e2eb26a1bd4eb47f4a0b540c8
Comment 12 Rajneesh Kumar 2016-03-03 17:26:31 UTC
I have checked this issue with C6SR2 build: monotouch-22.214.171.124_40f23b547a5f254638b625b5477d2e3d64dc017d and observed that the current ConcurrentDictionary test... is 17 ms. Screencast: http://www.screencast.com/t/oBxNAo5olz0 This issue has been fixed and working as expected, hence I closing this issue. Thanks..! Environment Info: https://gist.github.com/saurabh360/36ff40b7178a2eca6534 Application Output: https://gist.github.com/saurabh360/3e3394fb51c8dbb7d325