Skip to content

Conversation

toddtreece
Copy link
Member

@toddtreece toddtreece commented Oct 2, 2025

What this PR does / why we need it:

goos: darwin
goarch: arm64
pkg: github.com/grafana/grafana-plugin-sdk-go/data
cpu: Apple M4 Pro
                                                │    old.txt    │               new.txt                │
                                                │    sec/op     │    sec/op     vs base                │
MarshalArrow_Small                                 5.286µ ±  0%   5.051µ ±  1%   -4.45% (p=0.000 n=10)
MarshalArrow_Medium_100Rows                        12.87µ ±  0%   11.93µ ±  0%   -7.31% (p=0.000 n=10)
MarshalArrow_Medium_1000Rows                       37.21µ ±  0%   35.19µ ±  0%   -5.43% (p=0.000 n=10)
MarshalArrow_Large_10000Rows                       1.450m ± 11%   1.053m ± 19%  -27.39% (p=0.000 n=10)
MarshalArrow_Large_100000Rows                      11.05m ±  2%   10.05m ±  1%   -9.04% (p=0.000 n=10)
MarshalArrow_Wide_100x100                          233.2µ ±  0%   178.1µ ±  1%  -23.61% (p=0.000 n=10)
MarshalArrow_NumericOnly_10000Rows                 239.7µ ±  1%   153.0µ ±  0%  -36.19% (p=0.000 n=10)
MarshalArrow_TimeSeries_10000Rows                 145.55µ ±  1%   87.96µ ±  3%  -39.57% (p=0.000 n=10)
UnmarshalArrowFrame_Small                          2.546µ ±  0%   3.214µ ±  0%  +26.26% (p=0.000 n=10)
UnmarshalArrowFrame_Medium_100Rows                12.562µ ±  0%   8.287µ ±  4%  -34.03% (p=0.000 n=10)
UnmarshalArrowFrame_Medium_1000Rows                85.32µ ±  1%   30.74µ ±  0%  -63.97% (p=0.000 n=10)
UnmarshalArrowFrame_Large_10000Rows                2.966m ±  4%   1.638m ±  2%  -44.78% (p=0.000 n=10)
UnmarshalArrowFrame_Large_100000Rows               36.25m ±  2%   21.35m ±  3%  -41.10% (p=0.000 n=10)
UnmarshalArrowFrame_Wide_100x100                   184.3µ ±  1%   106.5µ ±  4%  -42.19% (p=0.000 n=10)
UnmarshalArrowFrame_NumericOnly_10000Rows         478.44µ ±  2%   39.10µ ±  1%  -91.83% (p=0.000 n=10)
UnmarshalArrowFrame_TimeSeries_10000Rows          646.90µ ±  4%   66.87µ ±  0%  -89.66% (p=0.000 n=10)
ArrowRoundTrip_Small                               8.498µ ±  2%   8.617µ ±  4%   +1.41% (p=0.029 n=10)
ArrowRoundTrip_Medium_1000Rows                    131.95µ ±  1%   63.94µ ±  4%  -51.54% (p=0.000 n=10)
ArrowRoundTrip_Large_10000Rows                     5.112m ±  7%   2.625m ±  2%  -48.65% (p=0.000 n=10)
FrameToArrowTable_Small                            1.703µ ±  3%   1.668µ ±  1%   -2.06% (p=0.027 n=10)
FrameToArrowTable_Medium_1000Rows                  28.66µ ±  2%   27.51µ ±  0%   -4.01% (p=0.000 n=10)
FrameToArrowTable_Large_10000Rows                 1038.8µ ± 24%   995.8µ ±  1%   -4.14% (p=0.001 n=10)
FromArrowRecord_Small                              528.5n ±  3%   345.4n ±  1%  -34.65% (p=0.000 n=10)
FromArrowRecord_Medium_1000Rows                    80.80µ ±  1%   26.10µ ±  1%  -67.70% (p=0.000 n=10)
FromArrowRecord_Large_10000Rows                    3.128m ±  2%   1.678m ±  2%  -46.37% (p=0.000 n=10)
FramesMarshalArrow_5Frames_1000Rows                234.1µ ±  0%   205.0µ ±  0%  -12.44% (p=0.000 n=10)
FramesMarshalArrow_10Frames_100Rows                146.3µ ±  2%   127.0µ ±  0%  -13.20% (p=0.000 n=10)
UnmarshalArrowFrames_5Frames_1000Rows              457.6µ ±  1%   198.4µ ±  1%  -56.64% (p=0.000 n=10)
UnmarshalArrowFrames_10Frames_100Rows             133.56µ ±  0%   91.56µ ±  0%  -31.45% (p=0.000 n=10)
MarshalArrow_StringHeavy_1000Rows                  32.43µ ±  3%   31.79µ ±  1%        ~ (p=0.190 n=10)
UnmarshalArrowFrame_StringHeavy_1000Rows           27.38µ ±  1%   30.88µ ±  0%  +12.82% (p=0.000 n=10)
MarshalArrow_WithMetadataAndLabels_1000Rows        51.80µ ±  0%   46.57µ ±  0%  -10.09% (p=0.000 n=10)
FrameToJSON_IncludeAll                             20.75µ ±  0%   13.04µ ±  1%  -37.14% (p=0.000 n=10)
FrameToJSON_SchemaOnly                             9.461µ ±  3%   8.264µ ±  1%  -12.65% (p=0.000 n=10)
FrameToJSON_DataOnly                              10.960µ ±  1%   4.597µ ±  1%  -58.05% (p=0.000 n=10)
FrameJSONCache_Create                              21.06µ ±  1%   13.04µ ±  1%  -38.07% (p=0.000 n=10)
FrameJSONCache_Bytes/IncludeAll                    978.1n ±  3%   540.0n ±  2%  -44.78% (p=0.000 n=10)
FrameJSONCache_Bytes/SchemaOnly                    419.6n ±  3%   403.1n ±  0%   -3.92% (p=0.000 n=10)
FrameJSONCache_Bytes/DataOnly                      220.3n ±  1%   217.5n ±  1%   -1.27% (p=0.000 n=10)
FrameUnmarshalJSON                                 83.18µ ±  1%   77.36µ ±  0%   -6.99% (p=0.000 n=10)
FrameUnmarshalJSON_FromFrameToJSON                 82.83µ ±  4%   77.23µ ±  1%   -6.76% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_10                     4.303µ ±  4%   3.376µ ±  0%  -21.53% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_100                    27.68µ ±  3%   19.92µ ±  0%  -28.04% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_1000                   263.7µ ±  1%   187.1µ ±  0%  -29.04% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_10000                  2.807m ±  2%   1.801m ±  3%  -35.85% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_10                   5.374µ ±  4%   5.413µ ±  0%        ~ (p=0.853 n=10)
FrameUnmarshalJSON_Sizes/Rows_100                  26.10µ ±  2%   25.17µ ±  0%   -3.55% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_1000                 248.1µ ±  1%   232.1µ ±  2%   -6.43% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_10000                2.291m ±  1%   2.499m ±  5%   +9.08% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/TimeNoNanos            77.36µ ±  2%   46.92µ ±  2%  -39.34% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/TimeWithNanos         113.56µ ±  2%   78.32µ ±  2%  -31.03% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableTime           79.92µ ±  1%   43.11µ ±  1%  -46.06% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Float64Clean           71.81µ ±  1%   55.07µ ±  1%  -23.31% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Float64WithSpecials    71.11µ ±  1%   53.43µ ±  0%  -24.86% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Float32WithSpecials    70.64µ ±  1%   53.30µ ±  2%  -24.55% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Int64                  38.27µ ±  1%   25.91µ ±  0%  -32.29% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableInt64          38.21µ ±  0%   26.43µ ±  1%  -30.81% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Uint64                 36.68µ ±  1%   24.78µ ±  0%  -32.44% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableUint64         36.06µ ±  1%   25.52µ ±  0%  -29.24% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/String                 77.57µ ±  0%   57.90µ ±  0%  -25.35% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableString         73.17µ ±  0%   55.29µ ±  0%  -24.44% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Bool                   34.40µ ±  1%   26.26µ ±  1%  -23.67% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/JSON                  242.13µ ±  0%   59.20µ ±  4%  -75.55% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Enum                   26.96µ ±  0%   17.01µ ±  3%  -36.90% (p=0.000 n=10)
FrameMarshalJSON_Parallel                          41.78µ ±  3%   33.64µ ±  0%  -19.49% (p=0.000 n=10)
FrameMarshalJSON_ParallelLarge                     264.7µ ±  1%   187.5µ ±  0%  -29.15% (p=0.000 n=10)
FrameUnmarshalJSON_Parallel                        78.47µ ±  1%   77.84µ ±  0%   -0.80% (p=0.007 n=10)
FrameMarshalJSON_WithLabels/NoLabels               178.1µ ±  1%   126.4µ ±  1%  -29.05% (p=0.000 n=10)
FrameMarshalJSON_WithLabels/SmallLabels            180.0µ ±  2%   126.6µ ±  1%  -29.65% (p=0.000 n=10)
FrameMarshalJSON_WithLabels/ManyLabels             184.4µ ±  1%   126.7µ ±  2%  -31.32% (p=0.000 n=10)
FrameMarshalJSON_WithMeta/NoMeta                   181.4µ ±  2%   125.3µ ±  2%  -30.95% (p=0.000 n=10)
FrameMarshalJSON_WithMeta/WithMeta                 181.2µ ±  1%   129.7µ ±  0%  -28.38% (p=0.000 n=10)
ArrowToJSON                                        39.10µ ±  1%   38.02µ ±  1%   -2.76% (p=0.000 n=10)
FrameRoundtrip                                     123.4µ ±  1%   114.0µ ±  1%   -7.62% (p=0.000 n=10)
FrameToJSON                                        20.52µ ±  1%   13.11µ ±  0%  -36.10% (p=0.000 n=10)
FrameMarshalJSONStd                                41.81µ ±  1%   33.78µ ±  1%  -19.21% (p=0.000 n=10)
FrameMarshalJSONIter                               18.01µ ±  1%   13.19µ ±  0%  -26.76% (p=0.000 n=10)
geomean                                            70.91µ         48.87µ        -31.09%

                                                │    old.txt    │                new.txt                 │
                                                │     B/op      │     B/op      vs base                  │
