From nobody Fri Sep 13 11:43:25 2024 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4X4srp4ymXz5WnnX for ; Fri, 13 Sep 2024 11:43:38 +0000 (UTC) (envelope-from aryeh.friedman@gmail.com) Received: from mail-ua1-x933.google.com (mail-ua1-x933.google.com [IPv6:2607:f8b0:4864:20::933]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X4srn3wJLz468y; Fri, 13 Sep 2024 11:43:37 +0000 (UTC) (envelope-from aryeh.friedman@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20230601 header.b=CFFE6wTV; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of aryeh.friedman@gmail.com designates 2607:f8b0:4864:20::933 as permitted sender) smtp.mailfrom=aryeh.friedman@gmail.com Received: by mail-ua1-x933.google.com with SMTP id a1e0cc1a2514c-848b77c89e0so227101241.0; Fri, 13 Sep 2024 04:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726227816; x=1726832616; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Y0KPMOhui2BsnicfBUP6L4hMiUZKCz+v4NFKQWjeHf8=; b=CFFE6wTV2Lk8hnm3YBijkZOY5kPGd978OCGg72Ge3VzKkHYIczPi/zHP7scSyESmPs 1uPTcYAgIdHtlQO+YiEOMprml/bpAjqV1gqj1U2lG+uywuD223c6HEIeo8+LQKbPcEev Jl/eMXKfW6eiFpnOCmrY9iMTcQs4jeWKCWD1QBhiKvRsqMB45O8z1FH6SR9d7pVq+H4m YpBuk2/mAU5bP/IhuAHDjJU0n2esBgcAuUFx4/oRGV3B/A9OWUcaOe7Fsq867NVWY9Ir BYhHA/kuLJ3UnREVrMVR4dHYcGikyR/HlMbdjQsy928BrTxEXkm16/0T4LzKOfuSyMsL EV3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726227816; x=1726832616; h=content-transfer-encoding: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=Y0KPMOhui2BsnicfBUP6L4hMiUZKCz+v4NFKQWjeHf8=; b=BIPRluGZchaWtT+G0CQE/2BJd3BT8AlH7BufX0GTcZnnSkCgj38oPoWfX9DWRfDcIY W4i/7AgRybVLFRC5rf52ih9Rhy5hQH1AQKmXnnh9DgbE5E9If85lGC3lnEUyM8vzw39r ZdRSeAk5cE65yLmQPfV8fCwCy5/EBHUqeMnBBW1i6wxThnhkAOhY31BsstKwWYKmhWXt ZtJ/smxxLHUj6ZdPJBuNK6W0/G/xa1D736ZdsDXDBXa6zxGs7HnPUSpQIXwpgBJh5+TA N+SPC7zvEX5ZaEIQaVlJsEfLX1Tnp+XJf6VoNO3X4q9DICstcF1ZtEIGUejp2jAIPggr 94Qg== X-Forwarded-Encrypted: i=1; AJvYcCUM5GYCp0F4cqm2sEkE0tueyK8y09jm7+lfFL0hl17C7RxhPUmZlGVEDGvRCAMweZfXD876FaD9@freebsd.org, AJvYcCXk9QDt8btXx9AwMZvUAr3x2w5ogZmeKHXt2Nzin9ljZXV7re7A9C8naYsFMHBTrq59lqgYiXlWYpL+DaEGGKeh@freebsd.org X-Gm-Message-State: AOJu0YxRBmjZHDXdicAYBVR2W5YgYBUkWmwxY8Y3Jj6PFqhjbjbMrqmb iyKnGEtdACmOHRa19gVMS2fPTOh2fqg/tJMilgBf6OCXqFMrKlN+JR2Oyh7BiuCL8lc1XqQRx+h TX8XkxmodEG5wGnmQpT5m/UlOGVY1Zw== X-Google-Smtp-Source: AGHT+IE9Na3rJGYms8tm9l923m/iWshqYs3aYOgVGeeq9FkUdXdwSevE8U13vbMzRuHCfwM3/NeIZr6q+0JDE3iKjGw= X-Received: by 2002:a05:6102:2acc:b0:494:560b:6c04 with SMTP id ada2fe7eead31-49d4f6b511emr1693796137.20.1726227816140; Fri, 13 Sep 2024 04:43:36 -0700 (PDT) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 References: <2EE309BF-CE1D-48AD-9C53-D4C87998B4A0@freebsd.org> <2D0F93DC-36DA-4FB9-BFD2-D7678EC03CD7@FreeBSD.org> In-Reply-To: From: Aryeh Friedman Date: Fri, 13 Sep 2024 07:43:25 -0400 Message-ID: Subject: Re: The Case for Rust (in any system) To: David Chisnall Cc: Joe Schaefer , Pat Maddox , Alan Somers , Chris , Warner Losh , FreeBSD Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.95 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.95)[-0.953]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ARC_NA(0.00)[]; TAGGED_FROM(0.00)[]; TO_DN_ALL(0.00)[]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[gmail.com,patmaddox.com,freebsd.org,bsdforge.com,bsdimp.com]; FROM_HAS_DN(0.00)[]; MISSING_XM_UA(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; MID_RHS_MATCH_FROMTLD(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_ONE(0.00)[1]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::933:from] X-Rspamd-Queue-Id: 4X4srn3wJLz468y On Fri, Sep 13, 2024 at 7:40=E2=80=AFAM Aryeh Friedman wrote: > > On Fri, Sep 13, 2024 at 4:54=E2=80=AFAM David Chisnall wrote: > > > > On 13 Sep 2024, at 08:59, Joe Schaefer wrote: > > > > > > That=E2=80=98s because you are a dork. > > > > > > In case you were wondering, that was the point when you lost all credib= ility in this thread. > > > > The point isn=E2=80=99t that calloc calls are faster than vector alloca= tions. The point is that by changing the way you deal with arrays (as obj= ects that manage their own size, versus managing the sizes using up front p= reallocations and dealing with their growth yourself), we can exchange func= tion calls for pointer dereferences. > > > > > > And that=E2=80=99s precisely the change you get by calling .reserve wit= h the expected size. And the speedup tends to be exactly what you claimed = you got. > > Speaking both as a freelance software engineer who works in > soft-realtime and soft-IoT (the EMR for a medical lab that does remote > cardiac monitoring) and as hopefully a PhD candidate in theoretical CS > (whose research revolves around the minimum number of gates needed for > Turing completeness) I can make few observations here that make clear > that while having good intentions Rust completely misses the mark for > being a true systems programming language: > > 1. Fixed allocations are *ALWAYS* safer and more predictable then > dynamic ones (dynamic ones are undecidable in there nature and > effects). > > 2. Combining fixed allocation with dynamic (under the hood and > unrequested) allocation is a very bad idea. > > 3. It is possible to do all the above safely with arrays and not > pointers IF the arrays are static but not dynamic. > > This implies that if and when you grow/shrink the physical array you > need to have really tight control on timing and Rust does not provide > that by putting it all under the hood. > > > -- > Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org --=20 Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org