• 日本語
  • Unity パフォーマンス問題について

  • संपादित
Related Discussions
...

お世話になっております。
Spineのパフォーマンスを調査するため簡易プロジェクトを作成しテストしたところ、
その結果、PS4ビルドのCPUに高い負荷がかかっていることが分かりました。

環境
Unity 2019.3.15f1
Package version: spine-unity-3.8-2020-11-13.unitypackage

テスト内容
・新規プロジェクトを作成しSpineSDKをインポート
・SpineUnityGirlをSkeletonAnimationで30オブジェクトを配置
・アニメーションは"main"をループ再生
・Devlopビルドで確認("Deep Profiling Support"は無効)

結果
約40fpsほどで60fpsを下回りました。
CPUのSkeletonAnimation.LateUpdate()とSkeletonAnimation.Update()に高い負荷がみられました。

こちらは正しい結果になっていると考えられますか?
また、開発ではUIなどもSpineで構成する想定でいましたので多くのSpineを扱うために
パフォーマンス改善で必要な設定や方法がありましたら教えて頂けると助かります。
よろしくお願い致します。

PS4でパフォーマンスの問題が発生しているとのことで、大変申し訳ございません。 たった30個のスケルトンで SkeletonAnimation.LateUpdateに16.9ミリ秒という非常に多くの時間が費やされているのを見るのは本当に驚くべきことです。 ご存知かもしれませんが、一般的なPCでは、これには約1/10の時間がかかります(ラップトップで1.7ミリ秒を測定しました)。 残念ながら、利用可能なPS4開発キットはありませんが、シングルスレッドを使用する場合にPS4 CPUがラップトップよりも遅いと考えている場合でも、10倍遅くなることはありません。

Unityプロファイラーがここに信頼できる情報を表示していると確信していますか? プロファイラーを接続せずにPS4でビルドを通常実行すると、40 fpsも表示されますか?

2020.1などの別のUnityバージョンが同じ悪いパフォーマンスにつながるかどうかをテストしましたか?


We are very sorry to hear that you are seeing performance problems on PS4. It is indeed surprising to see such a high number of 16.9 milliseconds spent on SkeletonAnimation.LateUpdate for only 30 Skeletons! As you may know, on a typical PC this takes about 1/10 of the time (I measured 1.7 ms on my laptop). Unfortunately we have no PS4 dev-kit available, but even when considering the PS4 cpu to be slower when using a single thread than my laptop's, it should not be 10x as slow.

Are you certain that the Unity profiler is showing reliable information here? Are you also seeing 40fps when normally running the build on the PS4 without the profiler attached?

Did you perform some tests whether a different Unity version, such as 2020.1 leads to the same bad performance?

返信ありがとうございます。

Unity profiler に接続していない場合は少しfpsが向上しますが、ほとんど変わりませんでした。

Unity 2020.1 についてはこれからテストしてみたいと思います。
結果が分かり次第、お伝え致します。

よろしくお願いいたします。


Harald लिखा

2020.1などの別のUnityバージョンが同じ悪いパフォーマンスにつながるかどうかをテストしましたか?

お待たせ致しました。
Unity 2020.1.14f1 でテストしたところ、Unity 2019と同様にパフォーマンスが悪い状態でした。
"Deep Profiling Support" を有効にし確認したところ、
VertexAttachment.ComputeWorldVertices() に負荷が見られました。

引き続きパフォーマンスの問題を調査したいと思います。
もしパフォーマンスの改善について進展がありましたらご連絡頂けると幸いです。
よろしくお願いいたします。

調査ありがとうございます。 問題が解決しないとのことで、ご不便をおかけしております。

「ディーププロファイリングサポート」を有効にします
VertexAttachment.ComputeWorldVertices()に待っが見られました。

追加されたインストルメンテーション命令は結果を歪め、かなり役に立たなくなるため、「ディーププロファイリングサポート」をいつでも有効にしないでください(通常、高速の数学関数呼び出しの表示ははるかに遅くなります)。

a)プロファイリングが有効でb)ディーププロファイリングが有効になっているデバイスでビルドを常にテストしましたか? はいの場合、プロファイリングとデバッグを完全に無効にしてテストを実行してください。それでも40 fpsで実行されますか?


Thank you for your investigations. Sorry to hear that the problem persists.

"Deep Profiling Support" を有効にし確認したところ、
VertexAttachment.ComputeWorldVertices() に負荷が見られました。

Please do not enable Deep Profiling Support at any time, because the added instrumentation instructions will distort the result and make it rather useless (normally fast mathematical function calls will then be displayed much slower).

Did you always test the build on device with a) profiling enabled and b) deep profiling? If yes, could you please perform a test with profiling and debugging disabled entirely, does it then still run at 40 fps?

Harald लिखा

Please do not enable Deep Profiling Support at any time, because the added instrumentation instructions will distort the result and make it rather useless (normally fast mathematical function calls will then be displayed much slower).

こちらの件、承知いたしました。

Harald लिखा

Did you always test the build on device with a) profiling enabled and b) deep profiling? If yes, could you please perform a test with profiling and debugging disabled entirely, does it then still run at 40 fps?

はい、こちら"Development Build" を無効にした場合でも約40fpsとなっていました。

参考になると良いのですが、下記がテストした結果になります。
a) "Development Build" を無効 : 約40fps
b) "Development Build" を有効 : 約37fps
c) "Development Build" と "Deep Profiling" を有効 : 約25fps

ああ、「ディーププロファイル」を有効にした状態で40fpsになるといいのですが。 ご不便をおかけして申し訳ございません。

この問題が「ヒーロー」や「スパインボーイ」などの他のスパインスケルトンでも同じように発生するかどうかをテストしていただけますか?


Oh dear, I would have hoped that it was 40 fps with Deep Profile enabled. We are sorry to hear that.

Could you please test if this problem also occurs in the same way with other Spine skeletons, like Hero or Spineboy?

Harald लिखा

Could you please test if this problem also occurs in the same way with other Spine skeletons, like Hero or Spineboy?

お待たせいたしました。
こちらの検証が不足しており申し訳ありませんでした。

HeroとSpineboyを同じ条件でテストしたところUnitySpineGirlほどの高負荷は見られませんでした。
Hero

Spineboy

他のもテストしたところRapterがUnitySpineGirlより高負荷になっており、
StretchymanはUnitySpineGirlほどではありませんが負荷が高めになっていました。

また、高負荷のSpine skeletonsはアニメーションを再生しなくても高負荷にみえます。
例ですが、アニメーションを再生しないUnitySpineGirlの場合は約48fpsでした。

謝罪する必要はありません、追加のフィードバックとテストをありがとう。

残念ながら、これらの値はすべて、DoiSpinegirlプロジェクトの値よりも優れている場合でも見栄えがよくありません。変換される頂点の数は、結果として費やされるミリ秒に直接相関しているように見えます。なぜこれがPCよりも約5〜10倍遅いのか疑問に思います。ただし、これでも、Spinegirlで最初にプロファイラーを実行するときにアニメーション(「更新」)にも非常に時間がかかる理由は説明されていません。 PS4用に構築した場合、数学的なC#操作が十分に最適化されていないかのように動作します。

PS4用にビルドするときに利用できるUnityPlayer設定のスクリーンショットを共有できますか?コンパイルバックエンドを使用するために利用できるオプションはありますか?たとえば、Andoidは IL2CPPを提供していますが、同様のオプションを利用できますか?

並列化のロードマップにこの問題チケットがあります。これにより、CPUスレッド間で計算を分散することにより、前述の UpdateおよびLateUpdateメソッド呼び出しのパフォーマンスが向上するはずです。
https://github.com/EsotericSoftware/spine-runtimes/issues/1348
PS4で数学演算が遅い理由が見つからない場合、この並列化によってパフォーマンスが大幅に向上するはずです。残念ながら、4.0ではいくつかの緊急の変更を完了する必要があるため、このチケットを実装するまでには時間がかかります。私たちが提供できるのは、優先キューでそれを上に移動し、当初の計画よりも早く実装することだけです。それでも、このチケットの実装にはある程度の努力が必要です。

PS4での数学演算のパフォーマンスやスピードアップに関する情報を見つけた場合は、お知らせください。

この問題が改善されるまで、費やされる時間をできるだけ短くするために、可能な場合は頂点の数を最小限に抑えることをお勧めします(メッシュアタッチメントの代わりに通常の領域アタッチメントを使用)。


No need to apologize, thank you for the additional feedback and testing.

Unfortunately, these values all do not look good, even when they are better than the ones at the Doi Spinegirl project. It seems as if the number of vertices to be transformed directly correlates to the resulting milliseconds spent. I still wonder, why this is about 5-10x slower than on PC. This however still does not really explain why the animation (Update) also takes very long at your first profiler run at Spinegirl. It behaves as if any mathematical C# operations are not well optimized when built for PS4.

Could you perhaps share a screenshot of the Unity Player settings available when building for PS4? Do you have any options available on which compilation backend shall be used, Andoid for example offers IL2CPP, do you have similar options available?

We have this issue ticket on the roadmap for parallelization, which should improve performance of the mentioned Update and LateUpdate method calls by distributing the computation across CPU threads:
https://github.com/EsotericSoftware/spine-runtimes/issues/1348
If we fail to find the reason why math operations are slow on PS4, this parallelization should improve performance by a significant amount. Unfortunately it will take some time until we get to implement this ticket, as some urgent changes have to be finished for 4.0. All we can offer is to move it up in the priority queue and implement it sooner than originally planned. Still this ticket will be take some effort to implement.

If you should find any information in regards to performance of math operations on PS4 and on any speedups, please let us know.

Until this issue is improved, we can only suggest to keep the number of vertices to a minimum (using normal region attachments instead of mesh attachments) where possible, in order to keep the time spent as low as possible.

Harald लिखा

Could you perhaps share a screenshot of the Unity Player settings available when building for PS4? Do you have any options available on which compilation backend shall be used, Andoid for example offers IL2CPP, do you have similar options available?

Unity Player settings のIL2CPPの設定項目を変更し、
最初と同様のテスト(SpineUnityGirl)を行ったところパフォーマンスが改善されました。

IL2CPPの影響がここまで大きいと考えておりませんでした。
ご教授頂きありがとうございます。

Harald लिखा

We have this issue ticket on the roadmap for parallelization, which should improve performance of the mentioned Update and LateUpdate method calls by distributing the computation across CPU threads:
https://github.com/EsotericSoftware/spine-runtimes/issues/1348

情報を頂きありがとうございます。
更なるパフォーマンス改善が必要になった際は参考にさせていただきます。

IL2CPPを更新していただき、ありがとうございます。パフォーマンスが向上したことを大変うれしく思います。 また、この違いがこれほど劇的になるとは思ってもみませんでした。PS4ではモノラルの数学演算の最適化が非常に悪いようです。

並列化による追加のパフォーマンスの最適化が進んだら、お知らせします。

あなたの忍耐とテストフィードバックを提供することによるすべての助けに感謝します!


Thank you for the update on IL2CPP, I am very glad that it has improved performance! I would also never have expected the difference to be so dramatic, it indeed seems as if optimizations on math operations for mono are very bad on PS4.

We will let you know once we have made any progress on the additional performance optimizations via parallelization.

Thanks for your patience and for all the help by providing test feedback!

24 दिन बाद में

悪い日本人でごめんなさい。私はGoogle翻訳を使っています。

PS4でも同様の問題があります。変更した設定の詳細を教えてください。

より高速なスレッドで実行するようにSpineを変更しています。私たちの実装は大まかなもので、まだ安定していません。


Sorry for bad japanese. I'm using Google translate.

We have similar issues on PS4. Please can you give detailed information on the settings you changed?

We have been modifying Spine to run on threads which is faster but our implementation is rough and not stable yet.

@sirob One of the major changes was to enable the IL2CPP compilation backend. Did you set this option in your project accordingly?

Harald लिखा

@[हटाया गया] One of the major changes was to enable the IL2CPP compilation backend. Did you set this option in your project accordingly?

Thanks for following up.

What had confused me was that IL2CPP is the only option these days, so it's always on. (Unity 2019.4 LTS)

However a further look showed that the important setting is IL2CPP optimization level, which other platforms do not have. We had this at No Optimization, but turning on the optimizations gives a significant performance boost, at the cost of longer build times.

Thanks for the info! As we unfortunately have no PS4 dev kit available, we were not yet aware of the available settings of the PS4 target.