Skip to content

Reduce Python FFT and C# channel-packing overhead - #871

Open
Andrey1994 wants to merge 3 commits into
masterfrom
perf/binding-copies-601
Open

Andrey1994 wants to merge 3 commits into
masterfrom
perf/binding-copies-601

Conversation

@Andrey1994

@Andrey1994 Andrey1994 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Python FFT/IFFT wrappers convert complex values in scalar Python loops, and C# band-power/ICA wrappers repeatedly allocate copied rows while packing selected channels. Use NumPy array assignments and contiguous real/imaginary buffers, and pack C# rows directly into one buffer while validating channel bounds.

Local Windows probes measured 11.2x faster Python FFT calls at 2,048 samples and 3.5–4.5x faster C# packing at 64 x 2,000 samples. These are operation-specific measurements, not application-wide speedups. C# packing allocations dropped from 4.13 MB to 1.02 MB per call.

Validation: freshly built MSVC Release /MT DataHandler; 19 signal-processing and 18 band-power Python tests passed; C# Release build and signal-processing regression passed. Added coverage for strided complex input, repeated/reordered channels, input preservation, and invalid channel indices. Tests run in the existing regression CI jobs.

Also repair the shared CI failures: stage native dylibs beside the macOS C# regression executable, report C++ test exceptions through a nonzero exit status, and guard allocation failure/overflow in the macOS Bluetooth pipe resize.

Part of #601. Independent of the file-reader, DSP-context, and acquisition changes.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T00:44:38.365611Z 5d66ce1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

var data = new double[4, 1024];
for (int row = 0; row < 4; row++)
for (int col = 0; col < 1024; col++)
data[row, col] = Math.Sin(2 * Math.PI * (5 + row * 7) * col / 256.0);
throw new Exception("Selected/repeated channel powers changed");
for (int row = 0; row < 4; row++)
for (int col = 0; col < 1024; col++)
if (data[row, col] != original[row, col])
var actual = DataFilter.get_custom_band_powers(data, bands, channels, 256, false);
var expected = DataFilter.get_custom_band_powers(selected, bands, new[] {0, 1, 2}, 256, false);
for (int band = 0; band < bands.Length; band++)
if (actual.Item1[band] != expected.Item1[band] || actual.Item2[band] != expected.Item2[band])
var actual = DataFilter.get_custom_band_powers(data, bands, channels, 256, false);
var expected = DataFilter.get_custom_band_powers(selected, bands, new[] {0, 1, 2}, 256, false);
for (int band = 0; band < bands.Length; band++)
if (actual.Item1[band] != expected.Item1[band] || actual.Item2[band] != expected.Item2[band])

This branch has not been deployed

No deployments
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