mcpbeat Sign in

Matlab Use Thread Pool Agent Skill

> Speed up local parfor, parfeval, or spmd by switching to a thread-based parallel pool. Trigger when a user describes slow or disappointing local on a laptop/workstation is slower than expected or "only slightly faster than for"; parfor scales poorly with the number of workers; ticBytes/tocBytes, the Parallel Pool dashboard, mpiprofile, or system tools show large per-worker data transfer; large broadcast variables or sliced inputs make iterations slow; opening a process pool dominates a short workload; user mentions serialisation or data transfer overhead. Also trigger on any question about whether code or a function works on a thread pool. For non-pool MATLAB performance work (vectorisation, preallocation, profiling), defer to matlab-optimize-performance.

1k tokens
context cost
the whole folder, loaded on every use
2
files
instructions only
0
copies elsewhere
how many repositories repackaged it
865
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-use-thread-pool

The instruction itself

6 sections, as written by the author

Use a Thread-Based Parallel Pool

Recommend starting a thread pool using parpool("Threads") instead of

using the default process-based pool to speed up local parfor /

parfeval / spmd code.

When to Use

  • User asks to improve performance of parfor, parfeval, or spmd on

a local machine.

  • Code passes large arrays into iterations or broadcasts them across

workers; user mentions slow start-up, serialization, or data transfer.

  • User asks "Processes or Threads?" or wants Threads as the default.

When NOT to Use

  • User is running on a cluster -- thread pools are local-only.
  • Code uses parsim or other Simulink parallel features -- those

require a process-based pool.

  • Code uses distributed or codistributed arrays.
  • User wants backgroundPool -- that's for running work

asynchronously (e.g. keeping an app responsive while a computation

runs), not for parallel speed-up. All MATLAB users have 1 worker in

the background pool; users with a Parallel Computing Toolbox license

have multiple workers.

For general MATLAB performance tuning (vectorisation, preallocation,

profiling), see matlab-optimize-performance (if available).

Workflow

  • Try it on a thread pool. Don't scan the code first -- just run

it. Only create a thread pool if the current pool isn't already a

thread pool. Avoid unconditionally deleting whichever pool the user

has open. The conditional snippet below is a development

convenience -- not something to bake into shipped code:

   % Development-time helper: ensure a thread pool is active
   pool = gcp("nocreate");
   if isempty(pool) || ~isa(pool, "parallel.ThreadPool")
       delete(pool);
       parpool("Threads");
   end

The existing parfor / parfeval / spmd block does not need to

change. Thread pools are a drop-in replacement, not a refactor.

  • Read the diagnostic if it errors. Unsupported features fail

loudly -- MATLAB tells you what isn't allowed and to use a

process-based pool instead. Recommend parpool("Processes"). No

silent wrong answers, no guessing.

  • Offer the persistent option if the user wants to use a thread

pool "always" or "every time": suggest setting Threads as the

default profile via parallel.defaultProfile("Threads") (R2022b+).

Persists across sessions; no startup script needed.

What threads actually save

Be precise. Broadcast variables are zero-copy on threads (the win).

Sliced inputs/outputs (X(:,:,i)) still allocate and copy --

threads only skip the serialize/IPC cost, not the slice itself.

Don't say "zero-copy" or "shared memory eliminates the cost

entirely" without qualifying it.

Convention

Always run it, never guess. This is the single most important

rule in this skill.

LLM training data is incomplete and stale. Thread-based workers

gained support for many functions across releases, and new support

is added regularly. Do not assert a function is unsupported on

threads from memory, by analogy to similar functions, or because

it's not on the skill's short blocker list. Reasoning about thread

support without running is the biggest failure mode for this skill

-- it has pushed users to a process pool unnecessarily.

The default action is to run the code on a thread pool and read

the diagnostic if it errors. Don't pre-scan the code looking for

blockers. Most functions you'd reach for (load, FFT, imgaussfilt,

numeric and basic I/O primitives) work on threads.

