Home / Function/ compare() — netty Function Reference

compare() — netty Function Reference

Architecture documentation for the compare() function in WeightedFairQueueByteDistributor.java from the netty codebase.

Function java Buffer Allocators calls 2 called by 2

Entity Profile

Dependency Diagram

graph TD
  b3a17d55_8d87_d700_8e02_461a42255873["compare()"]
  0efd6e94_f7c3_5a76_d967_17d4b213f016["StateOnlyComparator"]
  b3a17d55_8d87_d700_8e02_461a42255873 -->|defined in| 0efd6e94_f7c3_5a76_d967_17d4b213f016
  b7827799_3c40_3610_92dd_e707a1460416["compare()"]
  b7827799_3c40_3610_92dd_e707a1460416 -->|calls| b3a17d55_8d87_d700_8e02_461a42255873
  0f84cad1_72bf_48c4_a975_f58d297dd3c2["WeightedFairQueueByteDistributor()"]
  0f84cad1_72bf_48c4_a975_f58d297dd3c2 -->|calls| b3a17d55_8d87_d700_8e02_461a42255873
  b7827799_3c40_3610_92dd_e707a1460416["compare()"]
  b3a17d55_8d87_d700_8e02_461a42255873 -->|calls| b7827799_3c40_3610_92dd_e707a1460416
  cb7ef7cf_b5d7_3970_73e0_dd1eeb1d55f6["wasStreamReservedOrActivated()"]
  b3a17d55_8d87_d700_8e02_461a42255873 -->|calls| cb7ef7cf_b5d7_3970_73e0_dd1eeb1d55f6
  style b3a17d55_8d87_d700_8e02_461a42255873 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/WeightedFairQueueByteDistributor.java lines 397–415

        @Override
        public int compare(State o1, State o2) {
            // "priority only streams" (which have not been activated) are higher priority than streams used for data.
            boolean o1Actived = o1.wasStreamReservedOrActivated();
            if (o1Actived != o2.wasStreamReservedOrActivated()) {
                return o1Actived ? -1 : 1;
            }
            // Numerically greater depth is higher priority.
            int x = o2.dependencyTreeDepth - o1.dependencyTreeDepth;

            // I also considered tracking the number of streams which are "activated" (eligible transfer data) at each
            // subtree. This would require a traversal from each node to the root on dependency tree structural changes,
            // and then it would require a re-prioritization at each of these nodes (instead of just the nodes where the
            // direct parent changed). The costs of this are judged to be relatively high compared to the nominal
            // benefit it provides to the heuristic. Instead folks should just increase maxStateOnlySize.

            // Last resort is to give larger stream ids more priority.
            return x != 0 ? x : o1.streamId - o2.streamId;
        }

Domain

Subdomains

Frequently Asked Questions

What does compare() do?
compare() is a function in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/WeightedFairQueueByteDistributor.java.
Where is compare() defined?
compare() is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/WeightedFairQueueByteDistributor.java at line 397.
What does compare() call?
compare() calls 2 function(s): compare, wasStreamReservedOrActivated.
What calls compare()?
compare() is called by 2 function(s): WeightedFairQueueByteDistributor, compare.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free