From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: Why does adding a useless copy-sequence and discarding the result make my ELisp 40 times faster? Date: Sat, 25 Mar 2017 13:02:36 -0400 Message-ID: References: <77900613-3b45-52f4-5770-38fe6f27e69c@gmail.com> <83vaqxbzub.fsf@gnu.org> <8760ixhc9a.fsf@luca> <96d5bde3-fc20-750e-abc7-541b2abd2bd8@gmail.com> <8737e1fh1q.fsf@luca> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1490461404 6827 195.159.176.226 (25 Mar 2017 17:03:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 25 Mar 2017 17:03:24 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cc: Eli Zaretskii , emacs-devel@gnu.org To: Andreas Politz Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 25 18:03:20 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crp5t-0000iW-Pb for ged-emacs-devel@m.gmane.org; Sat, 25 Mar 2017 18:03:13 +0100 Original-Received: from localhost ([::1]:38025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crp5z-0000HF-TM for ged-emacs-devel@m.gmane.org; Sat, 25 Mar 2017 13:03:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crp5O-0000H9-Vo for emacs-devel@gnu.org; Sat, 25 Mar 2017 13:02:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1crp5L-0001Zw-QC for emacs-devel@gnu.org; Sat, 25 Mar 2017 13:02:43 -0400 Original-Received: from mail-qt0-x22b.google.com ([2607:f8b0:400d:c0d::22b]:32920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1crp5L-0001ZW-Mk; Sat, 25 Mar 2017 13:02:39 -0400 Original-Received: by mail-qt0-x22b.google.com with SMTP id i34so12188778qtc.0; Sat, 25 Mar 2017 10:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=9OcH2T3nTCD0iSdROOEizT5bEhAmywn9IHp61iKj04Q=; b=IAZ8EB0xg2IrUkv9U2wBl8TJ+eqJISJDNAjguJZ/5RBddSUuFo30IONMVyZqtQ4fTB qDQ4tVfp+mKmSYqjntKVvkCO20jJoGTN9ggXocKtH1BsIKQGt/QDcRLapc3SuCl5uPzE o4dqfVmNp3whFMKvfTCpQMnJl7O6Frvq5rO1MAiMo+DmefIG/AJ+GkCJ+YdpgZceOvqT MvA4zvk/hEFv2unYrIwXGUCbNKoHVgSjzY5yU8QFljTX7jMyMvu/05nY1Iun83dhD1DG ErCVYrQdmHMVF1/n0ETPyHuWUaRhBeKgjxp3OoSiY1JNL4mtDrQEr1muNhZytOIbWWRU KdsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=9OcH2T3nTCD0iSdROOEizT5bEhAmywn9IHp61iKj04Q=; b=XUyhje8LDYkN1s9yxGun+1qQzWfrWF9P6peW5tFSCT10MnsOO2atnDfp6YGBU2tuVl WGr38QgKIQct6lN+paCml+Tu8u7HsdC8IiB6pacGeuCCuBruRYuAWBizGahmnFTS+psZ z47WDSQDkSMT/rZPd3mHY0ehvSw1nMh9fWf8e9MdlUszSi3GGCxqaAtFZ2fBSFiGcHll hSO6I4HW0Jjo9FQxF3/UhDnemgO94nBSSV9rDnxt0REcWecOdG96OPvmRv2HUkni8IDS MbgQcnFu2BTO/2eRJ5cwTK0rC4Ke06z3yr8Qp9qApK2WgjiyYYgZiKsiT+V+400d/EMt 0e6A== X-Gm-Message-State: AFeK/H1aGpufy+Maej7EobSIm/Ul/UXlwRG8+zzIojsrUuVDaLXcH7PNy+wpkYdJFqnztg== X-Received: by 10.200.44.71 with SMTP id e7mr13165212qta.210.1490461357859; Sat, 25 Mar 2017 10:02:37 -0700 (PDT) Original-Received: from [18.189.26.125] (dhcp-18-189-26-125.dyn.MIT.EDU. [18.189.26.125]) by smtp.gmail.com with ESMTPSA id j33sm4057684qtb.8.2017.03.25.10.02.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Mar 2017 10:02:37 -0700 (PDT) In-Reply-To: <8737e1fh1q.fsf@luca> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c0d::22b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213345 Archived-At: On 2017-03-25 12:38, Andreas Politz wrote: > Clément Pit-Claudel writes: > >> On 2017-03-25 06:38, Andreas Politz wrote: >>> The limiting factor may also be python itself... >>> >>> ;; python2 >>> ((0.114342188 0 0.0) >>> (0.715895279 0 0.0) >>> (2.120252213 0 0.0) >>> (1.02429565 0 0.0)) >>> >>> ;; bash = "while read;do : ;done" >>> ((2.008305836 0 0.0) >>> (1.999825023 0 0.0) >>> (2.026715753 0 0.0) >>> (2.060320318 0 0.0)) >> >> Interesting! But doesn't this just show that bash is uniformly slow? > > This suggests to me, that the deciding factor in these numbers is python > and not Emacs. > > Maybe it has a read buffer of a certain size, let's say 65536 ;O), and > if that buffer runs out of space, things get stalled. The thing is, I reproduced these numbers with cat and a simple C program, so it's not python itself. But indeed the default pipe buffer size on Linux is 65536 bytes, so there's certainly something going on with buffering at the 65536 (2^16)/65537 (2^16 + 1) threshold. That doesn't explain observation 3 though (why is sending many small messages so much faster than 1 large one), nor observation 1 (why is the program without sleep or copy-sequence so slow?). Worse, Emacs' docs for process-send-string claims that messages larger than 500 bytes will be split. Clément.