Skip to content

MetaLB with TreeLB is unreliable when some PEs have no objects #4343

In progress

Description

@lvkale

Two defects, both only when at least one PE has no array elements (for example more PEs than elements). Found by reading while reviewing #4342; the first was also observed in runs. Neither is changed by #4342.

1. Abort "Intermingling iterations in MetaBalancer" (src/ck-ldb/MetaBalancer.C, the check near line 76).

  • lbdb_no_obj_callback marks a PE as having no objects. It is cleared only when lb_in_progress is set (near line 1027), and only CentralLB sets lb_in_progress (CentralLB.C near line 635); TreeLB never does.
  • After each step an empty PE therefore registers again (near lines 274 and 1016), PE 0 sends it TriggerAdaptiveReduction two or more times per iteration (near lines 559-562), and it contributes to the statistics reduction more often than the other PEs.
  • Its k-th contribution then carries a different ITER_NO from the others' k-th contribution, and the check aborts.
  • Observed: with fewer elements than PEs, tests/charm++/load_balancing/meta_lb_test aborts with this message on recharm with and without MetaLB: every PE switches strategy before the balancing step starts #4342. The cause above is from the code and was not confirmed by a traced run.
  • Likely fix: TreeLB sets and clears the in-progress flag as CentralLB does.

2. An empty PE can start a balancing step alone.

  • A PE without elements starts its step from a CkSyncBarrier kick (cksyncbarrier.C near lines 186-187), not from MetaLBCallLBOnChares.
  • If it finishes the step, receives migrated elements and resumes them before its own copy of MetaLBCallLBOnChares arrives, that broadcast (MetaBalancer.C near line 928, through cklocation.C near lines 1770-1773) puts every element at the barrier again and starts a step on that PE only. Its awaitingLB[0] and the root's awaitingLB[1] stay true.
  • Before MetaLB: every PE switches strategy before the balancing step starts #4342 this sequence hangs. With MetaLB: every PE switches strategy before the balancing step starts #4342's guard in TreeLB::configure, the next balancer switch aborts with a message.
  • Not reproduced; from the code.

Scope. MetaLB (+MetaLB) with TreeLB-based balancers. The same code is on classic.

Timing. The asynchronous load-balancing work in progress changes how a step starts and completes on each PE; it may be better to fix these after it lands, or as part of it.

Activity

  1. lvkale commented on Dec 1, 2026

    @lvkale
    ContributorAuthor

    A third defect, found by @adityapb in his review of #4356 (from the code; not reproduced). (Written with Claude Code.)

    A PE with no objects can miss the trigger loop for good.

    • HandleAdaptiveNoObj sends RegisterNoObjCallback to PE 0 and contributes at once (MetaBalancer.C 998-999).
    • If that contribution completes reduction k and PE 0 handles ReceiveMinStats(k) before the registration, the loop at 552-553 skips the PE. It never contributes k+1, and reduction k+1 never completes.
    • PE 0 then handles no further statistics. At startup no period has been decided yet, so MetaLB never balances, with no abort and no hang. A -anylb run of period_selection would report it as a pass.
    • The fallback below (1021-1027) is commented out, and uncommenting it is not enough: outside CentralLB its guard lb_iter_no != -1 holds after the first reduction (only ResetAdaptive resets it), so every registration after a step would add a contribution.

    Proposed direction: the registration carries the iteration the PE contributed, so that PE 0 can tell whether it has already handled that reduction and, if so, trigger the PE for the next one.

    #4356 fixes the first defect here (duplicate registration); the second (an empty PE starting a step alone, through cksyncbarrier.C and cklocation.C) and this one remain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions