Skip to content

Add mux and add functions for combining SignalChannels#26

Merged
zsoerenm merged 1 commit intomainfrom
ss/mux-and-add
Feb 10, 2026
Merged

Add mux and add functions for combining SignalChannels#26
zsoerenm merged 1 commit intomainfrom
ss/mux-and-add

Conversation

@zsoerenm
Copy link
Member

@zsoerenm zsoerenm commented Feb 10, 2026

Summary

  • mux(ch1, ch2; sync=true): Sequential channel multiplexer that forwards ch1 until closed, then ch2. Optional sync kwarg controls whether ch2 is drained during the ch1 phase (for code phase synchronization).
  • add(ch1, ch2, ...): Element-wise addition of 2+ SignalChannels (varargs). Errors on mismatched num_samples or fewer than 2 channels.
  • Both functions are allocation-free in steady state using pre-allocated rotating buffer slots (channel_size + 2 slots).

Test plan

  • 7 tests for mux (sync/no-sync, empty channels, order preservation, type generality, error cases)
  • 6 tests for add (2-channel, 3-channel varargs, multi-antenna N=2, Complex{Int16}, error cases)
  • All existing SignalChannels tests still pass

🤖 Generated with Claude Code

- mux: sequential channel multiplexer with optional sync (drains ch2
  while forwarding ch1). Ported from WheresWaldo.jl's channel_mux.
- add: element-wise addition of 2+ SignalChannels (varargs).
- Both are allocation-free in steady state using pre-allocated
  rotating buffer slots.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.21%. Comparing base (7721709) to head (dcc082f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
+ Coverage   71.13%   74.21%   +3.08%     
==========================================
  Files           7        8       +1     
  Lines         485      543      +58     
==========================================
+ Hits          345      403      +58     
  Misses        140      140              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zsoerenm zsoerenm merged commit 83a47fb into main Feb 10, 2026
7 checks passed
@zsoerenm zsoerenm deleted the ss/mux-and-add branch February 10, 2026 10:53
@github-actions
Copy link

Benchmark Results (Julia v1)

Time benchmarks
main dcc082f... main / dcc082f...
channel/buffer=1 3.91 ± 0.05 ms 3.95 ± 0.044 ms 0.989 ± 0.017
channel/buffer=1024 0.179 ± 0.0078 ms 0.191 ± 0.022 ms 0.938 ± 0.12
channel/buffer=16 0.418 ± 0.013 ms 0.423 ± 0.0089 ms 0.989 ± 0.038
channel/buffer=256 0.204 ± 0.01 ms 0.202 ± 0.0069 ms 1.01 ± 0.062
channel/buffer=4 1.11 ± 0.02 ms 1.13 ± 0.016 ms 0.979 ± 0.022
channel/buffer=64 0.243 ± 0.0091 ms 0.249 ± 0.0086 ms 0.977 ± 0.05
rechunk/10000_to_2048/buffer=1 6.44 ± 0.22 ms 6.99 ± 0.37 ms 0.922 ± 0.058
rechunk/10000_to_2048/buffer=16 4.43 ± 0.31 ms 4.7 ± 0.26 ms 0.941 ± 0.084
rechunk/10000_to_2048/buffer=4 4.52 ± 0.17 ms 4.98 ± 0.23 ms 0.906 ± 0.054
rechunk/10000_to_2048/buffer=64 4.44 ± 0.28 ms 4.86 ± 0.34 ms 0.913 ± 0.085
rechunk/2048_to_10000/buffer=1 1.08 ± 0.1 ms 1.07 ± 0.072 ms 1.01 ± 0.12
rechunk/2048_to_10000/buffer=16 1.13 ± 0.14 ms 1.19 ± 0.11 ms 0.947 ± 0.14
rechunk/2048_to_10000/buffer=4 1.11 ± 0.097 ms 1.09 ± 0.074 ms 1.02 ± 0.11
rechunk/2048_to_10000/buffer=64 1.36 ± 0.19 ms 1.42 ± 0.34 ms 0.963 ± 0.27
rechunk_state/batch/batch_2048_to_512_1ch 1.61 ± 0.12 ms 1.51 ± 0.17 ms 1.07 ± 0.14
rechunk_state/batch/batch_2048_to_512_4ch 6.37 ± 0.47 ms 6.38 ± 0.44 ms 0.999 ± 0.1
rechunk_state/batch/batch_512_to_2048_1ch 0.352 ± 0.073 ms 0.283 ± 0.062 ms 1.24 ± 0.38
rechunk_state/batch/batch_passthrough_2048_1ch 3.84 ± 0.37 μs 3.68 ± 0.3 μs 1.04 ± 0.13
rechunk_state/batch/iterative_2048_to_512_1ch 1.67 ± 0.13 ms 1.48 ± 0.12 ms 1.13 ± 0.13
rechunk_state/batch/iterative_2048_to_512_4ch 6.34 ± 0.33 ms 6.05 ± 0.32 ms 1.05 ± 0.077
rechunk_state/batch/iterative_512_to_2048_1ch 0.326 ± 0.059 ms 0.272 ± 0.068 ms 1.2 ± 0.37
rechunk_state/batch/iterative_passthrough_2048_1ch 3.83 ± 0.26 μs 3.68 ± 0.2 μs 1.04 ± 0.092
rechunk_state/channels/2048_to_1024_1ch 1.53 ± 0.16 ms 1.84 ± 0.16 ms 0.832 ± 0.11
rechunk_state/channels/2048_to_1024_2ch 3.14 ± 0.27 ms 3.48 ± 0.24 ms 0.905 ± 0.1
rechunk_state/channels/2048_to_1024_4ch 6.07 ± 0.33 ms 6.77 ± 0.29 ms 0.897 ± 0.062
rechunk_state/channels/2048_to_1024_8ch 12.1 ± 0.45 ms 13.6 ± 0.95 ms 0.891 ± 0.071
rechunk_state/downsample/10000_to_1024_1ch 8.01 ± 1.2 ms 7.16 ± 0.44 ms 1.12 ± 0.19
rechunk_state/downsample/2048_to_512_1ch 1.84 ± 0.3 ms 1.54 ± 0.12 ms 1.2 ± 0.22
rechunk_state/downsample/2048_to_512_4ch 6.59 ± 0.58 ms 6.08 ± 0.29 ms 1.08 ± 0.11
rechunk_state/passthrough/2048_to_2048_1ch 3.76 ± 0.26 μs 4.46 ± 0.4 μs 0.843 ± 0.095
rechunk_state/passthrough/2048_to_2048_4ch 4.38 ± 0.79 μs 4.82 ± 0.47 μs 0.91 ± 0.19
rechunk_state/types/ComplexF64_2048_to_1024 2.62 ± 0.25 ms 2.6 ± 0.3 ms 1.01 ± 0.15
rechunk_state/types/Float32_2048_to_1024 0.779 ± 0.096 ms 0.709 ± 0.071 ms 1.1 ± 0.17
rechunk_state/types/Float64_2048_to_1024 1.5 ± 0.17 ms 1.67 ± 0.11 ms 0.903 ± 0.12
rechunk_state/types/Int16_2048_to_1024 0.421 ± 0.055 ms 0.336 ± 0.042 ms 1.25 ± 0.23
rechunk_state/upsample/1024_to_10000_1ch 0.672 ± 0.051 ms 0.853 ± 0.08 ms 0.788 ± 0.095
rechunk_state/upsample/512_to_2048_1ch 0.262 ± 0.044 ms 0.432 ± 0.05 ms 0.606 ± 0.12
rechunk_state/upsample/512_to_2048_4ch 1.57 ± 0.11 ms 1.79 ± 0.08 ms 0.874 ± 0.072
rechunk_state/zero_copy/near_passthrough_2048_1ch 1.66 ± 0.19 ms 1.44 ± 0.14 ms 1.15 ± 0.18
rechunk_state/zero_copy/near_passthrough_2048_4ch 6.91 ± 1.6 ms 6.77 ± 0.18 ms 1.02 ± 0.23
rechunk_state/zero_copy/near_passthrough_8192_4ch 0.0473 ± 0.077 s 0.0696 ± 0.068 s 0.68 ± 1.3
rechunk_state/zero_copy/passthrough_2048_1ch 3.87 ± 0.37 μs 3.79 ± 0.33 μs 1.02 ± 0.13
rechunk_state/zero_copy/passthrough_2048_4ch 4.79 ± 0.64 μs 4.87 ± 0.49 μs 0.984 ± 0.16
rechunk_state/zero_copy/passthrough_8192_4ch 5.39 ± 1 μs 5.33 ± 0.79 μs 1.01 ± 0.24
tee/buffer=1 0.626 ± 0.017 ms 0.625 ± 0.018 ms 1 ± 0.04
tee/buffer=16 0.0956 ± 0.0092 ms 0.0962 ± 0.0017 ms 0.994 ± 0.098
tee/buffer=4 0.203 ± 0.014 ms 0.21 ± 0.015 ms 0.968 ± 0.098
tee/buffer=64 0.0684 ± 0.0011 ms 0.0688 ± 0.0014 ms 0.994 ± 0.026
time_to_load 1.52 ± 0.016 s 1.64 ± 0.032 s 0.927 ± 0.021
Memory benchmarks
main dcc082f... main / dcc082f...
channel/buffer=1 16 allocs: 1.09 kB 16 allocs: 1.09 kB 1
channel/buffer=1024 16 allocs: 1.09 kB 16 allocs: 1.09 kB 1
channel/buffer=16 16 allocs: 1.09 kB 16 allocs: 1.09 kB 1
channel/buffer=256 16 allocs: 1.09 kB 16 allocs: 1.09 kB 1
channel/buffer=4 16 allocs: 1.09 kB 16 allocs: 1.09 kB 1
channel/buffer=64 16 allocs: 1.09 kB 16 allocs: 1.09 kB 1
rechunk/10000_to_2048/buffer=1 12 allocs: 0.75 kB 12 allocs: 0.75 kB 1
rechunk/10000_to_2048/buffer=16 12 allocs: 0.75 kB 12 allocs: 0.75 kB 1
rechunk/10000_to_2048/buffer=4 12 allocs: 0.75 kB 12 allocs: 0.75 kB 1
rechunk/10000_to_2048/buffer=64 12 allocs: 0.75 kB 12 allocs: 0.75 kB 1
rechunk/2048_to_10000/buffer=1 13 allocs: 0.781 kB 13 allocs: 0.781 kB 1
rechunk/2048_to_10000/buffer=16 13 allocs: 0.781 kB 13 allocs: 0.781 kB 1
rechunk/2048_to_10000/buffer=4 13 allocs: 0.781 kB 12 allocs: 0.75 kB 1.04
rechunk/2048_to_10000/buffer=64 12 allocs: 0.75 kB 13 allocs: 0.781 kB 0.96
rechunk_state/batch/batch_2048_to_512_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/batch/batch_2048_to_512_4ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/batch/batch_512_to_2048_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/batch/batch_passthrough_2048_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/batch/iterative_2048_to_512_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/batch/iterative_2048_to_512_4ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/batch/iterative_512_to_2048_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/batch/iterative_passthrough_2048_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/channels/2048_to_1024_1ch 1 allocs: 16 B 1 allocs: 16 B 1
rechunk_state/channels/2048_to_1024_2ch 1 allocs: 16 B 1 allocs: 16 B 1
rechunk_state/channels/2048_to_1024_4ch 1 allocs: 16 B 1 allocs: 16 B 1
rechunk_state/channels/2048_to_1024_8ch 1 allocs: 16 B 1 allocs: 16 B 1
rechunk_state/downsample/10000_to_1024_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/downsample/2048_to_512_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/downsample/2048_to_512_4ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/passthrough/2048_to_2048_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/passthrough/2048_to_2048_4ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/types/ComplexF64_2048_to_1024 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/types/Float32_2048_to_1024 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/types/Float64_2048_to_1024 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/types/Int16_2048_to_1024 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/upsample/1024_to_10000_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/upsample/512_to_2048_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/upsample/512_to_2048_4ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/zero_copy/near_passthrough_2048_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/zero_copy/near_passthrough_2048_4ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/zero_copy/near_passthrough_8192_4ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/zero_copy/passthrough_2048_1ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/zero_copy/passthrough_2048_4ch 0 allocs: 0 B 0 allocs: 0 B
rechunk_state/zero_copy/passthrough_8192_4ch 0 allocs: 0 B 0 allocs: 0 B
tee/buffer=1 26 allocs: 1.48 kB 26 allocs: 1.48 kB 1
tee/buffer=16 26 allocs: 1.48 kB 26 allocs: 1.48 kB 1
tee/buffer=4 26 allocs: 1.48 kB 26 allocs: 1.48 kB 1
tee/buffer=64 26 allocs: 1.48 kB 26 allocs: 1.48 kB 1
time_to_load 0.145 k allocs: 11 kB 0.145 k allocs: 11 kB 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant