Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Perf/stage performance improve #22

Merged
merged 2 commits into from
Jun 12, 2023
Merged

Conversation

WooWan
Copy link
Owner

@WooWan WooWan commented Jun 12, 2023

Stage에서 브라우저가 작동을 멈추거나 느려지는 현상 해결

stage에서 브라우저가 멈춤이 잦아서 performance를 브라우저에서 확인해보았을 때 re-rendering으로 인해 scripting이 과도하게 많이 일어나는 문제를 발견.
코드를 다시 분석해봤을 때, useFrame 내부에서 setState를 실행하고 이에 따라 컴포넌트가 매 프레임마다 렌더링되고 있었습니다.
이를 방지하기 위해서 setState를 통해 state를 변경하는 대신, 값을 변경하여도 리렌더링이 일어나지 않는 useRef를 사용하여 성능 개선을 진행하였습니다


성능 개선 전

성능 개선 후

성능 비교

1번과 2번 테스트 모두 약 10초 동안의 3d 렌더링 성능을 테스트해보았습니다
1번은 10.01초 동안 script를 처리하는데 걸린 시간이 9636ms 이고, 2번 테스트는 10.38초 동안 2280ms가 걸린 것을 확인하였습니다

동일 시간 기준: 개선 전 => 개선후 약 scripting 77% 감소

@WooWan WooWan merged commit adc4085 into main Jun 12, 2023
@vercel
Copy link

vercel bot commented Jun 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
capstone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2023 4:33pm

@WooWan WooWan mentioned this pull request Jun 18, 2023
9 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant