# Merging incomparable linearizations

**URL:** <https://delvingbitcoin.org/t/merging-incomparable-linearizations/209>\
**Category:** Implementation\
**Tags:** wg-cluster-mempool, mempool\
**Created:** [November 19, 2023, 4:12am UTC](https://delvingbitcoin.org/t/merging-incomparable-linearizations/209 "2023-11-19T04:12:15Z")\
**Posts on this page:** 1\
**Showing post:** 44

<div class="post-metadata">

**Author:** ![sipa](https://delvingbitcoin.org/user_avatar/delvingbitcoin.org/sipa/32/1100_2.png) [@sipa](https://delvingbitcoin.org/u/sipa)\
**Post date:** [December 4, 2023, 6:59pm UTC](https://delvingbitcoin.org/t/merging-incomparable-linearizations/209/44 "2023-12-04T18:59:23Z")

</div>

> [@ajtowns](#):
>
> [5] [3,1,8] (feerate 4) [0]

Hmm, indeed. This example shows that bestPi isn’t always as good as the original PiMerge description.

Given that, I lean towards sticking with the original, as I don’t think that the performance difference between the two is significant. If there was no observable difference at all, it’d make sense to pick the faster one, but that doesn’t seem to be the case now?

> [@ajtowns](#):
>
> Merging isn’t necessarily commutative either, I think, in the case where both linearisations have different (eg, non-overlapping) first chunks at equal feerates.

The linearizations that come out can differ depending on whether the transactions from L\_1 or L\_2 is chosen when the found subsets have the same feerate, ~~but I believe this cannot affect the fee-size diagram. Generally I use “smaller size is better” as tie-breaker when comparing equal-feerate chunks, as inside linearization algorithms this sometimes avoids accidentally merging equal-feerate subsets, but I don’t believe it matters here what tie-breaker is chosen. Do you have a counter-example?~~

EDIT: here is a counterexample:

- Transactions: A=1, B=2, C=3, D=2, E=1 (all same size)
- L1: [B,E,C,A,D], chunked as [B:2, EC:2, AD:1.5]
- L2: [D,B,A,C,E], chunked as [D:2, B:2, AC:2, E:1]
- Merge(L1,L2): [B,C,D,E,A], chunked as [BC:2.5, D:2, E:1, A:1]
- Merge(L2,L1): [D,B,C,A,E], chunked as [DBC:2.33, A:1, E:1]

---

_[View the full topic](https://delvingbitcoin.org/t/merging-incomparable-linearizations/209)._
