c/1046: gcc less efficient than jdk for recursion!

bouchard@onera.fr bouchard@onera.fr
Tue Dec 12 02:56:00 GMT 2000


>Number:         1046
>Category:       c
>Synopsis:       gcc less efficient than jdk for recursion!
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 12 02:56:02 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     bouchard@onera.fr
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
Pentium III 500 MHz + 128 MB
RedHat Linux 6.2 - glibc-2.1.3-21

SUN's JAVA:
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
>Description:
I have 2 small codes that implement a fibonacci sequence
with recursion, one in C, the other in Java.

Here are my results:

time fib
267914296
21.36user 0.01system 0:21.36elapsed 100%CPU

time java Fib
267914296
17.54user 0.15system 0:17.83elapsed 99%CPU

time java Fib 1
1
0.31user 0.12system 0:00.61elapsed 70%CPU

(so 0.61s is needed to load the Java environment)

Conclusion:

The Java code is 19% faster ((1-(17.83-0.61)/21.36)*100)
than the C one. It is even worse with IBM's SDK (27%).

So I think that recursion is not well implemented in gcc.
>How-To-Repeat:
make
time fib
time java Fib
time java Fib 1
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-tar; name="fibonacci.tar.gz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="fibonacci.tar.gz"

H4sIABICNjoAA+2WUW/TMBDH+xp/itNYpWSswU7SVuq6TVPREKiIhz6WPXhumgZSp0rcSgjtu3NO
SsOGoCCtA8T9Hmqf73Rn2f5fOk9vcy2VSl+0DgbnEe93uzhWPBzreT8Q3YjXcUJ0edCC7uG21LAu
jSwAWkWem5/F7fP/o8x3948zXx2kBhec96Loh/cfhr36/sN+ENk4EUSCt4AfZDcP+M/v/1mqVbae
xTAszSzN/cUFu7eU4avANZZqA/hCXDtqDz4zp4jNutDgahieQ+DBJQgYVDEaOiA8eL4zAu+M3dU5
ljLVVRJZJOoU1AIP/+QEjU2VtEoP5+BaN1zYNJcgTZ7ahc1U3HhYIwrOmLMqMHbuHrVn7/XRaV3K
wzpf98VtyT99un8/jf6v8aY/yI18/Bp79d8LG/13cS5CHvVJ/0/Ban2bpQpUJssS8AlYEeKJGFzb
ur5X/u9K30HtO9ts29ybPJ3VvWBiUMjJ9MY2hLJO/20TKP0s1olZYC/gttBrbeIkLvyVLMoYjSpm
ypu+4Ew+lSZe+vna+FWPyLTbNIc7agr3afT/Vn6M52kWP36NffoPol7z/y8MrP5FGJH+n4LRCIWW
KMVG1+OrVxM0Ou8CNn65s0rG3uwMPKokNiD8EDrJQOc6xnDGrsZj9OJTsh3Er3oJYzLLBnDsos9j
TGWx1AP8OC+hM4cTP9952nU8yrddfX6YY38V+uuyHhwPSbIEQRAEQRAEQRAEQRAEQRAEQRAE8Ut8
AYdKCncAKAAA


More information about the Gcc-bugs mailing list