facebookresearch / fairscale
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 3,052 units with 11,371 lines of code in units (63.2% of code).
    • 0 very long units (0 lines of code)
    • 11 long units (698 lines of code)
    • 77 medium size units (2,320 lines of code)
    • 163 small units (2,323 lines of code)
    • 2,801 very small units (6,030 lines of code)
0% | 6% | 20% | 20% | 53%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py0% | 7% | 25% | 25% | 42%
pyi0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
benchmarks0% | 31% | 30% | 20% | 18%
benchmarks/experimental0% | 14% | 35% | 23% | 26%
fairscale/optim0% | 15% | 24% | 29% | 31%
fairscale/nn0% | 3% | 22% | 24% | 49%
fairscale/experimental0% | 4% | 27% | 24% | 43%
fairscale/utils0% | 9% | 20% | 27% | 42%
benchmarks/datasets0% | 0% | 33% | 40% | 25%
benchmarks/golden_configs0% | 0% | 0% | 39% | 60%
ROOT0% | 0% | 0% | 59% | 40%
benchmarks/models0% | 0% | 0% | 13% | 86%
stubs/torch0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def train()
in benchmarks/pipe.py
78 25 5
def step()
in fairscale/optim/adam.py
77 24 3
def train()
in benchmarks/moe.py
77 12 5
def _rebuild_full_params()
in fairscale/nn/data_parallel/fully_sharded_data_parallel.py
67 38 2
def train()
in benchmarks/experimental/offload.py
65 11 5
def run_on_gpu()
in benchmarks/experimental/benchmark_mevo.py
64 14 5
def _get_reduce_fn()
in fairscale/nn/data_parallel/sharded_ddp.py
59 14 4
def backward()
in fairscale/experimental/nn/offload.py
57 20 2
def torch_spawn()
in fairscale/utils/testing.py
52 11 1
def forward()
in fairscale/experimental/nn/mevo.py
51 15 3
def consolidate_state_dict()
in fairscale/optim/oss.py
51 12 2
def _wait_for_post_backward()
in fairscale/nn/data_parallel/fully_sharded_data_parallel.py
50 42 1
def summon_full_params()
in fairscale/nn/data_parallel/fully_sharded_data_parallel.py
46 15 3
def update()
in fairscale/optim/grad_scaler.py
46 13 3
def compute()
in fairscale/experimental/nn/distributed_pipeline/partition_handler.py
45 12 3
def objects_are_equal()
in fairscale/utils/testing.py
45 22 4
def step()
in benchmarks/experimental/experimental_async_approaches.py
45 13 2
def mix()
in fairscale/experimental/nn/data_parallel/gossip/gossiper.py
44 8 3
def dist_init()
in fairscale/utils/testing.py
44 15 4
def create_graph()
in fairscale/experimental/nn/distributed_pipeline/trace.py
43 19 1