facebookresearch / torchrec
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 860 units with 5,242 lines of code in units (40.6% of code).
    • 0 very long units (0 lines of code)
    • 5 long units (355 lines of code)
    • 30 medium size units (831 lines of code)
    • 70 small units (968 lines of code)
    • 755 very small units (3,088 lines of code)
0% | 6% | 15% | 18% | 58%
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% | 14% | 17% | 60%
cpp0% | 0% | 41% | 29% | 29%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
torchrec/distributed0% | 3% | 14% | 16% | 65%
torchrec/linter0% | 66% | 14% | 10% | 8%
torchrec/optim0% | 28% | 8% | 17% | 45%
torchrec/sparse0% | 10% | 17% | 30% | 42%
torchrec/datasets0% | 0% | 26% | 19% | 54%
torchrec/modules0% | 0% | 24% | 22% | 53%
torchrec/quant0% | 0% | 0% | 22% | 78%
torchrec/models0% | 0% | 0% | 0% | 100%
torchrec/fx0% | 0% | 0% | 0% | 100%
torchrec0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def check_class_definition()
in torchrec/linter/module_linter.py
98 36 2
def load_state_dict()
in torchrec/optim/keyed.py
76 25 3
def split()
in torchrec/sparse/jagged_tensor.py
71 6 2
def from_float()
in torchrec/distributed/quant_embedding_kernel.py
57 16 2
def _partition_by_host()
in torchrec/distributed/planner/partitioners.py
53 11 2
def _generate_batch()
in torchrec/datasets/random.py
46 2 1
def _call_impl()
in torchrec/modules/lazy_extension.py
45 32 3
def _init_combined_embeddings()
in torchrec/distributed/cw_sharding.py
42 10 1
def backward()
in torchrec/distributed/comm_ops.py
39 3 2
def __iter__()
in torchrec/datasets/criteo.py
35 7 1
def forward()
in torchrec/modules/crossnet.py
35 6 2
def progress()
in torchrec/distributed/train_pipeline.py
34 8 2
def _wait_impl()
in torchrec/distributed/dist_data.py
29 4 1
def _load_data_for_rank()
in torchrec/datasets/criteo.py
29 6 1
def forward()
in torchrec/distributed/grouped_position_weighted.py
28 5 2
def get_momentum()
in torchrec/distributed/batched_embedding_kernel.py
27 3 1
def load()
in torchrec/distributed/planner/proposers.py
27 9 2
TupleOptionalFields KeyedJaggedTensor::to()
in torchrec/sparse/jagged_tensor_ops.cpp
27 4 2
def _init_ddp()
in torchrec/distributed/model_parallel.py
26 7 1
def progress()
in torchrec/distributed/train_pipeline.py
25 5 2