MarshalArrow_Small                                 12.59Ki ± 0%   10.95Ki ± 0%  -12.97% (p=0.000 n=10)
MarshalArrow_Medium_100Rows                        42.24Ki ± 0%   29.17Ki ± 0%  -30.93% (p=0.000 n=10)
MarshalArrow_Medium_1000Rows                       167.5Ki ± 0%   137.8Ki ± 0%  -17.72% (p=0.000 n=10)
MarshalArrow_Large_10000Rows                       5.278Mi ± 0%   3.321Mi ± 0%  -37.08% (p=0.000 n=10)
MarshalArrow_Large_100000Rows                      44.15Mi ± 0%   27.13Mi ± 0%  -38.56% (p=0.000 n=10)
MarshalArrow_Wide_100x100                          828.0Ki ± 0%   621.8Ki ± 0%  -24.90% (p=0.000 n=10)
MarshalArrow_NumericOnly_10000Rows                 1.557Mi ± 0%   1.282Mi ± 0%  -17.69% (p=0.000 n=10)
MarshalArrow_TimeSeries_10000Rows                  828.5Ki ± 0%   746.8Ki ± 0%   -9.85% (p=0.000 n=10)
UnmarshalArrowFrame_Small                          5.133Ki ± 0%   6.453Ki ± 0%  +25.72% (p=0.000 n=10)
UnmarshalArrowFrame_Medium_100Rows                 33.66Ki ± 0%   27.68Ki ± 0%  -17.76% (p=0.000 n=10)
UnmarshalArrowFrame_Medium_1000Rows                264.6Ki ± 0%   185.0Ki ± 0%  -30.09% (p=0.000 n=10)
UnmarshalArrowFrame_Large_10000Rows                5.811Mi ± 0%   3.683Mi ± 0%  -36.62% (p=0.000 n=10)
UnmarshalArrowFrame_Large_100000Rows               76.47Mi ± 0%   36.22Mi ± 0%  -52.63% (p=0.000 n=10)
UnmarshalArrowFrame_Wide_100x100                   477.0Ki ± 0%   411.0Ki ± 0%  -13.85% (p=0.000 n=10)
UnmarshalArrowFrame_NumericOnly_10000Rows         1741.8Ki ± 0%   849.1Ki ± 0%  -51.25% (p=0.000 n=10)
UnmarshalArrowFrame_TimeSeries_10000Rows          2015.6Ki ± 0%   886.9Ki ± 0%  -56.00% (p=0.000 n=10)
ArrowRoundTrip_Small                               17.71Ki ± 0%   17.41Ki ± 0%   -1.68% (p=0.000 n=10)
ArrowRoundTrip_Medium_1000Rows                     432.1Ki ± 0%   322.8Ki ± 0%  -25.30% (p=0.000 n=10)
ArrowRoundTrip_Large_10000Rows                    11.089Mi ± 0%   7.002Mi ± 0%  -36.86% (p=0.000 n=10)
FrameToArrowTable_Small                            3.438Ki ± 0%   3.438Ki ± 0%        ~ (p=1.000 n=10) ¹
FrameToArrowTable_Medium_1000Rows                  89.06Ki ± 0%   89.07Ki ± 0%   +0.00% (p=0.000 n=10)
FrameToArrowTable_Large_10000Rows                  2.562Mi ± 0%   2.562Mi ± 0%   +0.00% (p=0.014 n=10)
FromArrowRecord_Small                                984.0 ± 0%     770.0 ± 0%  -21.75% (p=0.000 n=10)
FromArrowRecord_Medium_1000Rows                   218.78Ki ± 0%   96.71Ki ± 0%  -55.79% (p=0.000 n=10)
FromArrowRecord_Large_10000Rows                    5.092Mi ± 0%   2.253Mi ± 0%  -55.76% (p=0.000 n=10)
FramesMarshalArrow_5Frames_1000Rows                837.6Ki ± 0%   689.2Ki ± 0%  -17.72% (p=0.000 n=10)
FramesMarshalArrow_10Frames_100Rows                422.7Ki ± 0%   292.0Ki ± 0%  -30.92% (p=0.000 n=10)
UnmarshalArrowFrames_5Frames_1000Rows             1323.2Ki ± 0%   925.1Ki ± 0%  -30.09% (p=0.000 n=10)
UnmarshalArrowFrames_10Frames_100Rows              336.6Ki ± 0%   276.9Ki ± 0%  -17.75% (p=0.000 n=10)
MarshalArrow_StringHeavy_1000Rows                  236.3Ki ± 0%   230.6Ki ± 0%   -2.41% (p=0.000 n=10)
UnmarshalArrowFrame_StringHeavy_1000Rows           117.7Ki ± 0%   164.5Ki ± 0%  +39.78% (p=0.000 n=10)
MarshalArrow_WithMetadataAndLabels_1000Rows        185.8Ki ± 0%   149.9Ki ± 0%  -19.31% (p=0.000 n=10)
FrameToJSON_IncludeAll                            17.777Ki ± 0%   8.120Ki ± 0%  -54.32% (p=0.000 n=10)
FrameToJSON_SchemaOnly                             6.923Ki ± 0%   4.821Ki ± 0%  -30.36% (p=0.000 n=10)
FrameToJSON_DataOnly                              10.853Ki ± 0%   3.297Ki ± 0%  -69.62% (p=0.000 n=10)
FrameJSONCache_Create                             17.777Ki ± 0%   8.120Ki ± 0%  -54.32% (p=0.000 n=10)
FrameJSONCache_Bytes/IncludeAll                   10.766Ki ± 0%   6.000Ki ± 0%  -44.27% (p=0.000 n=10)
FrameJSONCache_Bytes/SchemaOnly                    4.016Ki ± 0%   4.000Ki ± 0%   -0.39% (p=0.000 n=10)
FrameJSONCache_Bytes/DataOnly                      2.008Ki ± 0%   2.000Ki ± 0%   -0.39% (p=0.000 n=10)
FrameUnmarshalJSON                                 25.80Ki ± 0%   24.54Ki ± 0%   -4.90% (p=0.000 n=10)
FrameUnmarshalJSON_FromFrameToJSON                 25.80Ki ± 0%   24.54Ki ± 0%   -4.90% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_10                     2.000Ki ± 0%   1.203Ki ± 0%  -39.84% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_100                   14.439Ki ± 0%   6.329Ki ± 0%  -56.17% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_1000                  142.80Ki ± 0%   64.09Ki ± 0%  -55.12% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_10000                 1443.2Ki ± 0%   656.2Ki ± 0%  -54.53% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_10                   3.328Ki ± 0%   2.953Ki ± 0%  -11.27% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_100                  15.50Ki ± 0%   12.67Ki ± 0%  -18.25% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_1000                132.44Ki ± 0%   98.73Ki ± 0%  -25.45% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_10000                1.822Mi ± 0%   1.320Mi ± 0%  -27.59% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/TimeNoNanos            55.28Ki ± 0%   16.00Ki ± 0%  -71.05% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/TimeWithNanos          67.31Ki ± 0%   36.00Ki ± 0%  -46.51% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableTime           52.01Ki ± 0%   13.50Ki ± 0%  -74.04% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Float64Clean           27.84Ki ± 0%   12.00Ki ± 0%  -56.89% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Float64WithSpecials    35.18Ki ± 0%   13.25Ki ± 0%  -62.33% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Float32WithSpecials    31.28Ki ± 0%   13.25Ki ± 0%  -57.63% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Int64                 21.847Ki ± 0%   8.001Ki ± 0%  -63.38% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableInt64         22.769Ki ± 0%   9.501Ki ± 0%  -58.27% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Uint64                21.847Ki ± 0%   8.001Ki ± 0%  -63.38% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableUint64        22.769Ki ± 0%   9.501Ki ± 0%  -58.27% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/String                 47.66Ki ± 0%   24.00Ki ± 0%  -49.64% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableString         46.10Ki ± 0%   24.00Ki ± 0%  -47.93% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Bool                   20.03Ki ± 0%   12.00Ki ± 0%  -40.10% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/JSON                  418.93Ki ± 0%   28.00Ki ± 0%  -93.32% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Enum                  12.533Ki ± 0%   4.500Ki ± 0%  -64.10% (p=0.000 n=10)
FrameMarshalJSON_Parallel                          23.78Ki ± 0%   14.12Ki ± 0%  -40.61% (p=0.000 n=10)
FrameMarshalJSON_ParallelLarge                    142.80Ki ± 0%   64.09Ki ± 0%  -55.12% (p=0.000 n=10)
FrameUnmarshalJSON_Parallel                        25.80Ki ± 0%   24.54Ki ± 0%   -4.90% (p=0.000 n=10)
FrameMarshalJSON_WithLabels/NoLabels               95.13Ki ± 0%   40.05Ki ± 0%  -57.90% (p=0.000 n=10)
FrameMarshalJSON_WithLabels/SmallLabels            95.15Ki ± 0%   40.05Ki ± 0%  -57.90% (p=0.000 n=10)
FrameMarshalJSON_WithLabels/ManyLabels             95.40Ki ± 0%   40.05Ki ± 0%  -58.01% (p=0.000 n=10)
FrameMarshalJSON_WithMeta/NoMeta                   95.13Ki ± 0%   40.05Ki ± 0%  -57.90% (p=0.000 n=10)
FrameMarshalJSON_WithMeta/WithMeta                 95.69Ki ± 0%   40.60Ki ± 0%  -57.57% (p=0.000 n=10)
ArrowToJSON                                        54.70Ki ± 0%   54.24Ki ± 0%   -0.84% (p=0.000 n=10)
FrameRoundtrip                                     49.58Ki ± 0%   38.67Ki ± 0%  -22.01% (p=0.000 n=10)
FrameToJSON                                       17.777Ki ± 0%   8.120Ki ± 0%  -54.32% (p=0.000 n=10)
FrameMarshalJSONStd                                23.78Ki ± 0%   14.12Ki ± 0%  -40.61% (p=0.000 n=10)
FrameMarshalJSONIter                              13.243Ki ± 0%   8.049Ki ± 0%  -39.22% (p=0.000 n=10)
geomean                                            92.22Ki        55.01Ki       -40.34%
¹ all samples are equal

                                                │    old.txt     │                new.txt                │
                                                │   allocs/op    │  allocs/op   vs base                  │
MarshalArrow_Small                                    125.0 ± 0%    120.0 ± 0%   -4.00% (p=0.000 n=10)
MarshalArrow_Medium_100Rows                           207.0 ± 0%    200.0 ± 0%   -3.38% (p=0.000 n=10)
MarshalArrow_Medium_1000Rows                          226.0 ± 0%    219.0 ± 0%   -3.10% (p=0.000 n=10)
MarshalArrow_Large_10000Rows                          737.0 ± 0%    727.0 ± 0%   -1.36% (p=0.000 n=10)
MarshalArrow_Large_100000Rows                         828.0 ± 0%    819.0 ± 0%   -1.09% (p=0.000 n=10)
MarshalArrow_Wide_100x100                            2.799k ± 0%   2.792k ± 0%   -0.25% (p=0.000 n=10)
MarshalArrow_NumericOnly_10000Rows                    237.0 ± 0%    230.0 ± 0%   -2.95% (p=0.000 n=10)
MarshalArrow_TimeSeries_10000Rows                     156.0 ± 0%    150.0 ± 0%   -3.85% (p=0.000 n=10)
UnmarshalArrowFrame_Small                             99.00 ± 0%   114.00 ± 0%  +15.15% (p=0.000 n=10)
UnmarshalArrowFrame_Medium_100Rows                    554.0 ± 0%    273.0 ± 0%  -50.72% (p=0.000 n=10)
UnmarshalArrowFrame_Medium_1000Rows                  4.912k ± 0%   1.173k ± 0%  -76.12% (p=0.000 n=10)
UnmarshalArrowFrame_Large_10000Rows                  127.6k ± 0%   126.5k ± 0%   -0.86% (p=0.000 n=10)
UnmarshalArrowFrame_Large_100000Rows                 1.271M ± 0%   1.261M ± 0%   -0.81% (p=0.000 n=10)
UnmarshalArrowFrame_Wide_100x100                    12.469k ± 0%   2.750k ± 0%  -77.95% (p=0.000 n=10)
UnmarshalArrowFrame_NumericOnly_10000Rows           39554.0 ± 0%    169.0 ± 0%  -99.57% (p=0.000 n=10)
UnmarshalArrowFrame_TimeSeries_10000Rows            30133.0 ± 0%    127.0 ± 0%  -99.58% (p=0.000 n=10)
ArrowRoundTrip_Small                                  224.0 ± 0%    234.0 ± 0%   +4.46% (p=0.000 n=10)
ArrowRoundTrip_Medium_1000Rows                       5.138k ± 0%   1.392k ± 0%  -72.91% (p=0.000 n=10)
ArrowRoundTrip_Large_10000Rows                       128.4k ± 0%   127.3k ± 0%   -0.87% (p=0.000 n=10)
FrameToArrowTable_Small                               53.00 ± 0%    53.00 ± 0%        ~ (p=1.000 n=10) ¹
FrameToArrowTable_Medium_1000Rows                     134.0 ± 0%    134.0 ± 0%        ~ (p=1.000 n=10) ¹
FrameToArrowTable_Large_10000Rows                     551.0 ± 0%    551.0 ± 0%        ~ (p=1.000 n=10)
FromArrowRecord_Small                                 25.00 ± 0%    13.00 ± 0%  -48.00% (p=0.000 n=10)
FromArrowRecord_Medium_1000Rows                      4.804k ± 0%   1.020k ± 0%  -78.77% (p=0.000 n=10)
FromArrowRecord_Large_10000Rows                      127.3k ± 0%   126.1k ± 0%   -0.97% (p=0.000 n=10)
FramesMarshalArrow_5Frames_1000Rows                  1.131k ± 0%   1.097k ± 0%   -3.01% (p=0.000 n=10)
FramesMarshalArrow_10Frames_100Rows                  2.071k ± 0%   2.001k ± 0%   -3.38% (p=0.000 n=10)
UnmarshalArrowFrames_5Frames_1000Rows               24.561k ± 0%   5.866k ± 0%  -76.12% (p=0.000 n=10)
UnmarshalArrowFrames_10Frames_100Rows                5.541k ± 0%   2.731k ± 0%  -50.71% (p=0.000 n=10)
MarshalArrow_StringHeavy_1000Rows                     125.0 ± 0%    119.0 ± 0%   -4.80% (p=0.000 n=10)
UnmarshalArrowFrame_StringHeavy_1000Rows             1.076k ± 0%   1.086k ± 0%   +0.93% (p=0.000 n=10)
MarshalArrow_WithMetadataAndLabels_1000Rows           287.0 ± 0%    280.0 ± 0%   -2.44% (p=0.000 n=10)
FrameToJSON_IncludeAll                               291.00 ± 0%    31.00 ± 0%  -89.35% (p=0.000 n=10)
FrameToJSON_SchemaOnly                                57.00 ± 0%    26.00 ± 0%  -54.39% (p=0.000 n=10)
FrameToJSON_DataOnly                                235.000 ± 0%    6.000 ± 0%  -97.45% (p=0.000 n=10)
FrameJSONCache_Create                                292.00 ± 0%    32.00 ± 0%  -89.04% (p=0.000 n=10)
FrameJSONCache_Bytes/IncludeAll                       3.000 ± 0%    1.000 ± 0%  -66.67% (p=0.000 n=10)
FrameJSONCache_Bytes/SchemaOnly                       2.000 ± 0%    1.000 ± 0%  -50.00% (p=0.000 n=10)
FrameJSONCache_Bytes/DataOnly                         2.000 ± 0%    1.000 ± 0%  -50.00% (p=0.000 n=10)
FrameUnmarshalJSON                                    811.0 ± 0%    757.0 ± 0%   -6.66% (p=0.000 n=10)
FrameUnmarshalJSON_FromFrameToJSON                    811.0 ± 0%    757.0 ± 0%   -6.66% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_10                       46.000 ± 0%    3.000 ± 0%  -93.48% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_100                     406.000 ± 0%    3.000 ± 0%  -99.26% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_1000                   4006.000 ± 0%    3.000 ± 0%  -99.93% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_10000                 40009.000 ± 0%    4.000 ± 0%  -99.99% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_10                     100.00 ± 0%    77.00 ± 0%  -23.00% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_100                     373.0 ± 0%    170.0 ± 0%  -54.42% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_1000                   3.076k ± 0%   1.073k ± 0%  -65.12% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_10000                  30.09k ± 0%   10.08k ± 0%  -66.50% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/TimeNoNanos            2004.000 ± 0%    2.000 ± 0%  -99.90% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/TimeWithNanos          2005.000 ± 0%    3.000 ± 0%  -99.85% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableTime           1905.000 ± 0%    2.000 ± 0%  -99.90% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Float64Clean           1004.000 ± 0%    2.000 ± 0%  -99.80% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Float64WithSpecials    1031.000 ± 0%    2.000 ± 0%  -99.81% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Float32WithSpecials    1031.000 ± 0%    2.000 ± 0%  -99.81% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Int64                   749.000 ± 0%    2.000 ± 0%  -99.73% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableInt64           675.000 ± 0%    2.000 ± 0%  -99.70% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Uint64                  749.000 ± 0%    2.000 ± 0%  -99.73% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableUint64          675.000 ± 0%    2.000 ± 0%  -99.70% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/String                 1005.000 ± 0%    2.000 ± 0%  -99.80% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/NullableString          905.000 ± 0%    2.000 ± 0%  -99.78% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Bool                      5.000 ± 0%    2.000 ± 0%  -60.00% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/JSON                   6005.000 ± 0%    2.000 ± 0%  -99.97% (p=0.000 n=10)
FrameMarshalJSON_FieldTypes/Enum                      5.000 ± 0%    2.000 ± 0%  -60.00% (p=0.000 n=10)
FrameMarshalJSON_Parallel                            292.00 ± 0%    32.00 ± 0%  -89.04% (p=0.000 n=10)
FrameMarshalJSON_ParallelLarge                     4006.000 ± 0%    3.000 ± 0%  -99.93% (p=0.000 n=10)
FrameUnmarshalJSON_Parallel                           811.0 ± 0%    757.0 ± 0%   -6.66% (p=0.000 n=10)
FrameMarshalJSON_WithLabels/NoLabels               3005.000 ± 0%    3.000 ± 0%  -99.90% (p=0.000 n=10)
FrameMarshalJSON_WithLabels/SmallLabels            3007.000 ± 0%    3.000 ± 0%  -99.90% (p=0.000 n=10)
FrameMarshalJSON_WithLabels/ManyLabels             3009.000 ± 0%    3.000 ± 0%  -99.90% (p=0.000 n=10)
FrameMarshalJSON_WithMeta/NoMeta                   3005.000 ± 0%    3.000 ± 0%  -99.90% (p=0.000 n=10)
FrameMarshalJSON_WithMeta/WithMeta                  3017.00 ± 0%    15.00 ± 0%  -99.50% (p=0.000 n=10)
ArrowToJSON                                           685.0 ± 0%    667.0 ± 0%   -2.63% (p=0.000 n=10)
FrameRoundtrip                                       1103.0 ± 0%    789.0 ± 0%  -28.47% (p=0.000 n=10)
FrameToJSON                                          292.00 ± 0%    32.00 ± 0%  -89.04% (p=0.000 n=10)
FrameMarshalJSONStd                                  292.00 ± 0%    32.00 ± 0%  -89.04% (p=0.000 n=10)
FrameMarshalJSONIter                                 217.00 ± 0%    29.00 ± 0%  -86.64% (p=0.000 n=10)
geomean                                               844.6         68.85       -91.85%
¹ all samples are equal

                                    │   old.txt    │                new.txt                │
                                    │     B/s      │     B/s       vs base                 │
