From owner-svn-src-head@freebsd.org Wed Sep 25 16:45:45 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 006A212C84B; Wed, 25 Sep 2019 16:45:45 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46dkT35rsgz488F; Wed, 25 Sep 2019 16:45:43 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-io1-f68.google.com with SMTP id u8so511343iom.5; Wed, 25 Sep 2019 09:45:43 -0700 (PDT) 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=koProXzroGRAcLZolTphazxSx4KXyOZaojrB5uUU0JY=; b=WrwF90V5IJ8gjlOdH5SjfCqkzd3bNZOrgIjH2r6Ho4awJyAFCGMGI/7khlmEmQTkxt gXujBzvYm0M8dgcQQPVviqrrwXZwl/lKkrvl5RDbCd81VTRkOJx0v6MPQF9xG8moCof2 DjpgedS4QNj/XtugBy6m13AGt2h2CrPrVc5Ey5x5P2lwpj+BpkV/n6c9uq7D7Ub96WpU 6dxnHXhlcFxY8nhwL+VgTJZyGywL+A70/B1dgon9t5ReFu7Ioy2ErlN/728IAz/8qXxg shcEB+IMPxvmkssX2g+0Lfgb6EKBnuoAYP5sgRNhoxdZyNYEJ40Te7m+6rGpD4rdhIgz tAXg== X-Gm-Message-State: APjAAAVrM9hD8r1o0tYnHgZzKz/cLHIEEU95K/1YHXPh+hs9pnbyPzz+ RwP9VEC6pocsG9KU24tosSP5a8Cj+3G6xS5tVSo= X-Google-Smtp-Source: APXvYqwn+T+vIC4lSADYByF2056kNki3sCOj9rslngx6O2qM7wv234lU4FQDBoncFj1y4zu6cdadIvK1rDH0FylJK70= X-Received: by 2002:a6b:254:: with SMTP id 81mr282303ioc.17.1569429942144; Wed, 25 Sep 2019 09:45:42 -0700 (PDT) MIME-Version: 1.0 References: <201909021356.x82Dui6v077765@repo.freebsd.org> <20190920212702.N1017@besplex.bde.org> <20190926002410.M1471@besplex.bde.org> In-Reply-To: <20190926002410.M1471@besplex.bde.org> From: Ed Maste Date: Wed, 25 Sep 2019 12:45:29 -0400 Message-ID: Subject: Re: svn commit: r351700 - head/lib/libc/string To: Bruce Evans Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 46dkT35rsgz488F X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of carpeddiem@gmail.com designates 209.85.166.68 as permitted sender) smtp.mailfrom=carpeddiem@gmail.com X-Spamd-Result: default: False [-3.60 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[68.166.85.209.list.dnswl.org : 127.0.5.0]; IP_SCORE(-1.60)[ip: (-2.46), ipnet: 209.85.128.0/17(-3.29), asn: 15169(-2.18), country: US(-0.05)]; FORGED_SENDER(0.30)[emaste@freebsd.org,carpeddiem@gmail.com]; FREEMAIL_TO(0.00)[optusnet.com.au]; RWL_MAILSPIKE_POSSIBLE(0.00)[68.166.85.209.rep.mailspike.net : 127.0.0.17]; 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)[emaste@freebsd.org,carpeddiem@gmail.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Sep 2019 16:45:45 -0000 On Wed, 25 Sep 2019 at 11:46, Bruce Evans wrote: > > On Wed, 25 Sep 2019, Ed Maste wrote: > > > On Fri, 20 Sep 2019 at 08:14, Bruce Evans wrote: > >> > >> Optimizing this function [memchr] is especially unimportant, > > > > Why? > > Because it is almost never used, and most of its uses are unimportant. > > It is used a whole 26 times in all of /usr/src/*bin: Sure, but libc exists for the benefit of more than just the FreeBSD base system. Open source software and proprietary products built on FreeBSD make use of memchr and other string routines and have performance concerns. > But how do you know that long strings are most common? For short strings, > it is better to have low overhead. Indeed, there is a trade-off. Some ad-hoc testing confirms the original implementation is faster for byte strings of less than 8 bytes (as one would expect), and showed it slower above that. > LONG_BIT is another bad way of encoding the word size. On arches with > correctly sized longs, long is twice as wide as either a machine register > or the maximum memory access width. So it is usually twice the word size > if correct. One can argue that all of our 64-bit archs have incorrectly sized longs then, but I don't find that useful. The compilers and machines FreeBSD runs on have 64-bit longs on 64-bit processors. > register_t is closer to being correct. That makes sense, although not currently used for that purpose anywhere in libc (or other libs) that I can see.