chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] Avoid checking ports multiple times in wri


From: Mario Domenech Goulart
Subject: Re: [Chicken-hackers] [PATCH] Avoid checking ports multiple times in write, display, print and print*
Date: Thu, 17 Apr 2014 18:30:35 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Hi Peter,

On Thu, 17 Apr 2014 19:57:46 +0200 Peter Bex <address@hidden> wrote:

> On Fri, Apr 11, 2014 at 01:23:30AM +0000, Mario Domenech Goulart wrote:
> 
>> Please, review the attached patch.  It gives a slight performance
>> improvement for write, display, print and print*.
>
> Do you have a benchmark that shows the difference?  As far as I know
> the bottleneck is in the formatting code, not so much in the port
> checking.

Not highly scientific, but here's a simple one:

$ cat print-bench.scm
(define max-iters 2000000)

(time (let loop ((i 0))
        (unless (fx> i max-iters)
          (display "foo")
          (loop (fx+ i 1)))))

(time (let loop ((i 0))
        (unless (fx> i max-iters)
          (print "foo")
          (loop (fx+ i 1)))))

(time (let loop ((i 0))
        (unless (fx> i max-iters)
          (print 0 1 2 3 4 5 6 7 8 9)
          (loop (fx+ i 1)))))

## Before patch
$ csi -s print-bench.scm > /dev/null
1.208s CPU time, 0.024s GC time (major), 16/0 mutations (total/tracked), 
30/8553 GCs (major/minor)
1.336s CPU time, 0.04s GC time (major), 16/0 mutations (total/tracked), 35/9525 
GCs (major/minor)
11.832s CPU time, 0.232s GC time (major), 40000036/29135 mutations 
(total/tracked), 236/52522 GCs (major/minor)

## After patch
$ csi -s print-bench.scm > /dev/null
1.1s CPU time, 0.024s GC time (major), 16/0 mutations (total/tracked), 28/7914 
GCs (major/minor)
1.244s CPU time, 0.032s GC time (major), 16/0 mutations (total/tracked), 
33/8825 GCs (major/minor)
10.832s CPU time, 0.192s GC time (major), 40000036/37673 mutations 
(total/tracked), 205/45810 GCs (major/minor)

The actual purpose of the patch is to remove redundant checks.  The
performance improvement (even if small) is just a consequence.

With regard to your observation about the bottleneck, I totally agree
port checking is not the cause.

Best wishes.
Mario
-- 
http://parenteses.org/mario



reply via email to

[Prev in Thread] Current Thread [Next in Thread]