FrameToJSON_IncludeAll                261.8Mi ± 0%   415.8Mi ± 1%   +58.82% (p=0.000 n=10)
FrameToJSON_SchemaOnly                369.1Mi ± 3%   422.5Mi ± 2%   +14.47% (p=0.000 n=10)
FrameToJSON_DataOnly                  177.3Mi ± 1%   420.5Mi ± 1%  +137.23% (p=0.000 n=10)
FrameJSONCache_Create                 258.0Mi ± 1%   415.9Mi ± 1%   +61.19% (p=0.000 n=10)
FrameJSONCache_Bytes/IncludeAll       5.425Gi ± 3%   9.808Gi ± 2%   +80.80% (p=0.000 n=10)
FrameJSONCache_Bytes/SchemaOnly       8.127Gi ± 3%   8.459Gi ± 0%    +4.08% (p=0.000 n=10)
FrameJSONCache_Bytes/DataOnly         8.614Gi ± 1%   8.681Gi ± 1%    +0.79% (p=0.023 n=10)
FrameUnmarshalJSON                    65.32Mi ± 1%   70.23Mi ± 0%    +7.52% (p=0.000 n=10)
FrameUnmarshalJSON_FromFrameToJSON    65.59Mi ± 5%   70.22Mi ± 1%    +7.06% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_10        116.4Mi ± 4%   148.3Mi ± 0%   +27.43% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_100       109.1Mi ± 3%   151.7Mi ± 0%   +38.96% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_1000      113.6Mi ± 1%   160.1Mi ± 0%   +40.92% (p=0.000 n=10)
FrameMarshalJSON_Sizes/Rows_10000     112.7Mi ± 2%   175.7Mi ± 3%   +55.88% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_10      93.17Mi ± 4%   92.49Mi ± 1%         ~ (p=0.838 n=10)
FrameUnmarshalJSON_Sizes/Rows_100     115.8Mi ± 2%   120.0Mi ± 0%    +3.68% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_1000    120.7Mi ± 1%   129.0Mi ± 2%    +6.87% (p=0.000 n=10)
FrameUnmarshalJSON_Sizes/Rows_10000   138.1Mi ± 1%   126.6Mi ± 5%    -8.32% (p=0.000 n=10)
ArrowToJSON                           138.7Mi ± 1%   142.6Mi ± 1%    +2.84% (p=0.000 n=10)
FrameToJSON                           264.8Mi ± 1%   413.7Mi ± 0%   +56.22% (p=0.000 n=10)
FrameMarshalJSONStd                   129.9Mi ± 1%   160.8Mi ± 1%   +23.77% (p=0.000 n=10)
FrameMarshalJSONIter                  301.6Mi ± 1%   411.1Mi ± 0%   +36.30% (p=0.000 n=10)
geomean                               254.3Mi        323.9Mi        +27.39%

