From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.user,gmane.lisp.guile.devel Subject: Re: map-par slower than map Date: Wed, 12 Oct 2022 22:20:28 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7643"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user , guile-devel To: Maxime Devos Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Oct 12 22:21:28 2022 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oiiEK-0001oW-1A for guile-user@m.gmane-mx.org; Wed, 12 Oct 2022 22:21:28 +0200 Original-Received: from localhost ([::1]:39088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiiEI-0003GA-Sm for guile-user@m.gmane-mx.org; Wed, 12 Oct 2022 16:21:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiiDf-0003Fp-85; Wed, 12 Oct 2022 16:20:47 -0400 Original-Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:46827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oiiDc-0002VS-Vh; Wed, 12 Oct 2022 16:20:46 -0400 Original-Received: by mail-ej1-x631.google.com with SMTP id bj12so40270865ejb.13; Wed, 12 Oct 2022 13:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0a3KxhknoqYOeNMSbF/MxjA5CkJmr8Ki+1pba7EBN+g=; b=ZFQdOJ4llq6prDCEtfLvgEngRrP0g+Uly0ynG08EN/kaDegBW/MFraGdIBNLN85kC3 mLn49plP74hqJbnz7Eb22lRfPH77TscSHeL9NAY1QlhtYFRVal68nY+UuRNoAbG5gFWc nGKZFghMLAkp0sHNL9P9tr79cUGi+tIJ5p36d8jNG3O2cpmpNFEmyEE3Iu5igk4ebC7C pi3Kv3ipCYgXbnlyossgGN+e2uAtGRE35CaMcuhZtRDYnaIJclgqin656DPhUQYrGxWU kIpNHqfESdvW56Cj+vWpqmcMWdI59twzihwsjltbo/mqrI3MniJVwBaU15eP6QG5t/QH Lxrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0a3KxhknoqYOeNMSbF/MxjA5CkJmr8Ki+1pba7EBN+g=; b=5V9K/szpAoCqlGNzc8+e53fwHy1wiQc5OlzbTmtnuwKvM4ZS3M+lQpgaAo55y+bwlT pkrogd2eol31k/Lg9VPpaaUOFfZMMw77NO94tdaI0dDlhldDkhxTXySrr81QUq5MBRmj GHLyf/pMCI46SM9gwCZsDRVE28DlJywYfjAsjQz/ZoUp5v2MT+tLV3D10jALbYxjT+zj pw9MsG1cl5SCaphqg96hnhJ++YNJcONGYcZXr3+ylo6SVCYZhobJrtbr4PLM0UReLl8a 4QNT5oBEz+5qEdPUn4ZgqYrwY9H0l5uFxunCWgbZuAuTYOEzA95lwr1mbOehtceRQAkG fj7Q== X-Gm-Message-State: ACrzQf3DvkVLY6lbVfMQNwFDi1WwPrJd8ApuVGzAoqmXSG5JbzntJYo3 5oVyfFG5fuc+XpkOj5pCNbmp0Hz4WXBq1jYA9yY7c3BqslgNRQ== X-Google-Smtp-Source: AMsMyM5irz6FwjIOSAjazKPAU/Jsuar3BSRprmN8EVSXEoBhKUqM+JliFgnlRSA7MbAjVuDNeOkdRFutSSYwYULEYqo= X-Received: by 2002:a17:907:ea6:b0:782:1ace:9d5b with SMTP id ho38-20020a1709070ea600b007821ace9d5bmr23230099ejc.770.1665606040754; Wed, 12 Oct 2022 13:20:40 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=damien.mattei@gmail.com; helo=mail-ej1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:18626 gmane.lisp.guile.devel:21405 Archived-At: Mutex? i do not think code has situation where dead lock could happen, it is a code about minimalising logic expressions, it uses minterms , minterms set is a set of minterms :like this: example: ((1 1 0) (1 1 1)) will be unified : (1 1 x) because 0 and 1 are replaced by x the minterms-set could have thousands of pair (mathematic not lisp) minterms to unify if there is more than one x as result there is no need to continue so i escape with a continuation: minterms-set =3D { ((1 0 1 0) (1 1 1 0)) ((1 0 1 0) (1 1 0 1)) ((1 0 1 0) (1 0 1 1)) ((1 0 1 0) (0 1 1 1)) ((0 1 1 0) (1 1 1 0)) ((0 1 1 0) (1 1 0 1)) ((0 1 1 0) (1 0 1 1)) ((0 1 1 0) (0 1 1 1)) ((0 1 0 1) (1 1 1 0)) ((0 1 0 1) (1 1 0 1)) ((0 1 0 1) (1 0 1 1)) ((0 1 0 1) (0 1 1 1)) ((0 0 1 1) (1 1 1 0)) ((0 0 1 1) (1 1 0 1)) ((0 0 1 1) (1 0 1 1)) ((0 0 1 1) (0 1 1 1)) } replace { } by () to have the list, other example at another level : minterms-set =3D { ((0 x 1 1) (x 1 1 1)) ((0 x 1 1) (1 x 1 1)) ((0 x 1 1) (1 1 x 1)) ((0 x 1 1) (1 1 1 x)) ((x 0 1 1) (x 1 1 1)) ((x 0 1 1) (1 x 1 1)) ((x 0 1 1) (1 1 x 1)) ((x 0 1 1) (1 1 1 x)) ((0 1 x 1) (x 1 1 1)) ((0 1 x 1) (1 x 1 1)) ((0 1 x 1) (1 1 x 1)) ((0 1 x 1) (1 1 1 x)) ((x 1 0 1) (x 1 1 1)) ((x 1 0 1) (1 x 1 1)) ((x 1 0 1) (1 1 x 1)) ((x 1 0 1) (1 1 1 x)) ((0 1 1 x) (x 1 1 1)) ((0 1 1 x) (1 x 1 1)) ((0 1 1 x) (1 1 x 1)) ((0 1 1 x) (1 1 1 x)) ((x 1 1 0) (x 1 1 1)) ((x 1 1 0) (1 x 1 1)) ((x 1 1 0) (1 1 x 1)) ((x 1 1 0) (1 1 1 x)) ((1 0 1 x) (x 1 1 1)) ((1 0 1 x) (1 x 1 1)) ((1 0 1 x) (1 1 x 1)) ((1 0 1 x) (1 1 1 x)) ((1 x 1 0) (x 1 1 1)) ((1 x 1 0) (1 x 1 1)) ((1 x 1 0) (1 1 x 1)) ((1 x 1 0) (1 1 1 x)) } here we see some minterms are already unified it is not easy to read even by me because i wrote the code many years ago and is split in many files, but here it is: (par-map function-unify-minterms-list minterms-set) {function-unify-minterms-list <+ (=CE=BB (L) (apply function-unify-two-minterms-and-tag L))} (define (unify-two-minterms mt1 mt2) (function-map-with-escaping-by-kontinuation2 (macro-function-compare-2-bits-with-continuation) mt1 mt2)) ;; (function-map-with-escaping-by-kontinuation2 (macro-function-compare-2-bits-with-continuation) '(1 1 0 1 0 1 1 0) '(1 1 0 1 1 1 1 1)) ;; list1 =3D (1 1 0 1 0 1 1 0) ;; more-lists =3D ((1 1 0 1 1 1 1 1)) ;; lists =3D ((1 1 0 1 0 1 1 0) (1 1 0 1 1 1 1 1)) ;; clozure =3D # ;; #f ;; ;; (function-map-with-escaping-by-kontinuation2 (macro-function-compare-2-bits-with-continuation) '(1 1 0 1 0 1 1 0) '(1 1 0 1 1 1 1 0)) ;; list1 =3D (1 1 0 1 0 1 1 0) ;; more-lists =3D ((1 1 0 1 1 1 1 0)) ;; lists =3D ((1 1 0 1 0 1 1 0) (1 1 0 1 1 1 1 0)) ;; clozure =3D # ;; '(1 1 0 1 x 1 1 0) (define (function-map-with-escaping-by-kontinuation2 clozure list1 . more-lists) (call/cc (lambda (kontinuation) (let ((lists (cons list1 more-lists)) (funct-continu ;; this function have the kontinuation in his environment (lambda (arg1 . more-args) (let ((args (cons arg1 more-args))) (apply clozure kontinuation args))))) ;; a tester: (apply clozure (cons conti args)) ;; (newline) ;; (dv list1) ;; (dv more-lists) ;; (dv lists) ;; (dv clozure) ;; (newline) (apply map funct-continu lists))))) (define-syntax macro-function-compare-2-bits-with-continuation ;; continuation version of macro-compare-2-bits ;; i need a macro because of external function to the clozure (syntax-rules () ((_) (let ((cnt 0)) ;; counter (lambda (continuation b1 b2) (if (equal? b1 b2) b1 (begin (set! cnt (add1 cnt)) ;; we leave with continuation in case cpt > 1, we can have used a flag too instead of a counter (when (> cnt 1) (continuation #f)) ;; escaping with the continuation 'x))))))) ;; return x in case of (b1,b2) =3D (O,1) or (1,0) what could have caused mutex if in the latter definition above (let ((cnt 0)) ;; counter was defined at top level and shared by all threads!!! yes there could have be some mutex but this is not the case, i think even all function are pure so why is it more slow with // than without? Damien On Wed, Oct 12, 2022 at 8:45 PM Maxime Devos wrote= : > On 12-10-2022 19:19, Damien Mattei wrote: > > Hello, > > all is in the title, i test on a approximately 30000 element list , i g= ot > > 9s with map and 3min 30s with par-map on exactly the same piece of code= !? > > > > [...] > > > > translated from Scheme+ to Scheme: > > (define unified-minterms-set-1 (map function-unify-minterms-list > > minterms-set)) ;;(par-map function-unify-minterms-list minterms-set)) > > The definition of 'function-unify-minterms-list' and 'minterms-set' is > missing. Without a test case, we can only speculate what's going on. > (E.g., maybe it grabs a mutex). > > Greetings, > Maxime. >