From owner-svn-src-all@freebsd.org Thu Feb 27 10:58:14 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7343225CC33; Thu, 27 Feb 2020 10:58:14 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48SqQZ1DYRz457M; Thu, 27 Feb 2020 10:58:13 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: by mail-qk1-x733.google.com with SMTP id m2so2642245qka.7; Thu, 27 Feb 2020 02:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Nv1x3ahO25/EfYijjNj8tNbSWtObpDnV/I/Om+F4Oyc=; b=u9Gmp0QGbUsL0geduurhV6EVvXnz2L5lg5Dq1tuvmCMo29gu5KCehGpaBG74XIWJMA zeabcjRtdfJvUYzj5mBr2wuZq08e5qqPL+s9JugeuDZcIDOnPJTfHMHuX9O40ibHp2J9 LgopnPXSIoI9MpiRFSeVjupIwoWH7UFXf1FBx9+mAGl0jh0UV4Q6jLer/DbUD3lkSz4E bMXSmLu0v1qouneppil5Izht3ZrZkrRWdkv5KE1o7wNlFqfM7vHch/+/AQDdVJenPFKK MReKOvY1q2+LTLlfpNpz9fQ6kPatm0cMNYdYee5Pwm26ritf6u1aEIGkvFD21ChTjG9A ZuZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Nv1x3ahO25/EfYijjNj8tNbSWtObpDnV/I/Om+F4Oyc=; b=lJN99RJ+qwitn+EcaNyCSwJb4mb1aFAVvo2JniZw2hnQmygjzkCago1/jN3YgFlInN XknLnp2QnwDfqxSAlPqJ4l7YNCB+pXHFFrr4TEjcZ2sP9rblwQi8nmVmlgTZitYPFJY+ rX94rSGTCA0Bg4coWUdyb/bkiEhQpPYXslTgxZBNOGZKP5Igd0NA/Eotc/RatuF2qK2m EpKc6Y9edFNKlQ+t/59Yw2Rbeqqhje9YO8RCenvJ/6TUSyhjZr1DBu8EcfzWw/3hRFn5 6KXZXPY6JeEjErHsdTESoYbBfYx13UjD/nOLcTmZjLrJ6PsZsucs/wyI69mCSwvHyJpB AFeQ== X-Gm-Message-State: APjAAAVmkDII9nFoWiIf+iCc85AfyIg2xznkgruqKqqynFemAS6V25F+ uUGp03/1/dbiPY/mcgvn6xdq/ySZ1CQRUay9nos+8bdB X-Google-Smtp-Source: APXvYqyvxYRncMjblaekySETADgdXJfrp3lNuEkbyhFm03Zt1s5zRnWyf/6rdD9EpjHGnn5DcEJCsCuIZC7J3u+8reY= X-Received: by 2002:a37:9fcf:: with SMTP id i198mr4552251qke.337.1582801091938; Thu, 27 Feb 2020 02:58:11 -0800 (PST) MIME-Version: 1.0 References: <202002270823.01R8NAAQ032671@repo.freebsd.org> In-Reply-To: <202002270823.01R8NAAQ032671@repo.freebsd.org> From: Ryan Libby Date: Thu, 27 Feb 2020 02:58:01 -0800 Message-ID: Subject: Re: svn commit: r358377 - head/sys/vm To: Jeff Roberson Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 48SqQZ1DYRz457M X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Feb 2020 10:58:14 -0000 On Thu, Feb 27, 2020 at 12:23 AM Jeff Roberson wrote: > > Author: jeff > Date: Thu Feb 27 08:23:10 2020 > New Revision: 358377 > URL: https://svnweb.freebsd.org/changeset/base/358377 > > Log: > A pair of performance improvements. > > Swap buckets on free as well as alloc so that alloc is always the most > cache-hot data. > > When selecting a zone domain for the round-robin bucket cache use the > local domain unless there is a severe imbalance. This does not affinitize > memory, only locks and queues. > > Reviewed by: markj, rlibby > Differential Revision: https://reviews.freebsd.org/D23824 > > Modified: > head/sys/vm/uma_core.c > > Modified: head/sys/vm/uma_core.c > ============================================================================== > --- head/sys/vm/uma_core.c Thu Feb 27 07:02:33 2020 (r358376) > +++ head/sys/vm/uma_core.c Thu Feb 27 08:23:10 2020 (r358377) > @@ -564,26 +564,29 @@ zone_domain_lock(uma_zone_t zone, int domain) > } > > /* > - * Search for the domain with the least cached items and return it, breaking > - * ties with a preferred domain by returning it. > + * Search for the domain with the least cached items and return it if it > + * is out of balance with the preferred domain. > */ > static __noinline int > zone_domain_lowest(uma_zone_t zone, int pref) > { > - long least, nitems; > + long least, nitems, prefitems; > int domain; > int i; > > - least = LONG_MAX; > + prefitems = least = LONG_MAX; > domain = 0; > for (i = 0; i < vm_ndomains; i++) { > nitems = ZDOM_GET(zone, i)->uzd_nitems; > if (nitems < least) { > domain = i; > least = nitems; > - } else if (nitems == least && (i == pref || domain == pref)) > - domain = pref; > + } > + if (domain == pref) > + prefitems = nitems; > } > + if (prefitems < least * 2) > + return (pref); If think this does need to be <=, not <, for the case where prefitems=0, but it wasn't the first domain. So e.g. if all domains nitems are 0, but pref=1, then with < we return domain=0. > > return (domain); > } > @@ -4102,8 +4105,11 @@ uma_zfree_arg(uma_zone_t zone, void *item, void *udata > bucket = &cache->uc_crossbucket; > } else > #endif > - if (bucket->ucb_cnt >= bucket->ucb_entries) > - bucket = &cache->uc_freebucket; > + if (bucket->ucb_cnt == bucket->ucb_entries && > + cache->uc_freebucket.ucb_cnt < > + cache->uc_freebucket.ucb_entries) > + cache_bucket_swap(&cache->uc_freebucket, > + &cache->uc_allocbucket); > if (__predict_true(bucket->ucb_cnt < bucket->ucb_entries)) { > cache_bucket_push(cache, bucket, item); > critical_exit();