Project

General

Profile

Feature #12497

GMP version of divmod may be slower

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

Status:
Assigned
Priority:
Normal
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.

History

Updated by shyouhei (Shyouhei Urabe) over 3 years ago

  • Assignee set to akr (Akira Tanaka)
  • Status changed from Open to Assigned

Also available in: Atom PDF