Skip to content

Grouped line envelope loses resolution for groups that span part of the x domain #16

Open

Description

@jvdd

_streaming_envelope_planinflexviz/trace/line.pycuts min-max buckets on the **global** x range and shares that one grid across every group. A group that occupies part of the domain therefore receives only a proportional share of the point budget. Before the change each group got its ownn_points`, because the plugin kernel ran once per group.

Reproduction

3000 rows. Group a holds x 0..299, group b holds x 300..2999.
LinePlot(x="t", y="v", group_by="g", n_points=20).

main    -> group 'a': 20 points, group 'b': 20 points
branch  -> group 'a':  2 points, group 'b': 18 points

Group a covers 10 percent of the domain, so it lands in 1 of the 10 global buckets and renders as 2 points instead of a 20-point envelope.

Impact

This has minimal visual impact, only when we toggle traces (and the trace with a smaller span is the only one visible) it will look quite janky.

Why it is not a simple fix
Per-group buckets need per-group x bounds, which is an extra pass over the data or a second aggregate in the same pass. The current design deliberately buys its 3.2x speed and 11x memory win with a single pass

This will require substantial benchmarking prior to selecting what we land on

Activity

  1. jvdd commented on Sep 3, 2026

    @jvdd
    ContributorAuthor

    Planning decision, 2026-09-03: keep the global x-domain bucket grid for the first implementation. This is provisional, not a resolution of the product semantics. Do not build a per-group alternative now. Keep this issue open and revisit when visual testing or user reports show that partial-domain groups lose unacceptable detail, then benchmark the global and per-group policies under the same memory limit before changing the default.

  2. jvdd commented on Sep 5, 2026

    @jvdd
    ContributorAuthor

    On branch feat/line-grouped, not merged yet.

    Grouped x-width lines now bucket on the same global grid as an ungrouped line
    over the same x column and n_points (6e015d6, 1309075). One streaming
    group_by(key, bucket) plan runs on both source kinds, for minmax, fpcs and
    lttb. Row-count buckets per group are gone. nth keeps its stride per group.

    The open question stays open: a group that covers a tenth of the x domain now
    gets about a tenth of the budget. A short series therefore gets few points, and
    a series that spans the whole domain gets the full budget. This is provisional.
    tests/test_trace_line.py::TestGroupedXWidthBuckets pins the current split, so
    a change to it fails a test on purpose.

    A per-group grid was not measured. It would give every series a full budget, but it puts the series on different edges, so the children of one parent are no longer comparable point by point. Benchmark both policies under one memory cap before changing the default.

    Measured on 100M rows with 10 groups (Apple M5): the streaming plan takes 0.8
    to 0.95 s and 16 MiB, against 1.2 to 1.6 s and 3.8 to 5.7 GiB for the old
    kernel inside group_by().agg().

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