Cake - FQ_codel the next generation
 help / color / mirror / Atom feed
From: Pete Heist <peteheist@gmail.com>
To: Cake List <cake@lists.bufferbloat.net>
Subject: [Cake] small cake_hash optimization?
Date: Wed, 22 Nov 2017 11:06:18 +0100	[thread overview]
Message-ID: <107CB879-B196-40F1-A7C2-08B963B7A835@gmail.com> (raw)

I’ve been playing around with cake’s hashing and happened to notice in cake_hash that it seems like srchost_idx and dsthost_idx could rather be calculated only if need_allocate_src or need_allocate_dst are true, respectively, as the values are only used inside those code blocks.

I’ve not done any testing on what the real impact of this change would be, or even if it breaks something.

Forgive me for any waste of time if I’ve missed something here...

-----

sysadmin@apu2b:~/src/sch_cake$ git diff sch_cake.c
diff --git a/sch_cake.c b/sch_cake.c
index 97a27be..8f59917 100644
--- a/sch_cake.c
+++ b/sch_cake.c
@@ -747,8 +747,6 @@ cake_hash(struct cake_tin_data *q, const struct sk_buff *skb, int flow_mode)
        }
 
        reduced_hash = flow_hash    % CAKE_QUEUES;
-       srchost_idx  = srchost_hash % CAKE_QUEUES;
-       dsthost_idx  = dsthost_hash % CAKE_QUEUES;
 
        /* set-associative hashing */
        /* fast path if no hash collision (direct lookup succeeds) */
@@ -809,6 +807,7 @@ found:
                q->tags[reduced_hash] = flow_hash;
 
                if (need_allocate_src) {
+                       srchost_idx = srchost_hash % CAKE_QUEUES;
                        inner_hash = srchost_idx % CAKE_SET_WAYS;
                        outer_hash = srchost_idx - inner_hash;
                        for (i = 0, k = inner_hash; i < CAKE_SET_WAYS;
@@ -830,6 +829,7 @@ found_src:
                }
 
                if (need_allocate_dst) {
+                       dsthost_idx = dsthost_hash % CAKE_QUEUES;
                        inner_hash = dsthost_idx % CAKE_SET_WAYS;
                        outer_hash = dsthost_idx - inner_hash;
                        for (i = 0, k = inner_hash; i < CAKE_SET_WAYS;

-----

             reply	other threads:[~2017-11-22 10:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22 10:06 Pete Heist [this message]
2017-11-22 12:37 ` Pete Heist
2017-11-22 13:51   ` Sebastian Moeller
2017-11-22 18:33   ` Dave Taht
2017-11-22 18:43     ` Pete Heist
2017-11-23  8:00       ` Sebastian Moeller
2017-11-23  9:30         ` Pete Heist
2017-11-23  9:36           ` Pete Heist
2017-11-23 16:21             ` Dave Taht
2017-11-23 16:48               ` Sebastian Moeller
2017-11-23 16:57                 ` Dave Taht
2017-11-23 10:22           ` Sebastian Moeller
2017-11-22 18:38   ` Dave Taht
2017-11-22 18:49     ` Pete Heist
2017-11-22 21:19       ` Pete Heist
2017-11-22 21:26         ` Dave Taht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.bufferbloat.net/postorius/lists/cake.lists.bufferbloat.net/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=107CB879-B196-40F1-A7C2-08B963B7A835@gmail.com \
    --to=peteheist@gmail.com \
    --cc=cake@lists.bufferbloat.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox