From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Psionic K Newsgroups: gmane.emacs.help Subject: Re: Identifying sources of allocations in a toy Mandelbrot package Date: Sat, 27 Jan 2024 18:25:32 +0900 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000003048e8060fe9ffec" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31288"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Tomas Hlavaty To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 27 10:26:42 2024 Return-path: Envelope-to: geh-help-gnu-emacs@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 1rTexW-0007wr-0F for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 27 Jan 2024 10:26:42 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTewg-0005RM-EU; Sat, 27 Jan 2024 04:25:50 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rTewd-0005RA-QB for help-gnu-emacs@gnu.org; Sat, 27 Jan 2024 04:25:47 -0500 Original-Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTewb-0003Nw-4p for help-gnu-emacs@gnu.org; Sat, 27 Jan 2024 04:25:46 -0500 Original-Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-783d4b3a026so94691185a.1 for ; Sat, 27 Jan 2024 01:25:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=positron.solutions; s=google; t=1706347543; x=1706952343; darn=gnu.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=1XdX+0TTem6bovrSzjC9plsYBMO3+owBcK87L5WGT7E=; b=nCsF+faq4nVfVHA76oXnTCCLCAirkAtu4/rKZlVWB56TdIQb/Cf5ClbwI+/qkz628Z j/AGaLdiJ7w4XE+alfcufMw6YrojyU2kaqjlhbahzjd0cDHjBwuHKUpZ/fFXQk5zI6gb 2efch94Qq02hd7xNeFhgStE56GTuc9LLJdLek+MYZZWBJx51qPEenADZ1KY+sNJBKVW5 fiDJZ2SzsHokUvHHdzs/NuLFMhlqldznpKPMb8el0YVa+DHpOZkwkU/kvQxQYksA+GSP Wv2CIbfEz/I8QAPSjA/ofRZOfEP8+W6jqCZNeuh9i9W9dRZgpM8JQ3/39IDojwBX/saM 2g9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706347543; x=1706952343; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1XdX+0TTem6bovrSzjC9plsYBMO3+owBcK87L5WGT7E=; b=T2WWtSxt+DMaV28QlHYoEIhvsmzximhA7McxryD+hnSPUmxBiO/33Obzvt7s3A7TNf xXe42M9U+svJ75MTsUa0IMC9xWSDjYQz2+KIer4xt9OTPkbiTCFWa8a1qbSIcZMvnOjo 8GXNBx0zGTFnl6EJm+bmv+fHvw8EMrn1L29OIN/W8b0X8jZ/zIl2NJkFallh2RZqc0np GYqw7Z0tuapw4/CNPBfrraVgqgN6Fw64MyYryeq+tElpgHJymHgrD/+yOkSp3efNZ+2b ZnDJ3ybN5Sa3WwV/mT+u1KqpQVyvC8mtYct37Ji/Ji80luWwGalK75VH8vUu8n7oTdnN s1ow== X-Gm-Message-State: AOJu0YxvirmC/UWHGZy4nd8j+G0yOdkfaHR1Ie7ayc58iHcqQtLsKYCC DfE8w2Y7zSRhHVEbz8lpHbiDgwHyJBpFQjxSK4eQRN2BdAGYweuuddK0eAnk1+nO8HPvHV7J3dN UBT/fQhOFs9Bu/6SaHyfy6eSrQ5lcL4BeBhbO8Su51o5ZVm8Ks3I= X-Google-Smtp-Source: AGHT+IH8jXqQxTkvDVzUP3/3NMBPa2+m74kIruKerSWnBS1Z1J6+h+Kb+Y6eVqHleOjc22JYZkgV8OruJEoq6VGZ8HA= X-Received: by 2002:a05:620a:8c4:b0:783:8fce:cc75 with SMTP id z4-20020a05620a08c400b007838fcecc75mr1008410qkz.96.1706347543380; Sat, 27 Jan 2024 01:25:43 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::72f; envelope-from=exec@positron.solutions; helo=mail-qk1-x72f.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145811 Archived-At: --0000000000003048e8060fe9ffec Content-Type: text/plain; charset="UTF-8" I wanted to dig into the CPU versus memory limitation a bit. I switched back to writing to a vector, not touching any buffers to wrap the profile around the hot section. CPU + mem results: fixed point byte-compiled: 195 samples 3,890,391 bytes fixed point native compiled: 250 samples 4,205,335 bytes floating point byte-compiled: 560 samples 221,858,239 bytes floating point native compiled: 409 samples 221,732,687 bytes * There is no typo in the native & byte compiled fixed point results. I made a few runs. It is slower when native compiled. * I found no other combination of `defsubst' `defun' or declaring speed or not that could get the native compiled fixed point version to be faster than byte compiled. * The floating point version was only measured when the run did not trigger GC. This inflates its performance because GC cost, about 30%, is not shown. While the fixed point is fast considering it has to do more work, perhaps if the native compiler didn't manage to slow it down, it could be faster. Regarding my previous statements about memory bandwidth being the limiting factor, while the memory used is on the lower end of an order of magnitude within the random write bandwidth available. If that amount was limiting, the compilation method would not be expected to affect performance much. Since the native compiled floating point is faster, it is likely CPU bound. Consumption is just a proxy for bandwidth used. Runtimes use bandwidth without new allocation. Better tools are needed to answer this conclusively. I may continue this exercise. My initial idea to create clarity is by writing a function that just throws away conses that hold values that require 1, 10, 100, or 1000 steps to compute. If the performance scales inversely by conses but not by steps, we can isolate memory versus computation as the bottleneck for some workflows and provide a benchmark for the compiler and GC to be smarter about not generating garbage in the first place. --0000000000003048e8060fe9ffec Content-Type: text/x-emacs-lisp; charset="US-ASCII"; name="fixed.el" Content-Disposition: attachment; filename="fixed.el" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lrvu2kk20 Ozs7IC0qLSBsZXhpY2FsLWJpbmRpbmc6IHQgLSotCgo7OyBzYW1wbGVzIHRoYXQgaGl0IDI1NiB3 cmFwIGluIHRoZSBncmFwaGljIHRvIGRpc3BsYXkgYXMgemVybwo7OyBleHBvbmVudGlhbCAwLjgg ZW5oYW5jZXMgY29udHJhc3QgYSBiaXQKKGxldCAoKGEgKG1ha2UtdmVjdG9yIDI1NyAwKSkpCiAg KGRvdGltZXMgKHYgMjU2KQogICAgKGFzZXQgYSB2IChmbG9vciAoKiAyNTYgKGV4cHQgKC8gdiAy NTYuMCkgMC44KSkpKSkKICAoZGVmaW5lLWlubGluZSBjb250cmFzdCAodikKICAgICh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oKCgoKCgoK CgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoK CgoKCgoKCgoKCgoKCgoKCgoKCgo7OygzMi44OTgyMTU1OTggMiAwLjA5MzY2NTgyMDAwMDAxMjQ1 KQo7Oyg1MS42Mjk3NjMyODkgMiAwLjA5MTY1Mzg5MzAwMDAwMDE1KQo= --0000000000003048e8060fe9ffec Content-Type: text/x-emacs-lisp; charset="US-ASCII"; name="floating.el" Content-Disposition: attachment; filename="floating.el" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lrvu2pnx1 Ozs7IC0qLSBsZXhpY2FsLWJpbmRpbmc6IHQgLSotCgooZGVmaW5lLWlubGluZSBtYW5kZWxicm90 MSAoY3ggY3kpCiAgKGxldCAoKHpyIDApCgkoemkgMCkKCSh2IDApKQogICAgKHdoaWxlIChhbmQg KDwgdiAyNTYpICg8PSAoKyAoKiB6ciB6cikgKCogemkgemkpKSA0KSkKICAgICAgKHNldHEgdiAo MSsgdikpCiAgICAgIChsZXQgKCh0bXAgKCsgKCogenIgenIpICgtICgqIHppIHppKSkgY3gpKSkK CShzZXRxIHppICgrICgqICgqIHpyIHppKSAyKSBjeSkpCgkoc2V0cSB6ciB0bXApKSkKICAgIDs7 IHNhbXBsZXMgdGhhdCBoaXQgMjU2IHdyYXAgaW4gdGhlIGdyYXBoaWMgdG8gZGlzcGxheSBhcyB6 ZXJvCiAgICA7OyBleHBvbmVudGlhbCAwLjggZW5oYW5jZXMgY29udHJhc3QgYSBiaXQKICAgIChm bG9vciAoKiAyNTYgKGV4cHQgKC8gdiAyNTYuMCkgMC44KSkpKSkKCihkZWZ1biBtYW5kZWxicm90 ICgmb3B0aW9uYWwgdyBoKQogIChkZWNsYXJlIChzcGVlZCAzKSkKICAoaW50ZXJhY3RpdmUpCiAg KGxldCAoKG91dHB1dCAobWFrZS12ZWN0b3IgKCogdyBoKSAwLjApKQogICAgICAgI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