{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/993","labels_url":"https://api.github.com/repos/dotnet/coreclr/issues/993/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/993/comments","events_url":"https://api.github.com/repos/dotnet/coreclr/issues/993/events","html_url":"https://github.com/dotnet/coreclr/issues/993","id":76027307,"number":993,"title":".Net 4.6 RC x64 is twice as slow as x86 (release version)","user":{"login":"BijanVan","id":8338504,"avatar_url":"https://avatars.githubusercontent.com/u/8338504?v=3","gravatar_id":"","url":"https://api.github.com/users/BijanVan","html_url":"https://github.com/BijanVan","followers_url":"https://api.github.com/users/BijanVan/followers","following_url":"https://api.github.com/users/BijanVan/following{/other_user}","gists_url":"https://api.github.com/users/BijanVan/gists{/gist_id}","starred_url":"https://api.github.com/users/BijanVan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BijanVan/subscriptions","organizations_url":"https://api.github.com/users/BijanVan/orgs","repos_url":"https://api.github.com/users/BijanVan/repos","events_url":"https://api.github.com/users/BijanVan/events{/privacy}","received_events_url":"https://api.github.com/users/BijanVan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/coreclr/labels/CodeGen","name":"CodeGen","color":"d4c5f9"},{"url":"https://api.github.com/repos/dotnet/coreclr/labels/optimization","name":"optimization","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-13T15:34:03Z","updated_at":"2015-05-13T20:27:16Z","closed_at":null,"body":"Net 4.6 RC x64 is twice as slow as x86 (release version):\r\n\r\nConsider this piece of code:\r\n\r\nclass SpectralNorm\r\n{\r\n    public static void Main(String[] args)\r\n    {\r\n        int n = 5500;\r\n        if (args.Length > 0) n = Int32.Parse(args[0]);\r\n\r\n        var spec = new SpectralNorm();\r\n        var watch = Stopwatch.StartNew();\r\n        var res = spec.Approximate(n);\r\n\r\n        Console.WriteLine(\"{0:f9} -- {1}\", res, watch.Elapsed.TotalMilliseconds);\r\n    }\r\n\r\n    double Approximate(int n)\r\n    {\r\n        // create unit vector\r\n        double[] u = new double[n];\r\n        for (int i = 0; i < n; i++) u[i] = 1;\r\n\r\n        // 20 steps of the power method\r\n        double[] v = new double[n];\r\n        for (int i = 0; i < n; i++) v[i] = 0;\r\n\r\n        for (int i = 0; i < 10; i++)\r\n        {\r\n            MultiplyAtAv(n, u, v);\r\n            MultiplyAtAv(n, v, u);\r\n        }\r\n\r\n        // B=AtA         A multiplied by A transposed\r\n        // v.Bv /(v.v)   eigenvalue of v \r\n        double vBv = 0, vv = 0;\r\n        for (int i = 0; i < n; i++)\r\n        {\r\n            vBv += u[i] * v[i];\r\n            vv += v[i] * v[i];\r\n        }\r\n\r\n        return Math.Sqrt(vBv / vv);\r\n    }\r\n\r\n\r\n    /* return element i,j of infinite matrix A */\r\n    double A(int i, int j)\r\n    {\r\n        return 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1);\r\n    }\r\n\r\n    /* multiply vector v by matrix A */\r\n    void MultiplyAv(int n, double[] v, double[] Av)\r\n    {\r\n        for (int i = 0; i < n; i++)\r\n        {\r\n            Av[i] = 0;\r\n            for (int j = 0; j < n; j++) Av[i] += A(i, j) * v[j];\r\n        }\r\n    }\r\n\r\n    /* multiply vector v by matrix A transposed */\r\n    void MultiplyAtv(int n, double[] v, double[] Atv)\r\n    {\r\n        for (int i = 0; i < n; i++)\r\n        {\r\n            Atv[i] = 0;\r\n            for (int j = 0; j < n; j++) Atv[i] += A(j, i) * v[j];\r\n        }\r\n    }\r\n\r\n    /* multiply vector v by matrix A and then by matrix A transposed */\r\n    void MultiplyAtAv(int n, double[] v, double[] AtAv)\r\n    {\r\n        double[] u = new double[n];\r\n        MultiplyAv(n, v, u);\r\n        MultiplyAtv(n, u, AtAv);\r\n    }\r\n}\r\nOn my machine x86 release version takes 4.5 seconds to complete, while the x64 takes 9.5 seconds. Is there any specific flag/setting needed for the x64?\r\n\r\n===== UPDATE =========\r\n\r\nIt turns out that RyuJIT has a role in this issue. If useLegacyJit is enabled in app.config, the the result is different and this time x64 is faster.\r\n\r\n    <?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n    <configuration>\r\n      <startup>\r\n        <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.6\"/>\r\n      </startup>\r\n      <runtime>\r\n          <useLegacyJit enabled=\"1\" />\r\n     </runtime>\r\n    </configuration>\r\nReference:\r\nhttp://stackoverflow.com/questions/30195356/net-4-6-rc-x64-is-twice-as-slow-as-x86-release-version"},"comment":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/comments/101805661","html_url":"https://github.com/dotnet/coreclr/issues/993#issuecomment-101805661","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/993","id":101805661,"user":{"login":"billwert","id":4523120,"avatar_url":"https://avatars.githubusercontent.com/u/4523120?v=3","gravatar_id":"","url":"https://api.github.com/users/billwert","html_url":"https://github.com/billwert","followers_url":"https://api.github.com/users/billwert/followers","following_url":"https://api.github.com/users/billwert/following{/other_user}","gists_url":"https://api.github.com/users/billwert/gists{/gist_id}","starred_url":"https://api.github.com/users/billwert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/billwert/subscriptions","organizations_url":"https://api.github.com/users/billwert/orgs","repos_url":"https://api.github.com/users/billwert/repos","events_url":"https://api.github.com/users/billwert/events{/privacy}","received_events_url":"https://api.github.com/users/billwert/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T20:27:16Z","updated_at":"2015-05-13T20:27:16Z","body":"cc @vancem @CarolEidt @BruceForstall "}}