https://aostols.tistory.com/47
[Unity]ECS - 2
https://aostols.tistory.com/46 [Unity]ECS ECS 가 최근에 정식으로 출시 되었습니다. DOTS 의 핵심중 하나인데요 DOTS 는 3가지 큰 주제로 구성되고 있습니다. 1. ECS Component 2. Burst Compiler 3. Job System 여기서 ECS 가
aostols.tistory.com
이어서 진행 됩니다.
ECS 의 최적화 입니다.
가장 단순하고 효과좋은것이 BurstCompile입니다.
https://docs.unity3d.com/Packages/com.unity.burst@0.2/manual/index.html
Burst User Guide | Package Manager UI website
Burst User Guide Overview Burst is a compiler, it translates from IL/.NET bytecode to highly optimized native code using LLVM. It is released as a unity package and integrated into Unity using the Unity Package Manager. Quick Start Compile a Job with the b
docs.unity3d.com
예제에서는 Job을 기준으로 설명하고 있지만 Burst 는 기본적으로 많은 제약 조건을 가지고 있습니다.
성능을 많이 끌어올릴 수 있지만 제약조건이 많아서 사용하기 까다로롭습니다.
하지만 ECS 는 Burst에 완벽히 대응되기 때문에 쉽게 성능을 올릴 수 있습니다.
프로파일러를 활용하여 SpawnSystem이 스폰시킬떄의 모습입니다.
20.14ms를 잡아먹고 있습니다.
여기서 BurstCompile을 추가해 보겠습니다.
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
주된 스폰 작업을 하는 부분은 SpawnSystem.cs 의 OnUpdate이기 때문에 여기에 [BurstCompile]을 붙여줍니다.
이제 1.90ms가 되었습니다.
단순히 BurstCompile을 붙인것이지만 ECS 가 BurstCompile을 완벽히 지원하고 있기 때문에 효과가 좋습니다.
추가적으로 DancerSystem과 WalkerSystem도 살펴보게 되면 11.89ms, 13.14ms 로 볼수 있습니다.
동일하게 처리해 줍니다.
public partial struct WalkerSystem : ISystem
{
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
public partial struct DancerSystem : ISystem
{
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
동일하게 OnUpdate에 [BurstCompile]을 붙여줍니다.
결과는 역시 SpawnSystem과 동일하게 0.25ms, 0.20ms로 대폭 감소되었습니다.
'Unity Engine' 카테고리의 다른 글
[Unity]Playfab + Firebase 인증 (0) | 2025.03.25 |
---|---|
[Unity]Playfab + AzureBlobStorage 사용하기 (0) | 2024.12.26 |
[Unity]ECS - 2 (0) | 2023.12.19 |
[Unity]ECS (1) | 2023.12.05 |
[Unity] Animation Controller (3) | 2023.04.23 |