From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 20D013858C60 for ; Wed, 8 Dec 2021 11:49:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 20D013858C60 Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-491-Pvg8ZQmVN0O68QMbSCwSig-1; Wed, 08 Dec 2021 06:49:45 -0500 X-MC-Unique: Pvg8ZQmVN0O68QMbSCwSig-1 Received: by mail-yb1-f200.google.com with SMTP id y125-20020a25dc83000000b005c2326bf744so3924116ybe.21 for ; Wed, 08 Dec 2021 03:49:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S7UWeo8dr6CTb68EAQDHPz+OUvKkLX4CXeFoocCZ+po=; b=6k9iDw3hJYz5XDSPKv9jp5gTt9Jg5Xl+0dMTfU16VNfVU6NGlkF0BzjByHhJCZEuc4 j83XEaSFu0tIytsH8NYVb6LvG8qBx2ZVHmMvO8clazRX5kDTurOHsQQp+kpQxJjSBQri GwMjf1Q5DYk04zmzYIn+Km2cfBeQ9QIKWs64y0sNb0NHEAYNGV8jtDfn3Avgkx7rdtK7 D4fhbJ613vpiezsFPI3EmBPTl1gpxL0dOB9T0LCI0ldAjpe/LO1kLDN0gPSQ0pwmMUth elWor/rlqUML/OoYrBdf7+f/oOra+kwBva7VT0789jc/I+GyYVrf31/uWCcpxl19PW1P CaQA== X-Gm-Message-State: AOAM532YXFP9E8tKn9SEx5MqEoHclnQk618kXIJY26x0oue8cN3OZH8B m3SyfvXaPxJOiAHryj9o2/+olxh17ztNyMeGHd9J0gqc3FUUXArtuyLpzAIQ3u+8xBmHjisGQU4 kwqtDtg3qQFSks1zhWkl+WcLVXN3yrkU= X-Received: by 2002:a25:bcc9:: with SMTP id l9mr57841727ybm.13.1638964184885; Wed, 08 Dec 2021 03:49:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyy6gvOZ8w82HR1yTUJvezzc0a26mlWwpVen42D4KpqoC6j19EQHFVpY/eqBy7mrbJ53PSfMiIp0IQ96/USaQ0= X-Received: by 2002:a25:bcc9:: with SMTP id l9mr57841694ybm.13.1638964184580; Wed, 08 Dec 2021 03:49:44 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 8 Dec 2021 11:49:33 +0000 Message-ID: Subject: Re: [PATCH] libstdc++: Skip atomic instructions in _Sp_counted_base::_M_release when both counts are 1 To: Maged Michael Cc: "libstdc++" , gcc-patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="000000000000064a8e05d2a116fa" X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Dec 2021 11:49:50 -0000 --000000000000064a8e05d2a116fa Content-Type: text/plain; charset="UTF-8" I've pushed this change to trunk now (it was posted and reviewed in stage 1, I just didn't get around to pushing it until now). The final version of the patch is attached to this mail. Thanks for the nice optimization, Maged! On Wed, 4 Aug 2021 at 20:49, Maged Michael via Libstdc++ wrote: > > On Wed, Aug 4, 2021 at 3:32 PM Jonathan Wakely > wrote: > > > On Wed, 4 Aug 2021 at 18:19, Maged Michael wrote: > > > > > > Sorry. I totally missed the rest of your message and the patch. My fuzzy > > eyesight, which usually guesses correctly 90% of the time, mistook > > "Secondly" on a line by itself for "Sincerely" :-) > > > > :-) > > > > > The noinlining was based on looking at generated code. That was for > > clang. It was inlining the _M_last_use function for every instance of > > _M_release (e.g., ~shared_ptr). This optimization with the noinline for > > _M_release_last_use ended up reducing massive binary text sizes by 1.5% > > (several megabytes)., which was an extra benefit. Without the noinline we > > saw code size increase. > > > > Wow, that is a convincing argument for making it not inline, thanks. > > > > > IIUC, we van use the following. Right? > > > > > > __attribute__((__noinline__)) > > > > Right. > > > > > I didn't understand the part about programmers doing #define noinline 1. > > I don't see code in the patch that uses noinline. > > > > This is a valid C++ program: > > > > #define noinline 1 > > #include > > int main() { } > > > > But if anything in uses "noinline" then this valid program > > will not compile. Which is why we must use ((__noinline__)) instead of > > ((noinline)). > > > > Thanks. Now I get it. > > > > > > > > > > > > How about something like this comment? > > > > > > // Noinline to avoid code size increase. > > > > Great, thanks. > > > > On Wed, 4 Aug 2021 at 18:34, Maged Michael wrote: > > > Actually I take back what I said. Sorry. I think the logic in your patch > > is correct. I missed some of the atomic decrements. > > > But I'd be concerned about performance. If we make _M_release_last_use > > noinline then we are adding overhead to the fast path of the original logic > > (where both counts are 1). > > > > Oh, I see. So the code duplication serves a purpose. We want the > > _M_release_last_use() code to be non-inline for the new logic, because > > in the common case we never call it (we either detect that both counts > > are 1 and do the dispose & destroy without atomic decrements, or we do > > a single decrement and don't dispose or destroy anything). But for the > > old logic, we do want that code inlined into _M_release (or > > _M_release_orig as it was called in your patch). Have I got that right > > now? > > > > Yes. Completely right. > > > > What if we remove the __noinline__ from _M_release_last_use() so that > > it can be inlined, but than add a noinline wrapper that can be called > > when we don't want to inline it? > > > > So: > > // Called by _M_release() when the use count reaches zero. > > void > > _M_release_last_use() noexcept > > { > > // unchanged from previous patch, but without the attribute. > > // ... > > } > > > > // As above, but 'noinline' to reduce code size on the cold path. > > __attribute__((__noinline__)) > > void > > _M_release_last_use_cold() noexcept > > { _M_release_last_use(); } > > > > > > And then: > > > > template<> > > inline void > > _Sp_counted_base<_S_atomic>::_M_release() noexcept > > { > > _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count); > > #if ! _GLIBCXX_TSAN > > constexpr bool __lock_free > > = __atomic_always_lock_free(sizeof(long long), 0) > > && __atomic_always_lock_free(sizeof(_Atomic_word), 0); > > constexpr bool __double_word > > = sizeof(long long) == 2 * sizeof(_Atomic_word); > > // The ref-count members follow the vptr, so are aligned to > > // alignof(void*). > > constexpr bool __aligned = __alignof(long long) <= alignof(void*); > > if _GLIBCXX17_CONSTEXPR (__lock_free && __double_word && __aligned) > > { > > constexpr long long __unique_ref > > = 1LL + (1LL << (__CHAR_BIT__ * sizeof(_Atomic_word))); > > auto __both_counts = reinterpret_cast(&_M_use_count); > > > > _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); > > if (__atomic_load_n(__both_counts, __ATOMIC_ACQUIRE) == > > __unique_ref) > > { > > // Both counts are 1, so there are no weak references and > > // we are releasing the last strong reference. No other > > // threads can observe the effects of this _M_release() > > // call (e.g. calling use_count()) without a data race. > > *(long long*)(&_M_use_count) = 0; > > _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count); > > _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); > > _M_dispose(); > > _M_destroy(); > > return; > > } > > if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == > > 1) > > { > > _M_release_last_use_cold(); > > return; > > } > > } > > else > > #endif > > if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1) > > { > > _M_release_last_use(); > > } > > } > > > > > > So we use the noinline version for the else branch in the new logic, > > but the can-inline version for the old logic. Would that work? > > > > Yes. > > > > We could also consider adding __attribute__((__cold__)) to the > > _M_release_last_use_cold() function, and/or add [[__unlikely__]] to > > the 'if' that calls it, but maybe that's overkill. > > > > It seems like this will slightly pessimize the case where the last use > > count is dropped but there are weak refs, as that will take the cold > > path now. That's probably OK, given the benefits for the "both counts > > are 1" case, and that it might reduce the code size for the "use count > > > 1" case. > > > > Right, This pessimizes the case of having weak_ptr-s when the last use is > released (e.g., enable_shared_from_this). > For background, when I applied this optimization there were gains and > losses but overall net gain. Then I investigated whether the losses are > large enough to warrant developing a library for custom shared_ptr-s that > we can use only in the cases of gains and use the standard one for the > cases where we'd lose (for example if gains are 3x and losses are 2x). I > found out that overall (over 100s of services) the gains and losses are > closer to 1.1x gains and 0.1x losses, which didn't warrant the hassle of > maintaining a custom library. > > > > > > It's past 8pm here so I'll come back to this tomorrow and do some code > > size measurements of my own, now that I have a clearer understanding > > of what your original patch was optimizing for. > > > > Thank you very much, Jonathan! > --000000000000064a8e05d2a116fa Content-Type: text/plain; charset="US-ASCII"; name="patch.txt" Content-Disposition: attachment; filename="patch.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kwxgxufc0 Y29tbWl0IGRiZjhiZDNjMmYyY2QyZDI3Y2E0ZjBmZTM3OWJkOTQ5MDI3M2M2ZDcKQXV0aG9yOiBN YWdlZCBNaWNoYWVsIDxtYWdlZC5taWNoYWVsQGdtYWlsLmNvbT4KRGF0ZTogICBUdWUgRGVjIDcg MTU6MjA6NTggMjAyMQoKICAgIGxpYnN0ZGMrKzogU2tpcCBhdG9taWMgaW5zdHJ1Y3Rpb25zIGlu IHNoYXJlZF9wdHIgd2hlbiBib3RoIGNvdW50cyBhcmUgMQogICAgCiAgICBUaGlzIHJld3JpdGVz IF9TcF9jb3VudGVkX2Jhc2U6Ol9NX3JlbGVhc2UgdG8gc2tpcCB0aGUgdHdvIGF0b21pYwogICAg aW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vLyB0aHJlYWRzIGNhbiBvYnNlcnZlIHRoZSBlZmZlY3RzIG9m IHRoaXMgX01fcmVsZWFzZSgpCisJICAgICAgLy8gY2FsbCAoZS5nLiBjYWxsaW5nIHVzZV9jb3Vu dCgpKSB3aXRob3V0IGEgZGF0YSByYWNlLgorCSAgICAgICoobG9uZyBsb25nKikoJl9NX3VzZV9j b3VudCkgPSAwOworCSAgICAgIF9HTElCQ1hYX1NZTkNIUk9OSVpBVElPTl9IQVBQRU5TX0FGVEVS KCZfTV91c2VfY291bnQpOworCSAgICAgIF9HTElCQ1hYX1NZTkNIUk9OSVpBVElPTl9IQVBQRU5T X0FGVEVSKCZfTV93ZWFrX2NvdW50KTsKKwkgICAgICBfTV9kaXNwb3NlKCk7CisJICAgICAgX01f ZGVzdHJveSgpOworCSAgICAgIHJldHVybjsKKwkgICAgfQorCSAgaWYgKF9fZ251X2N4eDo6X19l eGNoYW5nZV9hbmRfYWRkX2Rpc3BhdGNoKCZfTV91c2VfY291bnQsIC0xKSA9PSAxKQorCSAgICBb W19fdW5saWtlbHlfX11dCisJICAgIHsKKwkgICAgICBfTV9yZWxlYXNlX2xhc3RfdXNlX2NvbGQo KTsKKwkgICAgICByZXR1cm47CisJICAgIH0KKwl9CisgICAgICBlbHNlCisjZW5kaWYKKyAgICAg IGlmIChfX2dudV9jeHg6Ol9fZXhjaGFuZ2VfYW5kX2FkZF9kaXNwYXRjaCgmX01fdXNlX2NvdW50 LCAtMSkgPT0gMSkKKwl7CisJICBfTV9yZWxlYXNlX2xhc3RfdXNlKCk7CisJfQorICAgIH0KKwog ICB0ZW1wbGF0ZTw+CiAgICAgaW5saW5lIHZvaWQKICAgICBfU3BfY291bnRlZF9iYXNlPF9TX3Np bmdsZT46Ol9NX3dlYWtfYWRkX3JlZigpIG5vZXhjZXB0Cg== --000000000000064a8e05d2a116fa--