Speed up MATLAB mex build by caching shared C object files - #60
Merged
Conversation
mexAll.m recompiled the ~24 shared C source files (helper_functions.c, stats.c, fft.c, ...) from scratch for every one of the 24 features, since each mex() call was handed the full includeFiles list. Compile those shared files to object files once with mex -c, then link each feature's small wrapper against the cached objects instead. ~3.4x faster locally (62s -> 18s on macOS/clang), output verified bit-identical against the previous build.
benfulcher
added a commit
to benfulcher/hctsa
that referenced
this pull request
Aug 21, 2026
…; bump catch22 startup.m now fetches the catch22 git submodule automatically (streaming git's progress) if it's missing, rather than only warning about it -- this fires whether startup is called directly or via install.m, so it's no longer possible to skip install.m and hit a silent addpath warning. install.m's now-redundant interactive prompt for the same check is removed. TISEAN and ripser now print inline in the same comma-separated toolbox list as everything else in startup.m, instead of separate "System path to..." lines with the full path. Bumped the catch22 submodule to pick up an upstream fix (merged as DynamicsAndNeuralSystems/catch22#60) that caches shared C object files during the MATLAB mex build instead of recompiling them from scratch for every one of the 24 features (~3x faster, verified bit-identical output).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wrap_Matlab/mexAll.mcompiled each of the 24 feature mex files as a separatemexcall, and every call was handed the full set of ~24 shared C source files (helper_functions.c,stats.c,fft.c, ...) alongsideM_wrapper.cand the one feature-specific wrapper -- so every shared file was recompiled from scratch 24 times over.mex -c -outdir, then links each small per-feature wrapper against the cached objects.Test plan
mexAllend-to-end on macOS, all 24 features compile successfullyCO_FirstMin_ac,DN_Mean,SP_Summaries_welch_rect_centroid) on a fixed-seed input against a build from the unmodifiedmexAll.m-- bit-identical-c -outdirobject-compile steps ahead of the existing per-feature mex calls, no new platform-specific logic