Only if you genuinely cannot run the code (planning context, code

review, user can't execute right now) should you fall back to

documentation. Use an appropriate documentation skill (if available)

to fetch the function's reference page and read its **Extended

Capabilities -> Thread-Based Environment** section. Even then: an

absent or older entry is not proof the function won't run -- some

thread support is undocumented. When in doubt, try it.

----

Copyright 2026 The MathWorks, Inc.

----

Other skills for the same job

different authors, same section of the catalogue
D3 Viz
by chrisvoncsefalvay
×3

Creating interactive data visualisations using d3.js. This skill should be used when creating custom charts, graphs, network diagrams, geographic visualisations, or any complex SVG-based data visualisation that requires fine-grained control over visual elements, transitions, or interactions. Use this for bespoke visualisations beyond standard charting libraries, whether in React, Vue, Svelte, vanilla JavaScript, or any other environment.

20k tokens
Astropy
by christophacham
×3

Comprehensive Python library for astronomy and astrophysics. This skill should be used when working with astronomical data including celestial coordinates, physical units, FITS files, cosmological calculations, time systems, tables, world coordinate systems (WCS), and astronomical data analysis. Use when tasks involve coordinate transformations, unit conversions, FITS file manipulation, cosmological distance calculations, time scale conversions, or astronomical data processing.

16k tokens
Instrument Data To Allotrope
by anthropics
vendor ×2

Convert laboratory instrument output files (PDF, CSV, Excel, TXT) to Allotrope Simple Model (ASM) JSON format or flattened 2D CSV. Use this skill when scientists need to standardize instrument data for LIMS systems, data lakes, or downstream analysis. Supports auto-detection of instrument types. Outputs include full ASM JSON, flattened CSV for easy import, and exportable Python code for data engineers. Common triggers include converting instrument files, standardizing lab data, preparing data for upload to LIMS/ELN systems, or generating parser code for production pipelines.

33k tokens scripts
Qutip
by ComeOnOliver
×2

Quantum mechanics simulations and analysis using QuTiP (Quantum Toolbox in Python). Use when working with quantum systems including: (1) quantum states (kets, bras, density matrices), (2) quantum operators and gates, (3) time evolution and dynamics (Schrödinger, master equations, Monte Carlo), (4) open quantum systems with dissipation, (5) quantum measurements and entanglement, (6) visualization (Bloch sphere, Wigner functions), (7) steady states and correlation functions, or (8) advanced methods (Floquet theory, HEOM, stochastic solvers). Handles both closed and open quantum systems across various domains including quantum optics, quantum computing, and condensed matter physics.

27k tokens
Copilot Usage Metrics
by github
vendor ×1

Retrieve and display GitHub Copilot usage metrics for organizations and enterprises using the GitHub CLI and REST API.

1k tokens scripts
Mentoring Juniors
by github
vendor ×1

Socratic mentoring for junior developers and AI newcomers. Guides through questions, never answers. Triggers: "help me understand", "explain this code", "I''m stuck", "Im stuck", "I''m confused", "Im confused", "I don''t understand", "I dont understand", "can you teach me", "teach me", "mentor me", "guide me", "what does this error mean", "why doesn''t this work", "why does not this work", "I''m a beginner", "Im a beginner", "I''m learning", "Im learning", "I''m new to this", "Im new to this", "walk me through", "how does this work", "what''s wrong with my code", "what''s wrong", "can you break this down", "ELI5", "step by step", "where do I start", "what am I missing", "newbie here", "junior dev", "first time using", "how do I", "what is", "is this right", "not sure", "need help", "struggling", "show me", "help me debug", "best practice", "too complex", "overwhelmed", "lost", "debug this", "/socratic", "/hint", "/concept", "/pseudocode". Progressive clue systems, teaching techniques, and success metrics.

4k tokens
Astropy
by K-Dense-AI
×1

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

18k tokens
Polars
by K-Dense-AI
×1

High-performance DataFrame library for Python ETL, analytics, and pandas migration. Use for expression-based data manipulation with lazy query optimization, parallel execution, streaming out-of-core processing, Arrow interoperability, and optional GPU execution.

20k tokens

How to use it

Copy the folder

Take matlab/matlab-use-thread-pool from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.