From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id DFD456EC6F; Sat, 13 Feb 2021 01:26:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DFD456EC6F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1613168763; bh=3WLyi3bK6kJi+hjdzbIk5k1IU6B7yFtbxCop0bhxBf8=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=hipV2vUX0CIpe0p3IJWprSlQqEBgvNqOkoF4i963+UpIBrS+Y4i4Qk/7HDO1wL0mS n0+Ecjy4WLWCemPgpfkzJ++3RJh6UMNQirBJags2byCfFIKut8rOE7r58jQIUkHF35 73vBqyvfPVKhKrO6Ku7avmDBzqqXGimg+1pS0gAE= Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C18B06EC6F for ; Sat, 13 Feb 2021 01:26:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C18B06EC6F Received: by mail-lj1-f179.google.com with SMTP id q14so876376ljp.4 for ; Fri, 12 Feb 2021 14:26:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=gM+YmOJghGIrbZC2WsuFoCxy+T8Lk7ujadfpOwQ+tr0=; b=oj4ALie84nxaz06Tl3HYLn4DjPrrpi5DaSgpqhI8d9YDHJcECWnuBr48SX8sbW1257 D5PAOl2FEjRuikmHDU/JCDAK5fk/R7Jp/Ck11/7cTrS9SIUYrGCZznTjXYt9A/f+31zr RVrNmdGqV6JfQ4GBd35/TixHwEQ7pAgGINGbyWbkl/WH0vNURQ3r2rfC6yl256G3Jz1a X4n6BNW+mlZJA9DSwSg2b1hrMIMvX+4ESs37EEdPGMxQ0/O4yruYo3SkFBg11ERED6nV smN4EaHeox2XAM/22UfCuj6ocoeeYxW62ASLlV5fayxGqVg6Mz1oC8lkEEAYgEmGBi45 VePg== X-Gm-Message-State: AOAM532odty5STTKFRmclLFNFRDAlhxsLpmZme2m5gDoiDQxvUEtuZ22 X7m3rr3XV1iqpjQ473JGXMwx+T8qY4w= X-Google-Smtp-Source: ABdhPJwjHl5Z23ocJSsPj074g5jcf83H1wHH4k7hgi1yRiLBmPfJ/sZOhkESLyw0LQScALXX/KA+rQ== X-Received: by 2002:a2e:b522:: with SMTP id z2mr2661371ljm.137.1613168761748; Fri, 12 Feb 2021 14:26:01 -0800 (PST) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id 74sm1316981lfo.268.2021.02.12.14.26.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 14:26:00 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id E0B4A560097; Sat, 13 Feb 2021 01:25:59 +0300 (MSK) Date: Sat, 13 Feb 2021 01:25:59 +0300 To: Vladislav Shpilevoy Message-ID: References: <20210212112541.27561-1-sergepetrenko@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.5 (2021-01-21) Subject: Re: [Tarantool-patches] [PATCH] relay: yield explicitly every N sent rows X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Fri, Feb 12, 2021 at 10:48:49PM +0100, Vladislav Shpilevoy wrote: > > diff --git a/src/box/relay.cc b/src/box/relay.cc > > index df04f8198..afc57dfbc 100644 > > --- a/src/box/relay.cc > > +++ b/src/box/relay.cc > > @@ -836,11 +836,20 @@ relay_send(struct relay *relay, struct xrow_header *packet) > > { > > ERROR_INJECT_YIELD(ERRINJ_RELAY_SEND_DELAY); > > > > + static uint64_t row_cnt = 0; > > Relays are in threads. So this variable either should be thread-local, > or be in struct relay. Otherwise you get non-atomic updates which may > lead to some increments disappearing. That's the good catch! Without lock/tls this gonna be completely arbritrary updates. > Given that thread-local variable access is not free, I would go for > having it in struct relay, but up to you. Actually tls access should be as cheap as regular memory access except using different base register (iirc %fs on linux). But maybe things are changed novadays.