From: Damien Mattei <damien.mattei@gmail.com>
To: guile-devel@gnu.org
Subject: Re: [PATCH] Extensions for SRFI-171 (Transducers)
Date: Sat, 24 Dec 2022 14:25:28 +0100 [thread overview]
Message-ID: <CADEOadd0DXS7u5XEeNt31FhTxmyP5BoP3v-oOLPkFDq9UWPGUA@mail.gmail.com> (raw)
In-Reply-To: <CADEOaddYGBGt03uS-QZLo==Xvoq2xygx_7KcAjUWfLXQOtVjqQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6371 bytes --]
that is strange but with more ,the same ,tests i have no more speed up:
with Racket versions of srfi 171
{unified-minterms-set-2 <+ (filter (λ (x) x) unified-minterms-set-1)} ;;
remove #f results
;; (nodebug
;; {unified-minterms-set-2-length <+ (length unified-minterms-set-2)}
;; (dv unified-minterms-set-2-length))
{unified-minterms-set <+ (remove-duplicates unified-minterms-set-2)} ;;
(remove-duplicates-sorted unified-minterms-set-2)} ;; uniq MODIF
;; C12 in Terminal mode with MacOS Ventura M1 and 32"
;; (nodebug
;; {unified-minterms-set-uniq-length <+ (length unified-minterms-set)}
;; (dv unified-minterms-set-uniq-length))
;;{unified-minterms-set <+ (remove-duplicates (filter (λ (x) x)
unified-minterms-set-1))} ;; C12 in Terminal mode with MacOS Ventura M1 and
32"
;;{unified-minterms-set <+ (list-transduce (compose (tfilter (λ (x) x))
(tdelete-duplicates)) rcons unified-minterms-set-1)} ;; C12 in Terminal
mode with MacOS Ventura M1 and 31"
and Guile:
;; 8'04" MacOS Ventura M1 for C12 ,50" for C11
;;{unified-minterms-set-2 <+ (filter (λ (x) x) unified-minterms-set-1)}
;; remove #f results
;; (nodebug
;; {unified-minterms-set-2-length <+ (length unified-minterms-set-2)}
;; (dv unified-minterms-set-2-length))
;;{unified-minterms-set <+ (remove-duplicates unified-minterms-set-2)}
;;(remove-duplicates-sorted unified-minterms-set-2)} ;; uniq MODIF
;; (nodebug
;; {unified-minterms-set-uniq-length <+ (length unified-minterms-set)}
;; (dv unified-minterms-set-uniq-length))
{unified-minterms-set <+ (remove-duplicates (filter (λ (x) x)
unified-minterms-set-1))} ;; 59" for C11, 8'05" for C12
;; 7'08" ,8'15" MacOS Ventura M1 for C12 and 56" for C11
;;{unified-minterms-set <+ (list-transduce (compose (tfilter (λ (x) x))
(tdelete-duplicates)) rcons unified-minterms-set-1)}
some code is commented because i only run one test at a time.
I suppose the speed up was only because debug mode slowed down other code
but perheaps my test are not reliable, i can only explain some slow down
now due to CPU overloaded by another process in the system at different
moment in tests. I have no idea how to perform more reliable tests.
On Thu, Dec 22, 2022 at 6:32 PM Damien Mattei <damien.mattei@gmail.com>
wrote:
> i'm interested with transducers to speed up code:
>
> ;; 8'21" MacOS Ventura M1
> {unified-minterms-set-2 <+ (filter (λ (x) x) unified-minterms-set-1)} ;;
> remove #f results
> (nodebug
> {unified-minterms-set-2-length <+ (length unified-minterms-set-2)}
> (dv unified-minterms-set-2-length))
>
> {unified-minterms-set <+ (remove-duplicates unified-minterms-set-2)}
> ;;(remove-duplicates-sorted unified-minterms-set-2)} ;; uniq MODIF
> (nodebug
> {unified-minterms-set-uniq-length <+ (length unified-minterms-set)}
> (dv unified-minterms-set-uniq-length))
>
> with transducers:
> ;; 7'08" MacOS Ventura M1
> {unified-minterms-set <+ (list-transduce (compose (tfilter (λ (x) x))
> (tdelete-duplicates)) rcons unified-minterms-set-1)}
>
> it is an interesting 15% speed up in my code.
>
>
> On Thu, Dec 22, 2022 at 3:52 PM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
>> i just understood the scheme :-)
>>
>> scheme@(guile-user)> (list-transduce (compose (tfilter (λ (x) x))
>> (tdelete-duplicates)) rcons (list 1 2 #f 3 3 4))
>> $12 = (1 2 3 4)
>>
>> sorry...
>>
>>
>> On Thu, Dec 22, 2022 at 3:33 PM Damien Mattei <damien.mattei@gmail.com>
>> wrote:
>>
>>> hello,
>>> just trying transducers before using it, i try to understand.
>>> what is wrong with that:
>>> scheme@(guile-user)> (list-transduce (tfilter (λ (x) x))
>>> (tdelete-duplicates) (list 1 2 #f 3 3 4))
>>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>>> Wrong number of arguments to #<procedure 10786aa60 at
>>> srfi/srfi-171.scm:338:2 (reducer)>
>>>
>>> Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
>>>
>>> Regards,
>>> Damien
>>>
>>> On Wed, Dec 21, 2022 at 11:01 AM Linus Björnstam <
>>> linus.bjornstam@veryfast.biz> wrote:
>>>
>>>> As the author of both the SRFI and the guile code I am very happy you
>>>> like it. I don't have a computer at the moment, but I looked through the
>>>> code and it looked great.
>>>>
>>>> All additions should have been included in the original SRFI :)
>>>>
>>>> one comment: your code uses define-public, which the rest of SRFI-171
>>>> code does not.
>>>>
>>>> I am not in any position to sign code off for inclusion in guile
>>>> proper, but if the define-public thing is fixed it very much has my
>>>> blessing.
>>>>
>>>> Best regards
>>>> Linus Björnstam
>>>>
>>>> On Wed, 21 Dec 2022, at 01:48, Colin Woodbury wrote:
>>>> > Happy holidays everyone, I hope everything is going well for you.
>>>> >
>>>> > Since discovering SRFI-171 (Transducers) I have fallen in love with
>>>> it.
>>>> > Transducers let me "talk the way I want to talk" while knowing that
>>>> I'm
>>>> > being efficient underneath w.r.t. to iteration and allocation. In
>>>> using
>>>> > Guile's implementation, I noticed a few common idioms missing that
>>>> are
>>>> > otherwise present in other languages, so I've added them in a series
>>>> of
>>>> > patches. I've been using these often for a number of weeks without
>>>> > issue, but of course have added unit tests as well.
>>>> >
>>>> > The full details are in the commit messages, but here are the main
>>>> highlights:
>>>> >
>>>> > * rfold: The fundamental reducer. This allows the user to turn any
>>>> > two-arg function into a valid reducer, so that they don't need to
>>>> worry
>>>> > about hand-writing reducers via case-lambda.
>>>> > * rfind: Yields the first item in the transduction that matches some
>>>> > predicate. Nice for locating some specific value from a potentially
>>>> > large data source (e.g. a port).
>>>> > * twindow: Like tsegment, but yields overlapping slices into the
>>>> data.
>>>> > Cheers, and have a great holiday.
>>>> >
>>>> > Colin
>>>> >
>>>> > Attachments:
>>>> > * 0001-srfi-171-add-twindow-and-various-reducers.patch
>>>> > * 0002-doc-add-new-SRFI-171-reducers-to-the-manual.patch
>>>> > * 0003-srfi-171-add-unit-tests-for-new-functions.patch
>>>>
>>>>
[-- Attachment #2: Type: text/html, Size: 9645 bytes --]
next prev parent reply other threads:[~2022-12-24 13:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-21 0:48 [PATCH] Extensions for SRFI-171 (Transducers) Colin Woodbury
2022-12-21 10:00 ` Linus Björnstam
2022-12-22 14:33 ` Damien Mattei
2022-12-22 14:52 ` Damien Mattei
2022-12-22 17:32 ` Damien Mattei
2022-12-24 13:25 ` Damien Mattei [this message]
2022-12-24 15:28 ` [PATCHv2] " Colin Woodbury
2023-01-14 15:09 ` Ludovic Courtès
2023-01-21 1:48 ` [PATCHv3] " Colin Woodbury
2023-01-23 22:17 ` Ludovic Courtès
2023-01-24 0:21 ` Colin Woodbury
2023-01-24 9:07 ` Ludovic Courtès
2023-05-18 0:36 ` Colin Woodbury
2023-06-28 12:27 ` Colin Woodbury
2023-08-12 19:37 ` Linus Björnstam
2023-08-13 4:07 ` Colin Woodbury
2023-08-18 10:03 ` Ludovic Courtès
2023-08-18 10:10 ` Colin Woodbury
2023-08-18 13:24 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADEOadd0DXS7u5XEeNt31FhTxmyP5BoP3v-oOLPkFDq9UWPGUA@mail.gmail.com \
--to=damien.mattei@gmail.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).