From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 399B13858D37; Tue, 20 Sep 2022 07:39:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 399B13858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663659548; bh=pfK7OsCbksVHV5eeXlB2h5Xw7llb2rMZ8KC4jqK0pBQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XsUBl2AvPOhZk7/MzG+C9kCFBk1BL0vNkSWm7W2drRPkUOMit6w3jitRBCpjpkIg+ s9scBC7ynm+HwoY6wAbO6EuShD2llpGuMddMceyvfD13txq/wN6GWMrXgr0WdWtxqK xL9R0GFK58VY7Zlmt6EBty4hK0FgZRZ12XjRHVPI= From: "valera.mironow at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/106772] atomic::wait shouldn't touch waiter pool if used platform wait Date: Tue, 20 Sep 2022 07:39:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: valera.mironow at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106772 --- Comment #4 from Mkkt Bkkt --- Nice, thanks for benchmarks without code. Also, why do I need call notify when don't have wait?=20 Common usage from my point of view looks like: atomic.wait(value, mo): while (atomic.load(mo) =3D=3D value) { futex_wait(); } Notify want to looks like: atomic.store(1, mo) atomic.notify_one(); See: https://github.com/lewissbaker/cppcoro/blob/master/lib/lightweight_manual_r= eset_event.cpp https://github.com/YACLib/YACLib/blob/main/src/util/atomic_event.cpp and others So your optimization is pretty useless. Also if for some reason possible few notification, or notify before wait, t= hen possible to have code can looks like: if (atomic.exchange(non_wait_value, mo) =3D=3D wait_value) { atomic.notify_one(); }=