{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/17015","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/17015/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/17015/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/17015/events","html_url":"https://github.com/JuliaLang/julia/pull/17015","id":161075670,"number":17015,"title":"[WIP] implement BigInt (and BigFloat?) with native Array","user":{"login":"rfourquet","id":8462914,"avatar_url":"https://avatars.githubusercontent.com/u/8462914?v=3","gravatar_id":"","url":"https://api.github.com/users/rfourquet","html_url":"https://github.com/rfourquet","followers_url":"https://api.github.com/users/rfourquet/followers","following_url":"https://api.github.com/users/rfourquet/following{/other_user}","gists_url":"https://api.github.com/users/rfourquet/gists{/gist_id}","starred_url":"https://api.github.com/users/rfourquet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfourquet/subscriptions","organizations_url":"https://api.github.com/users/rfourquet/orgs","repos_url":"https://api.github.com/users/rfourquet/repos","events_url":"https://api.github.com/users/rfourquet/events{/privacy}","received_events_url":"https://api.github.com/users/rfourquet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":30,"created_at":"2016-06-19T14:33:06Z","updated_at":"2016-06-22T15:01:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/17015","html_url":"https://github.com/JuliaLang/julia/pull/17015","diff_url":"https://github.com/JuliaLang/julia/pull/17015.diff","patch_url":"https://github.com/JuliaLang/julia/pull/17015.patch"},"body":"This implements what was on the mind of many. `BigInt` has now two fields, an array (of type `Limb` to keep compatibility with GMP, but ideally would be changed to `UInt`), and a `size` like before (again for compatibility, but also to allow in the future the optimization to store small integers inline, which for now is not convincing (AFAICT), probably because even an `#undef` array field forces the object to be heap allocated).\r\nWhat was `BigInt` is now called `MPZ`, and there are simple routines to convert back and forth when `ccall`ing into libgmp.\r\n\r\nI didn't test much the performances, but for the simple tests of addition given occasionally by @wbhart  or by @skariel [here](https://github.com/JuliaLang/julia/pull/10084#issuecomment-73406923), I get roughly a 3x speedup on my machine, with 2/3 of the number of allocations, but (a bit less than) twice as much total memory allocated.\r\n\r\nThis is WIP as it's a very mechanical work, so there will be errors and omissions. I think the same transformation can be applied to `BigFloat`.\r\nThis is branched off unmerged #13815, so only one new commit here. "},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/227772479","html_url":"https://github.com/JuliaLang/julia/pull/17015#issuecomment-227772479","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/17015","id":227772479,"user":{"login":"rfourquet","id":8462914,"avatar_url":"https://avatars.githubusercontent.com/u/8462914?v=3","gravatar_id":"","url":"https://api.github.com/users/rfourquet","html_url":"https://github.com/rfourquet","followers_url":"https://api.github.com/users/rfourquet/followers","following_url":"https://api.github.com/users/rfourquet/following{/other_user}","gists_url":"https://api.github.com/users/rfourquet/gists{/gist_id}","starred_url":"https://api.github.com/users/rfourquet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfourquet/subscriptions","organizations_url":"https://api.github.com/users/rfourquet/orgs","repos_url":"https://api.github.com/users/rfourquet/repos","events_url":"https://api.github.com/users/rfourquet/events{/privacy}","received_events_url":"https://api.github.com/users/rfourquet/received_events","type":"User","site_admin":false},"created_at":"2016-06-22T15:01:57Z","updated_at":"2016-06-22T15:01:57Z","body":"I don't exactly understand: if you `unsafe_wrap` the global `MPZ` data into the new `BigIng` object, then the global `MPZ` needs to be re-initialized (and a buffer reallocated) for the subsequent call, right? So I don't see what your proposition addresses compared the this branch. Also, in my experiment where I avoid using globals, I initialized a temporary `MPZ` to serve as output argument before each `ccall`; it was then even slower to use `unsafe_wrap(..., true)` when creating the `BigInt` rather than allocating a new array field for it and copying over from the `MPZ` result (at least for `BigInt`'s with 2/3 limbs). "}}
{"actor":{"display_login":"rfourquet"}}