chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] [PATCH] Improve srfi-13 performance quite a bit by inl


From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Improve srfi-13 performance quite a bit by inlining optarg handling
Date: Fri, 27 Sep 2019 19:18:37 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

Hi all,

Attached is a relatively straightforward patch for SRFI-13.  It changes
the let-string-start+end macro (and also let-string-start+end2 but that
isn't exported) so that it uses let-optionals* and the entire picking
apart of the rest arg list into start/end can be completely inlined,
as well as checking the values against the string length(s).

The old version was written in terms of the awkward string-parse-start+end
and string-parse-final-start+end procedures, which could of course not be
inlined.

The performance benefit seems to be quite a bit:  total runtime of the
srfi-13 benchmark suite in chicken-benchmarks went from 58s to 36s.

Here's the cpu time (right is with patch, left without.  Higher numbers
are better):

===
=== cpu-time
===

Programs                   [1]       [2]
========================================
string-ci-equal___________1.00______2.39
string-concatenate________1.00______1.00
string-contains___________1.00______2.45
string-contains-ci________1.00______2.22
string-drop_______________1.00______1.00
string-drop-right_________1.00______1.00
string-equal______________1.00______2.37
string-join_______________1.00______1.00
string-prefix_____________1.00______1.85
string-prefix-ci__________1.00______1.80
string-suffix_____________1.00______1.83
string-suffix-ci__________1.00______1.74
string-take_______________1.00______1.01
string-take-right_________1.00______1.01

NOTE: The moving of the ##sys#check-fixnum calls in string-pad,
string-pad-right, string-hash and string-hash-ci are not strictly
needed to improve the performance with current CHICKEN, but they are
useful for a patch I'm working on which eliminates the need to cons up
a rest list for optional arguments.

This also applies to the note I added regarding complex expressions.
Feel free to remove it.

Cheers,
Peter

Attachment: srfi-13.patch
Description: Text Data

Attachment: signature.asc
Description: PGP signature


reply via email to

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