← All projects
Project record1 mention
Originally shared on Hacker News

Merge sort performance investigation

A merge sort implementation written for a daily coding problem, accompanied by an ongoing blog series investigating a repeatable performance drop: linked lists of 2^21 nodes sort faster than lists of 2^21 + 1 nodes, with follow-up posts exploring cache sizes, node size, sorted vs reverse-sorted input, recursive variants, and garbage collection.

Last shared
01 / The problem

What it addresses

A bizarre, repeatable performance drop occurs in the merge sort when one extra node is added to a linked list (e.g., lists of 2^21 + 1 nodes sort slower than lists of 2^21 nodes).

02 / Source history

Shared over time

Each entry reflects what was shared on that date. Details may have changed since then.

  1. Merge sort performance investigation

    A merge sort implementation written for a daily coding problem, accompanied by an ongoing blog series investigating a repeatable performance drop: linked lists of 2^21 nodes sort faster than lists of 2^21 + 1 nodes, with follow-up posts exploring cache sizes, node size, sorted vs reverse-sorted input, recursive variants, and garbage collection.

    Problem: A bizarre, repeatable performance drop occurs in the merge sort when one extra node is added to a linked list (e.g., lists of 2^21 + 1 nodes sort slower than lists of 2^21 nodes).

    Posted by @bediger4000 · Original source ↗

    Source text · @bediger4000 · · Source ↗

    Trying to figure out a bizarre performance drop in a merge sort I wrote for one of those daily coding problems. https://bruceediger.com/posts/mergesort-investigation-1/ It seems that adding one node to a linked list causes a repeatable performance drop. That is, linked lists of say 2^21 nodes sort faster than lists of 2^21 + 1 nodes.