grafana tests

ran using k6 with two parallel queries (loki and prom). max 5000 results each.

before:


         /\      Grafana   /‾‾/  
    /\  /  \     |\  __   /  /   
   /  \/    \    | |/ /  /   ‾‾\ 
  /          \   |   (  |  (‾)  |
 / __________ \  |_|\_\  \_____/ 

     execution: local
        script: queryk6.js
        output: -

     scenarios: (100.00%) 1 scenario, 100 max VUs, 1m0s max duration (incl. graceful stop):
              * default: 100 looping VUs for 30s (gracefulStop: 30s)


  █ TOTAL RESULTS 

    checks_total.......: 1756    54.17458/s
    checks_succeeded...: 100.00% 1756 out of 1756
    checks_failed......: 0.00%   0 out of 1756

    ✓ prometheus query OK
    ✓ loki query OK

    HTTP
    http_req_duration..............: avg=2.42s min=159.99ms med=2.29s max=6.88s p(90)=4.32s p(95)=4.67s
      { expected_response:true }...: avg=2.42s min=159.99ms med=2.29s max=6.88s p(90)=4.32s p(95)=4.67s
    http_req_failed................: 0.00%  0 out of 1756
    http_reqs......................: 1756   54.17458/s

    EXECUTION
    iteration_duration.............: avg=3.6s  min=839.4ms  med=3.59s max=6.88s p(90)=4.67s p(95)=5.12s
    iterations.....................: 878    27.08729/s
    vus............................: 46     min=46        max=100
    vus_max........................: 100    min=100       max=100

    NETWORK
    data_received..................: 6.0 GB 186 MB/s
    data_sent......................: 1.4 MB 43 kB/s




running (0m32.4s), 000/100 VUs, 878 complete and 0 interrupted iterations
default ✓ [ 100% ] 100 VUs  30s

after:


         /\      Grafana   /‾‾/  
    /\  /  \     |\  __   /  /   
   /  \/    \    | |/ /  /   ‾‾\ 
  /          \   |   (  |  (‾)  |
 / __________ \  |_|\_\  \_____/ 

     execution: local
        script: queryk6.js
        output: -

     scenarios: (100.00%) 1 scenario, 100 max VUs, 1m0s max duration (incl. graceful stop):
              * default: 100 looping VUs for 30s (gracefulStop: 30s)

  █ TOTAL RESULTS 

    checks_total.......: 2748    86.860566/s
    checks_succeeded...: 100.00% 2748 out of 2748
    checks_failed......: 0.00%   0 out of 2748

    ✓ prometheus query OK
    ✓ loki query OK

    HTTP
    http_req_duration..............: avg=1.61s min=28.18ms  med=1.45s max=6.79s p(90)=2.73s p(95)=3.05s
      { expected_response:true }...: avg=1.61s min=28.18ms  med=1.45s max=6.79s p(90)=2.73s p(95)=3.05s
    http_req_failed................: 0.00%  0 out of 2748
    http_reqs......................: 2748   86.860566/s

    EXECUTION
    iteration_duration.............: avg=2.26s min=391.13ms med=2.19s max=6.79s p(90)=3.04s p(95)=3.51s
    iterations.....................: 1374   43.430283/s
    vus............................: 68     min=68        max=100
    vus_max........................: 100    min=100       max=100

    NETWORK
    data_received..................: 9.4 GB 297 MB/s
    data_sent......................: 2.2 MB 69 kB/s




running (0m31.6s), 000/100 VUs, 1374 complete and 0 interrupted iterations
default ✓ [ 100% ] 100 VUs  30s

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@toddtreece toddtreece force-pushed the toddtreece/generics branch from 4fe7618 to 27e5315 Compare October 2, 2025 23:36

// This function will write code to the console that should be copy/pasted into frame_json.gen.go
// when changes are required. Typically this function will always be skipped.
func TestGenerateGenericArrowCode(t *testing.T) {
Copy link
Contributor

@ryantxu ryantxu Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 really great to replace the bespoke code generation!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryantxu if @grafana/grafana-datasources-core-services decides this is worth testing, do you think it makes sense to copy these changes to another folder/package and switch between them with an env var (similar to prom framing changes)? i can't think of another option at the moment to test these types of changes without introducing extra overhead 🤔

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@toddtreece what was the prom framing changes again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asimpson a feature toggle was used to flip between an unmodified copy of the prometheus datasource framing code and a replacement. once the new code was determined to be ok, the old framing code was deleted

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itsmylife might have thoughts here since he helped pushed that project to completion

@ryantxu
Copy link
Contributor

ryantxu commented Oct 5, 2025

is this faster because it can avoid the casting? .(*T)?

@toddtreece
Copy link
Member Author

@ryantxu there are a few improvements mixed in so it's probably a combination of things, but i think it's primarily related to avoiding extra allocations related to the use of interface{}. this has a good summary https://goperf.dev/01-common-patterns/interface-boxing/

sd2k and others added 3 commits October 7, 2025 06:51
There are already fast paths for certain types, but floats and various
others were missing, so we were falling back to a very allocation-heavy
interface{} method where every value was boxed then unboxed later.
Now that we have generic vectors we can read directly into them and
avoid a ton of allocations, which speeds things up dramatically,
especially for larger vectors.

Benchmarks for JSON unmarshalling:

```
goos: linux
goarch: amd64
pkg: github.com/grafana/grafana-plugin-sdk-go/data
cpu: AMD Ryzen 9 7950X 16-Core Processor
                                       │ benchmark-baseline.txt │         benchmark-final.txt         │
                                       │         sec/op         │    sec/op     vs base               │
FrameUnmarshalJSON-32                              77.72µ ± ∞ ¹   76.13µ ± ∞ ¹        ~ (p=0.421 n=5)
FrameUnmarshalJSON_FromFrameToJSON-32              74.86µ ± ∞ ¹   76.81µ ± ∞ ¹   +2.60% (p=0.032 n=5)
FrameUnmarshalJSON_Sizes/Rows_10-32                5.345µ ± ∞ ¹   5.065µ ± ∞ ¹   -5.24% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_100-32               25.44µ ± ∞ ¹   22.27µ ± ∞ ¹  -12.44% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_1000-32              231.4µ ± ∞ ¹   199.0µ ± ∞ ¹  -13.99% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_10000-32             2.523m ± ∞ ¹   2.090m ± ∞ ¹  -17.19% (p=0.008 n=5)
FrameUnmarshalJSON_Parallel-32                     25.92µ ± ∞ ¹   25.42µ ± ∞ ¹        ~ (p=1.000 n=5)
geomean                                            73.85µ         68.36µ         -7.43%
¹ need >= 6 samples for confidence interval at level 0.95

                                       │ benchmark-baseline.txt │         benchmark-final.txt          │
                                       │          B/s           │      B/s       vs base               │
FrameUnmarshalJSON-32                             69.90Mi ± ∞ ¹   71.37Mi ± ∞ ¹        ~ (p=0.421 n=5)
FrameUnmarshalJSON_FromFrameToJSON-32             72.45Mi ± ∞ ¹   70.61Mi ± ∞ ¹   -2.54% (p=0.040 n=5)
FrameUnmarshalJSON_Sizes/Rows_10-32               93.67Mi ± ∞ ¹   98.85Mi ± ∞ ¹   +5.53% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_100-32              118.8Mi ± ∞ ¹   135.6Mi ± ∞ ¹  +14.21% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_1000-32             129.4Mi ± ∞ ¹   150.5Mi ± ∞ ¹  +16.26% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_10000-32            125.4Mi ± ∞ ¹   151.4Mi ± ∞ ¹  +20.75% (p=0.008 n=5)
geomean                                           98.52Mi         107.5Mi         +9.07%
¹ need >= 6 samples for confidence interval at level 0.95

                                       │ benchmark-baseline.txt │         benchmark-final.txt          │
                                       │          B/op          │     B/op       vs base               │
FrameUnmarshalJSON-32                             24.84Ki ± ∞ ¹   24.54Ki ± ∞ ¹   -1.23% (p=0.008 n=5)
FrameUnmarshalJSON_FromFrameToJSON-32             24.84Ki ± ∞ ¹   24.54Ki ± ∞ ¹   -1.23% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_10-32               3.328Ki ± ∞ ¹   2.953Ki ± ∞ ¹  -11.27% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_100-32              15.50Ki ± ∞ ¹   12.67Ki ± ∞ ¹  -18.25% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_1000-32            132.44Ki ± ∞ ¹   98.73Ki ± ∞ ¹  -25.45% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_10000-32            1.822Mi ± ∞ ¹   1.320Mi ± ∞ ¹  -27.59% (p=0.008 n=5)
FrameUnmarshalJSON_Parallel-32                    24.84Ki ± ∞ ¹   24.54Ki ± ∞ ¹   -1.22% (p=0.008 n=5)
geomean                                           41.02Ki         35.69Ki        -13.00%
¹ need >= 6 samples for confidence interval at level 0.95

                                       │ benchmark-baseline.txt │         benchmark-final.txt         │
                                       │       allocs/op        │  allocs/op    vs base               │
FrameUnmarshalJSON-32                               770.0 ± ∞ ¹    757.0 ± ∞ ¹   -1.69% (p=0.008 n=5)
FrameUnmarshalJSON_FromFrameToJSON-32               770.0 ± ∞ ¹    757.0 ± ∞ ¹   -1.69% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_10-32                100.00 ± ∞ ¹    77.00 ± ∞ ¹  -23.00% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_100-32                373.0 ± ∞ ¹    170.0 ± ∞ ¹  -54.42% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_1000-32              3.076k ± ∞ ¹   1.073k ± ∞ ¹  -65.12% (p=0.008 n=5)
FrameUnmarshalJSON_Sizes/Rows_10000-32             30.09k ± ∞ ¹   10.08k ± ∞ ¹  -66.50% (p=0.008 n=5)
FrameUnmarshalJSON_Parallel-32                      770.0 ± ∞ ¹    757.0 ± ∞ ¹   -1.69% (p=0.008 n=5)
geomean                                            1.067k          671.3        -37.10%
¹ need >= 6 samples for confidence interval at level 0.95
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🧑‍💻 In development
Development

Successfully merging this pull request may close these issues.

4 participants