当前位置:网站首页>Some thoughts on game performance optimization
Some thoughts on game performance optimization
2022-07-01 23:07:00 【Moyiii】
Recently, when doing optimization, I feel more and more , Optimization is not to add a comprehensive gain to the game Buff, The essence of optimization is to make trade-offs , On the one hand, it optimizes , It will inevitably bring about another problem , It is a zero sum game .
For example, we often use cache or object pool to improve the performance of the game , Reduce Caton , This is a typical space for time . At the same time, we also occasionally use compression technology , Compress a file , Or data tables , such as AssetBundle It's compressed , Then decompress it when reading . This is a typical time for space .
We are always changing time and space , Is there any optimization that improves performance from space to time ? Not without . But the cost of optimization may be engineering complexity , Smarter code often means less direct , More difficult to read , More difficult to expand and maintain , It may also be optimization for specific situations , Reduce the versatility of the solution . At first glance , This optimization seems acceptable . Then I have to give a few examples , Let's have a good discussion about this problem .
For example, a simple sort , We started with bubble sort , Later, it was changed to quick sort , We assume that fast sorting is brainless and better than bubble sorting , Time complexity and space complexity are lower . But at the same time, we also made a hypothesis , That is, the code that is quickly arranged is more difficult to write , It is also more difficult to understand , The students who took over didn't understand how the algorithm was implemented , Dare not change , Then there is a need to modify some logic of sorting , The classmate panicked at once , Finally, it was changed for a week, and finally it was changed , It's hard on the head . If bubble sorting is used , I believe this student will soon be able to meet the needs of new changes .
Here is just one example , But it is enough to explain some problems .《 The code of 》 In the said
The first technical mission of programmers is to control complexity
Everyone has a different understanding of this sentence , What complexity is controlled , But in my understanding , Part of it is code complexity , Architecture complexity , Engineering complexity . Maybe you used a very clever and advanced architecture and Algorithm , But you can't completely control yourself , Then you lack control over it , Maybe this version can run without problem , But you can't face the problems well , Future maintenance extensions , And modify the requirements .
I'm not saying that we can't write better algorithms . It's about expressing , Any optimization comes at a price , But sometimes you don't realize the form of cost , Think this is not brought about by optimization .
For example, I once did an optimization in the project , The result of this optimization is , All resources need to run the script again and modify it before they can be used . As a result, the packaging processing time is too long , It's too late to get out of the bag , It affects the acceptance of the test part , Lead to frequent complaints , Eventually my script was rolled back , I have to choose a more cautious approach .
Each project has its own pipeline , Project cost , Just like the example I just gave , The time of the testing department is usually compressed , Especially near the launch or version update , Any behavior that affects the test process may cause the project to fail to be accepted normally , And then cause the project to delay or suffer Bug Online and other serious consequences , This is absolutely not allowed for a mature project that has been launched .
Optimization is not just a technical activity
My predecessor made a version of optimization before leaving , As a result, there are nearly twice as many game resource files . Finally, the game download time is too long , Rejected by Apple . So the first task I took over , It turned out to be working overtime all night and seriously retreating from the optimization code of our predecessors , That taste can be imagined how absurd and helpless .
So optimization is a trade-off , Timing , For people , It varies from project to project , Analyze and clarify the key points of optimization , What will be sacrificed at this price , It is reasonable to optimize after confirming . If the analysis is not clear, blindly optimize , You may not get the effect or make negative optimization , At the same time, he also buried many uncertain pits in his future .
For example, games focus on combat experience , Then fighting without Caton is the most needed part , You may preload , Object pool , Special effect grading and other technologies to ensure CPU and GPU Fluency of . Although increasing the memory may cause the low-end machine to flash back , But it's always better than fighting. It's better for every machine to get stuck one by one . After ensuring the game experience , Then slowly find a way to optimize the memory occupation . In fact, the best way to exchange time and space is to transfer the cost to external storage . Some are right IO Time consumption insensitive , For example, some UI Data read by logic , You can put it in an external directory , Instead of putting it in memory . It's also good to choose a suitable degree according to the final experience . Of course, if this leads to too many external storage files , And the project has complex logic , That will also bring other problems , Still have to make a choice . Of course, if your core gameplay is not so hard , It's like making a SLG, Require the game to iterate over new content , Make late profits , Then you should be more cautious about the design of the framework , Maintainability and scalability of the framework , Rapid response has become the focus of a project . So no matter time or space , Make concessions to the architecture without affecting the experience , Make the architecture more flexible and easy to use .
So the optimization problem is very big , In fact, the most important thing is to figure out the goal , What do you want to optimize . First determine the focus of the project , Then choose the optimization direction , Then analyze the bottleneck of the project through appropriate tools , Then choose the appropriate method to optimize . Of course, we should remember that sentence in the process :
Control complexity , Make a choice
Search for
Copy
边栏推荐
- shell 流程控制
- [MySQL] index creation, viewing and deletion
- Cisco -- highly available and reliable network examination
- "Trust machine" empowers development
- Turn -- bring it and use it: share a gadget for checking memory leaks
- SAP intelligent robot process automation (IRPA) solution sharing
- AAAI22 | 结构标记和交互建模:用于图分类的“SLIM”网络
- Cisco -- an external tool for WAN's concept examination
- 下班前几分钟,我弄清了v-model与.sync的区别
- 什么是马赛克?
猜你喜欢
MySQL -- index of InnoDB storage engine
SAP intelligent robot process automation (IRPA) solution sharing
每日刷题记录 (十)
MySQL -- index of MyISAM storage engine
思科考试--冗余网络
死锁的处理策略—预防死锁、避免死锁、检测和解除死锁
Cisco -- highly available and reliable network examination
[JUC learning road day 9] barrier derivatives
ESP自动下载电路设计
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received
随机推荐
What class loading mechanisms does the JVM have?
每日刷题记录 (十)
Use and function of spark analyze command map join broadcast join
The principle, testing and Countermeasures of malicious software reverse closing EDR
Daily question brushing record (10)
Istio、eBPF 和 RSocket Broker:深入研究服务网格
Quantifiers of regular series
Cloud Vulnerability Global Database
Contents of other parts of the map
shell 流程控制
Groups and ranges of regular series
Kubernetes create service access pod
91. (cesium chapter) cesium rocket launch simulation
Programming English vocabulary notebook
Armbain系统根分区空间不足处理
软件测试之「 性能测试」总结,新手上路必会知识点
Explain ThreadLocal in detail
YOGA27多维一体电脑,兼具出色外观与高端配置
tcpdump命令使用详解
Use 3DMAX to make a chess piece