Function JobBuild.AutoLevels
Sort depth that resolves the tree down to roughly leaf granularity.
int AutoLevels (
int | count | |
int | childBits |
Sort depth that resolves the tree down to roughly leaf granularity.
Picks the shallowest depth whose buckets average at most LeafSize agents, so the sort absorbs the levels BuildNode would otherwise spend a full pass on, and BuildNode is left only the buckets that overflowed.
Chosen from a sweep of depths 2..6 over 300..10000 agents: this is the measured optimum at every uniform crowd size tested. Clustered crowds pile into a few buckets and want one level deeper, losing up to 31% here, but biasing a level towards them costs uniform crowds 13-21% and only recovers to within 5%, so the tie goes to the distribution that is not a synthetic extreme. Either way the sort still beats Partition by 37-49% on the clustered case.
The number of sorting buckets will be roughly count/LeafSize.