From owner-freebsd-hackers@freebsd.org Sun Jan 6 18:02:00 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 418A61495C56 for ; Sun, 6 Jan 2019 18:02:00 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5524F88286 for ; Sun, 6 Jan 2019 18:01:59 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lf1-f43.google.com with SMTP id b20so28571901lfa.12 for ; Sun, 06 Jan 2019 10:01:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gdAaLEanICDtrf1UUziP+MAP5XbLlViloTWMnVdfFxc=; b=hTSbeP3w3h6ToSUFzubF/A3evTz57Nnf6tVrBDUUwWaJMvK6vQjxynuUzlAc7E/O67 wEGuO/yx8h2GZuezw40alI1zbDoZgIHfSiIeE7F3UTphA2+oqB4DCj0VP/wZXBeAzUAC goCd3xLAVBwcjlPbUPWRkC29UKm95jM2uGn7kaLtajfZQnp3OijWey0+0Zz4341U5JJ6 wIMugo/CuYjxyBbbXOvw2/5fb8XeJPJXGLRadLIccx6Y9hfuJJZMMhTk8zpI+FL/QTEW 08UAxmLhNw4xr6YxsSVCsOG5HIxoVORcRtLb4kQBTZG6zCu4HI6ml+GbZPbuaiEgDhQi YA/Q== X-Gm-Message-State: AA+aEWYbDHiwP09sCHm7FWx+qGL1n/QLhLQBCH1xPDNhJ8q7rZsGJWqa 6/2kHoUKxwMi2CjI9HTs2NnZ2yu2y5pjBurm5Es= X-Google-Smtp-Source: AFSGD/UR7DjFOfA6KxULWwRfWfEvUpF0xrNS0T4AjsZrgFbjlap9koJqAageyR8hHcfi/d1S/PWGBaA7LpdxRuPLmiA= X-Received: by 2002:a19:8096:: with SMTP id b144mr31055120lfd.8.1546797717540; Sun, 06 Jan 2019 10:01:57 -0800 (PST) MIME-Version: 1.0 References: <7d7bc47d-04cf-2f9b-00a3-e3d9d92b3623@aceshardware.com> <72922F2C-9D27-47AA-BB1C-2DA8589CF008@rpi.edu> <92bd5362-d898-aa12-8f3d-9fbe23f38e0c@aceshardware.com> <26325c0b-4960-7739-72aa-c31c4e0638d3@aceshardware.com> In-Reply-To: From: Alan Somers Date: Sun, 6 Jan 2019 11:01:46 -0700 Message-ID: Subject: Re: Speculative: Rust for base system components To: Brian Neal Cc: "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 5524F88286 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.167.43 as permitted sender) smtp.mailfrom=asomers@gmail.com X-Spamd-Result: default: False [-4.00 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[43.167.85.209.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_SHORT(-0.89)[-0.889,0]; RCVD_TLS_LAST(0.00)[]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; IP_SCORE(-1.10)[ipnet: 209.85.128.0/17(-3.77), asn: 15169(-1.67), country: US(-0.08)]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2019 18:02:00 -0000 But it's not a like-for-like comparison. Rust eliminates dead code at a later stage. If you want to compare the efficiency of generated code, you need to exclude the dead code that will be eliminated by LTO. And you shouldn't be counting the labels for either language, because they don't affect the machine code. If you want to compare build times, then you should actually measure build times. -Alan On Sun, Jan 6, 2019 at 10:51 AM Brian Neal wrote: > > Of course. But I'm counting like for like. So labels are counted for > all languages. And I definitely don't rely on LTO when comparing the > efficacy of compiler, especially since the linker can spend lots of time > eliminating dead-code (usually single-threaded), which means longer > build times. > > On 1/6/2019 9:17 AM, Alan Somers wrote: > > Those 21 lines aren't 21 instructions; you're counting labels. Also, > > the first three instructions aren't actually part of the function. > > They're dead code, and should be eliminate by LTO. However, Rust > > doesn't do LTO when compiling libraries; only when linking > > executables. The unwrap logic, etc is also not part of the function. > > So in this example, Rust produces only a few more instructions than C. > > Also, FYI the Rust expression "0..num" is exclusive on the right. > > It's equivalent to C's "for (int i = 0; i < num; i++)", though that > > doesn't change the instruction count. > > > > -Alan > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"