Skip to content

Implement a distributed final merge for segmented hpx::sort #8032

Open

Description

@divyanshitalreja12

Follow-up to #7578.

Background

#7578 adds a correct first implementation of segmented hpx::sort for partitioned_vector. It sorts physical partitions in place, then gathers the sorted runs on one participating locality for a serial k-way merge.

The current final merge therefore:

  • uses O(N) memory on the coordinating locality;
  • performs a serial O(N log P) merge for P participating runs;
  • streams completed destination runs back, but still materializes the complete input on the coordinator; and
  • commits destination runs incrementally, so failures after stores begin cannot be rolled back.

Follow-up goal

Keep the final merge distributed so that no single locality gathers the full range. Candidate designs discussed during review include:

  • sample/splitter-based redistribution, where each locality sends elements to their final owner and merges locally; or
  • pairwise merge-split stages, where localities exchange only the portion needed to rebalance sorted runs.

The eventual design should preserve segmented subrange handling, execution-policy and exception semantics, comparator serialization requirements, and bounded transfer behavior. It should include multi-locality correctness tests and scalability benchmarks against the centralized implementation.

Coordination

The maintainers have noted that a distributed merge implementation is already under development in house. Please coordinate with them before starting implementation to avoid duplicating that work. This issue is primarily intended to keep the known limitation and follow-up visible.

Activity

  1. coderabbitai commented on Nov 9, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #7578 - Add segmented hpx::sort for partitioned_vector [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. added this to the 2.1.0 milestone on Nov 9, 2026
  3. added
    split: distributed
    on Nov 9, 2026
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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions