Why doesn't parfeval(@splitapply) improve splitapply's performance?

5 ビュー (過去 30 日間)
Simon
Simon 2023 年 8 月 31 日
コメント済み: Simon 2023 年 9 月 6 日
I want to readtable many html-files to extract tables. I wrote a function extract_sheet to do just that. I had used parfor to perform this task, and it runs decently fast. Then it occurs to me that those html-files can be grouped according to their foder and filename segments. So, I try splitapply(extract_sheet, input variables, groupNumber), and it works. Then I want to see if parfeval would improve the speed. I do something like parfeval(@splitapply, extract_sheet, input variables, groupNumber.)
For a small testing file list, both methods spend almost the same amount of elapsed time, around 27.5 +/- .1 seconds. My question is why parfeval doesn't improve the performance?

採用された回答

Matt J
Matt J 2023 年 8 月 31 日
編集済み: Matt J 2023 年 8 月 31 日
It probably means that Matlab's internal parallellization already does what parfeval does.
  6 件のコメント
Simon
Simon 2023 年 9 月 1 日
@Sam Marshalik, the splitapply doc page does say it is one of the functions that support multi-thread and suggest the users to read parfeavl doc. That's all I found in the doc. The doc is too stingy with providing parallelism instruction materials for Matlab-users (not software developers).
Sam Marshalik
Sam Marshalik 2023 年 9 月 5 日
編集済み: Sam Marshalik 2023 年 9 月 5 日
@Matt J: You bring up a good point that the doc page is lacking information on this topic. I put in an enhancement request to improve that. In the meantime, I would suggest to call our Technical Support - they can investigate this further and reach out to the relevant Dev team.

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2023 年 9 月 5 日
編集済み: Matt J 2023 年 9 月 5 日
If you're going to be using PCT functions anyway, I wonder if a parfor loop might do better than splitapply. I.e., instead of,
splitapply(func,X,G)
one might instead do,
I=splitapply(@(x){x}, 1:numel(G), G);
parfor j=1:numel(I)
results{j}=func( X(I{j}) );
end
  1 件のコメント
Simon
Simon 2023 年 9 月 6 日
That's a really nice solution. I'll try it. My experience with parfor tells me it's gonna be fast.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by