Cake - FQ_codel the next generation
 help / color / mirror / Atom feed
* [Cake] small cake_hash optimization?
@ 2017-11-22 10:06 Pete Heist
  2017-11-22 12:37 ` Pete Heist
  0 siblings, 1 reply; 16+ messages in thread
From: Pete Heist @ 2017-11-22 10:06 UTC (permalink / raw)
  To: Cake List

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;

-----

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-11-23 16:57 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22 10:06 [Cake] small cake_hash optimization? Pete Heist
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox