[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] [PATCH] read-line, etc.
From: |
Jim Ursetto |
Subject: |
[Chicken-hackers] [PATCH] read-line, etc. |
Date: |
Thu, 9 Apr 2009 15:47:54 -0500 |
I'd like to commit the attached patch to SVN HEAD, if it looks good.
1) Changes getc to getc_unlocked if available. We don't need locked
IO, and getc_unlocked is typically a macro, unlike getc.
2) A static 1024 byte buffer is allocated per port upon the first call
to read-line, instead of allocating a fresh 256-byte buffer per call.
This alleviates some GC pressure.
Timing data is attached but here is a summary: it approximately
doubles the performance of read-line.
$ wc -lc common.log
1799840 396072320 common.log
Pre-patch:
./for-each
9.843 seconds elapsed 3.399 seconds in (major) GC 3 mutations 6 minor
GCs 7657 major GCs
./for-each -:h1m
6.472 seconds elapsed 0.04 seconds in (major) GC 3 mutations 111 minor
GCs 78 major GCs
Post-patch:
./for-each
4.489 seconds elapsed 1.54 seconds in (major) GC 4 mutations 6 minor
GCs 3401 major GCs
./for-each -:h1m
2.992 seconds elapsed 0.011 seconds in (major) GC 4 mutations 1482
minor GCs 17 major GCs
These tests were conducted on OS X, but Linux tests show approximately
the same speedup.
With these changes, read-line performance is on par with Ruby, which
takes about 2.8 seconds to
iterate through the same 400MB file.
The patch works for read-char as well, but due to Scheme overhead, the
speedup is only about 10%.
(It still takes a full 100 seconds to iterate through with plain
(read-char), 110 seconds without the patch.)
getc+static.diff.txt
Description: Text document
timings.txt
Description: Text document
for-each.scm
Description: Binary data
- [Chicken-hackers] [PATCH] read-line, etc.,
Jim Ursetto <=