From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 7317F2C75E for ; Sat, 29 Sep 2018 01:05:35 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7KT6sTjPlt-I for ; Sat, 29 Sep 2018 01:05:35 -0400 (EDT) Received: from smtp62.i.mail.ru (smtp62.i.mail.ru [217.69.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id DD8422C6D5 for ; Sat, 29 Sep 2018 01:05:34 -0400 (EDT) Received: by smtp62.i.mail.ru with esmtpa (envelope-from ) id 1g67Rc-0006ST-UU for tarantool-patches@freelists.org; Sat, 29 Sep 2018 08:05:33 +0300 Date: Sat, 29 Sep 2018 08:05:31 +0300 From: Konstantin Osipov Subject: [tarantool-patches] Re: [PATCH v2 05/11] vinyl: implement quota wait queue without fiber_cond Message-ID: <20180929050531.GI32712@chai> References: <2144ee719cddf90f43389ebfb9979a2b4c5ee478.1538155645.git.vdavydov.dev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2144ee719cddf90f43389ebfb9979a2b4c5ee478.1538155645.git.vdavydov.dev@gmail.com> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org * Vladimir Davydov [18/09/28 21:00]: > Using fiber_cond as a wait queue isn't very convenient, because: > - It doesn't allow us to put a spuriously woken up fiber back to the > same position in the queue where it was, thus violating fairness. > - It doesn't allow us to check whether we actually need to wake up a > fiber or it will have to go back to sleep anyway as it needs more > memory than currently available. > - It doesn't allow us to implement a multi-queue approach where fibers > that have different priorities are put to different queues. > > So let's rewrite the wait queue with plain rlist and fiber_yield. Maybe you could factor out this change into an abstraction in fiber.[hc]? Or fix fiber_cond to be fair? > > @@ -92,7 +91,17 @@ vy_quota_check_limit(struct vy_quota *q) > static void > vy_quota_signal(struct vy_quota *q) > { > - fiber_cond_signal(&q->cond); > + if (!rlist_empty(&q->wait_queue)) { > + struct vy_quota_wait_node *n; > + n = rlist_first_entry(&q->wait_queue, > + struct vy_quota_wait_node, in_wait_queue); > + /* > + * No need in waking up a consumer if it will have > + * to go back to sleep immediately. > + */ > + if (vy_quota_may_use(q, n->size)) > + fiber_wakeup(n->fiber); > + } > } -- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.io - www.twitter.com/kostja_osipov