From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id BD94E3858438 for ; Thu, 19 Aug 2021 11:20:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BD94E3858438 Received: by mail-pl1-x636.google.com with SMTP id c17so3742848plz.2 for ; Thu, 19 Aug 2021 04:20:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Dw+qBM87hPlqI7PgxI1uHiUrehNsRsD7nvLivMDvgLg=; b=FuiEhQdRDyv+gFLaUqT+wHm+O3b0Km2VEuKVkcS6nS3i9HY4c45QXxHXUNEaM9TXVP +Zk8rV1R/pcsqUBttQnbUu6PotQ10xI2kUnuxm0XHwPkI2BP/h8XIZU4yFDWHMUDRQ8i hUvMSNN19ZFhD1imhWDcKtiu0UPaMWNZdmufUa+jWtT256s3HNEKzuTXkK/ZTsz2dIWY mSIE6Ly5orAfqfx68MFAIbv9nXXMHHzdnJDbwwUt09ARMpksobLrBCTvYQKgvkofNFsb UnwUy8wa7S4PO191iEPirXe5bXX29bZ/t/z6V/fRJGoUKCxkPMxxEph1h/5q57vpojov W+sw== X-Gm-Message-State: AOAM5324qYcN1XPvIAj1YfiwqARQcVSItjSzjdQuXpHZBh3GCCJbNpCo sTe0W4QkTNC7ixu+ezeuZlGCMdJJAgmK7A== X-Google-Smtp-Source: ABdhPJxnpG6MCbVBNsNwOM+E6aOPlDfCAlmnmBzD8l7QgXcuX8e2eEoQoA5WC2l+BF6uj3PJ1q1SGQ== X-Received: by 2002:a17:90b:903:: with SMTP id bo3mr14683625pjb.103.1629372053665; Thu, 19 Aug 2021 04:20:53 -0700 (PDT) Received: from ?IPv6:2804:431:c7ca:cd83:aa1a:7bd:9935:9bba? ([2804:431:c7ca:cd83:aa1a:7bd:9935:9bba]) by smtp.gmail.com with ESMTPSA id e12sm3088931pfv.146.2021.08.19.04.20.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Aug 2021 04:20:51 -0700 (PDT) Subject: Re: nextafter() about an order of magnitude slower than trivial implementation To: Stefan Kanthak , Szabolcs Nagy Cc: libc-help@sourceware.org References: <20210818125119.GH25257@arm.com> From: Adhemerval Zanella Message-ID: <741b2c48-a754-51c5-cb72-a2f97795e30f@linaro.org> Date: Thu, 19 Aug 2021 08:20:49 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Aug 2021 11:21:05 -0000 On 18/08/2021 14:11, Stefan Kanthak wrote: > Szabolcs Nagy wrote: > >> The 08/16/2021 18:03, Stefan Kanthak wrote: >>> Testing and benchmarking an exponential function that consumes >>> about 10ns/call on an AMD EPYC 7262, I noticed that nextafter() >>> itself is DEAD SLOW: it consumes about 8.5ns/call! >>> >>> The following (quick&dirty) implementation consumes 0.7ns/call, >>> i.e. is about an order of magnitude faster: >> >> correctly measuring latency on a modern x86_64 core: >> >> musl: 3.16 ns >> glibc: 5.68 ns >> your: 5.72 ns Thanks for bring this up, if you want to contribute a patch please follow the Contribution checklist [1]. We recently dropped the requirement of the FSF contribution, so you can use a SCO-like license on the patches. To change the current implementation I suggest you to also provide a benchmark using glibc benchmark framework. Some maths functions provide both latency and reciprocal-throughput information, and with both numbers we can evaluate if the new implementation is indeed better on different machines. I would just like to ask to keep the tone respectful and be open to suggestion and criticize, so you do not repeat the same derail thread on musl maillist [1]. Szabolcs and Wilco did an excellent job on some newer math functions implementation, you might read the old thread to see how was their approach. [1] https://sourceware.org/glibc/wiki/Contribution%20checklist [2] https://www.openwall.com/lists/musl/2021/08/15/18