Tabular assignment extremely slow

41 visualizzazioni (ultimi 30 giorni)
Piobaireachd
Piobaireachd il 11 Giu 2025
Modificato: Matt J il 14 Ott 2025 alle 18:45
I am using Matlab 2024a and tabular assignments (tabular.braceAssign as per Profiler) are making any code extremely slow compared to other computers with the same hardware, OS and Matlab version. A factor of 10x slower on my machine for the same piece of code. I tried to reset the cache, check for shadowed functions, but nothing helped.

Risposte (1)

Matt J
Matt J il 12 Giu 2025
Modificato: Matt J il 7 Ott 2025 alle 23:31
No demo code? Tsk...tsk..
But if I were to guess, it is because you are using brace indexing for row-wise access like in the code below. The overhead of brace indexing a single row is porportional to the size of the entire table, which means it will be slow if you have a large table. It is a known issue which I reported last September. Why you get different speeds on different computers I have no idea, but you should avoid row-wise assignment if you can.
T = combinations(1:100,1:100,1:40,1:40); %multi-row table
t=T(1,:); %one row table
timeit(@()assignTest(t))
ans = 2.3574e-04
timeit(@()assignTest(T))
ans = 0.2678
function assignTest(T)
T{1,:}=[1,1,1,1];
end
  5 Commenti
Paul
Paul il 6 Ott 2025 alle 17:27
Regrardless of this particular question, is there any progress on improving tabular brace indexing as shown in this thread and this other thread?
Matt J
Matt J il 14 Ott 2025 alle 17:10
Modificato: Matt J il 14 Ott 2025 alle 18:45
This is unlikely to be the problem, given that the OP said, "A factor of 10x slower on my machine for the same piece of code."
Since the OP said they are doing row-wise indexing, I think it has to be at least a major contributor to the problem. If I had to guess, I would say some of the different computers being compared are doing a better job of caching the large table2array result that table.braceReference computes. The OP said they are using similar hardware on all machines, but we don't know how similar...

Accedi per commentare.

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by