From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id B86011F9FD for ; Sun, 7 Mar 2021 09:58:40 +0000 (UTC) Received: from localhost ([::1]:36052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIqBL-0003Nh-Cp for normalperson@yhbt.net; Sun, 07 Mar 2021 04:58:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIqBI-0003NZ-Nf for bug-gnulib@gnu.org; Sun, 07 Mar 2021 04:58:36 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.24]:22173) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIqBG-0002uK-JR for bug-gnulib@gnu.org; Sun, 07 Mar 2021 04:58:36 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1615111110; cv=none; d=strato.com; s=strato-dkim-0002; b=LzrndsQxzF05kt4X4amE3P5v2Biad7VpINHrk/QA+R0Aifd6MrSI0NO0ew8aON13lX Rg36l+4nil8zhGMY5KlDZM6oMF1hYRocxXDsBk5mwwFm8dsgqgNV/MZm/0GtThCnu3q0 lBzG6PEx3gUAS6mFcc+8lZNQCIqVeZPQanGxeTPDBYA4JLMFZr5GBNVu7BRHHMrvyys4 CJRjtLWNCtG7eK/zx1qcFN14m4oYRP6NiDpeSdfpZXiPKKin48DGQUYiGQwnuRvmyj0B 28SSls0U1ZKOGuyCvK/Xi7czYfeNcf0sh1oFChWjNx+GIzWV+P5mDDSceBkRGAnyuysZ phZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1615111110; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=nBnT84WR+oPtHz5AM5Zadjw5vGVYFB/4BKYDQL2YYv0=; b=NNhaXj41slRKUchBzMiQz18KD3ahZ+npmDfgXgAIf1b18ZpijHBgA88Fkpd8gp8I8j tQQBelIftx6fcjjk7ES/ypXMMFTEPEQKS282LXpgzw3E+U/8EoJPA0C6mAqOkstHJ7gT mKaBacJYYaPCgFZtrYhUQtO1/6wttOFfCddU3Mt1Rmu5SJirSsJpurl589vvxvaYlPBC ZD5J1lj+jKkVCluW2XObke6f5BplytFP6ui9ck6q/MDZcFjIcvxqWOtWdls2ZyBQ+P2j 00ZDN4O2SEcx/kFBV4qHJtAXzlloLYqdt0IbYMTXCU3PTwDhWeXUNKtJbV5Wp+bm+h9l 8tbQ== ARC-Authentication-Results: i=1; strato.com; dkim=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1615111110; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=nBnT84WR+oPtHz5AM5Zadjw5vGVYFB/4BKYDQL2YYv0=; b=XBgvDrnPp7+ziJ05khqFntZNlnQGl4IQYIMDssRjFDm/HSUNAHCxQW4BOHy8UylKEG jI2CEYc6xf0v4X5c+YR9sNZyBnnE4W8hn1rUKTRvDFGruYxgP2QaSyHX5fNdy+CxP6lM Ysn26AvJXw5BeS79bnrxwqI5qodzpROT1AJWmGHdpp8IhQ6DoqLuiAhpNuwdF6MqDebg IJt0Zo0htIq6bkTiDSgAW+a0NLdd215Aca0UhbHeyz9185/rR9Vkk2OYpFh3CbqwpCgo J3gyyJEmI0ubHibqbVNDvFqVA+ixTFyF7ewCurPXvUS3IbdrBKeq2bQf4XvuQhBOdF1m RtKQ== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOHqf3zZdW" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.20.3 DYNA|AUTH) with ESMTPSA id n0b11fx279wTD0y (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sun, 7 Mar 2021 10:58:29 +0100 (CET) From: Bruno Haible To: Paul Eggert Subject: Re: single-threaded optimizations Date: Sun, 07 Mar 2021 10:58:28 +0100 Message-ID: <2783771.9LmcWK8fO3@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-203-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <20210303002855.5819-1-eggert@cs.ucla.edu> <14551115.F8Qjx3YMge@omega> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=85.215.255.24; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de 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, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi Paul, > > a general macro won't cut it e.g. for coreutils. coreutils > > has multithreaded programs ('sort') next to single-threaded programs. > > But coreutils wants to optimize wcwidth. GNULIB_WCHAR_SINGLE actually > > means "assume that the locale has been set before the program becomes > > multithreaded, and won't change afterwards". Similarly, > > '#include "unlocked-io.h"' does not mean that the program is single- > > threaded; it means that no FILE object is being accessed in more than > > one thread. > > Good point. How about this idea? > > * We establish a new macro GNULIB_MBTOWC_SINGLE which means "assume that > at most one thread invokes mbtowc-like functions". The mbtowc > replacement uses this instead of using USE_UNLOCKED_IO. Tar can #define > this new macro. I like this idea. The packages can then define or not define each such macro individually. > * If macros like GNLIB_MBTOWC_SINGLE proliferate, we can have a single > macro GNULIB_SINGLE_THREADED that implies all the other macros. For now > I'm not sure it's worth the bother to do this. I agree, it doesn't seem worth to have such a GNULIB_SINGLE_THREADED macro because - more code becomes multithreaded over time, - the documentation clearly states what each of the individual macros imply. > * If someone has the time, fix the underlying problem that the Gnulib > mbrtowc replacement doesn't link under AIX in some circumstances, unless > you #define GNULIB_MBTOWC_SINGLE. The mbrtowc modules states: Link: $(LIB_MBRTOWC) This link dependency (which expands to -lpthread on AIX) is needed because we document that This function does not put the state into non-initial state when parsing an incomplete multibyte character on some platforms: AIX 7.2. and - Since the state of mbrtowc is hidden, we cannot work around this without reimplementing mbrtowc from scratch. - Since the wide character representation on AIX is locale dependent and undocumented, we cannot roll our own mbrtowc implementation, but must use mbtowc(). - mbtowc() uses global state and is therefore not multithread-safe. > I think I > might want to investigate the possibility of having the mbrtowc > replacement use AIX mbrtowc instead of a lock around AIX mbtowc, as that > should perform better anyway. But I'm not sure AIX is worth the time for > this sort of thing. I don't know what the solution could look like. Bruno