Project

General

Profile

Actions

Feature #12497

open

GMP version of divmod may be slower

Added by mame (Yusuke Endoh) over 8 years ago. Updated over 8 years ago.

Status:
Assigned
Target version:
-
[ruby-core:76054]

Description

The benchmark program pidigits.rb runs faster if USE_GMP is disabled for divmod.

$ time ./miniruby.orig pidigits.rb 10000 > /dev/null

real    0m5.932s
user    0m5.740s
sys     0m0.188s
$ time ./miniruby.patched pidigits.rb 10000 > /dev/null

real    0m3.212s
user    0m3.056s
sys     0m0.152s
diff --git a/bignum.c b/bignum.c
index 767659d..33a172e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -2813,12 +2813,6 @@ rb_big_divrem_gmp(VALUE x, VALUE y)
 static void
 bary_divmod_branch(BDIGIT *qds, size_t qn, BDIGIT *rds, size_t rn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
 {
-#ifdef USE_GMP
-    if (GMP_DIV_DIGITS < xn) {
-        bary_divmod_gmp(qds, qn, rds, rn, xds, xn, yds, yn);
-        return;
-    }
-#endif
     bary_divmod_normal(qds, qn, rds, rn, xds, xn, yds, yn);
 }
 

We can possibly tune performance.

Actions

Also available in: Atom PDF

Like0
Like0