如何将 GTA Online 的加载时间缩短 70%

注:机翻。未校。


How I cut GTA Online loading times by 70%

t0st

2021-02-28

GTA Online. Infamous for its slow loading times. Having picked up the game again to finish some of the newer heists I was shocked (/s) to discover that it still loads just as slow as the day it was released 7 years ago.
侠盗猎车手在线模式。因其缓慢的加载时间而臭名昭著。再次拿起游戏以完成一些较新的抢劫后,我震惊地 (/s) 发现它的加载速度仍然和 7 年前发布的那一天一样慢。

It was time. Time to get to the bottom of this.
是时候了。是时候深入了解这个问题了。

Recon

First I wanted to check if someone had already solved this problem. Most of the results I found pointed towards anecdata about how the game is so sophisticated that it needs to load so long, stories on how the p2p network architecture is rubbish (not saying that it isn’t), some elaborate ways of loading into story mode and a solo session after that and a couple of mods that allowed skipping the startup R* logo video. Some more reading told me we could save a whopping 10-30 seconds with these combined!
首先,我想检查是否有人已经解决了这个问题。我发现的大多数结果都指向关于游戏如何如此复杂以至于需要加载如此之长时间的轶事数据,关于 p2p 网络架构如何垃圾的故事(并不是说它不是),一些精心设计的加载到故事模式和之后的单独会话的方法,以及一些允许跳过启动 R* 标志视频的模组。更多的阅读告诉我,我们可以用这些结合起来节省高达 10-30 秒的时间!

Meanwhile on my PC… 同时在我的电脑上…

Benchmark

Story mode load time: ~1m 10s
Online mode load time: ~6m flat
Startup menu disabled, time from R* logo until in-game (social club login time isn’t counted).
Old but decent CPU: AMD FX-8350
Cheap-o SSD: KINGSTON SA400S37120G
We have to have RAM: 2x Kingston 8192 MB (DDR3-1337) 99U5471
Good-ish GPU: NVIDIA GeForce GTX 1070

I know my setup is dated but what on earth could take 6x longer to load into online mode? I couldn’t measure any difference using the story-to-online loading technique as others have found before me. Even if it did work the results would be down in the noise.
我知道我的设置已经过时了,但到底什么可能需要 6 倍的时间才能加载到在线模式?我无法像其他人在我之前发现的那样,使用故事到在线加载技术来衡量任何差异。即使它确实有效,结果也会在噪音中下降。

I Am (Not) Alone

If this poll is to be trusted then the issue is widespread enough to mildly annoy more than 80% of the player base. It’s been 7 years R*!
如果这项民意调查是可信的,那么这个问题就足够普遍,足以轻微地惹恼超过80%的玩家群。已经 7 年了 R*!

在这里插入图片描述

Looking around a bit to find who are the lucky ~20% that get sub 3 minute load times I came across a few benchmarks with high-end gaming PCs and an online mode load time of about 2 minutes. I would kill hack for a 2 minute load time! It does seem to be hardware-dependent but something doesn’t add up here…
环顾四周,找出谁是幸运的 ~20% 的加载时间低于 3 分钟,我遇到了一些高端游戏 PC 的基准测试,在线模式加载时间约为 2 分钟。我会在 2 分钟的加载时间内杀死 hack!它似乎确实依赖于硬件,但这里没有加起来…

How come their story mode still takes near a minute to load? (The M.2 one didn’t count the startup logos btw.) Also, loading story to online takes them only a minute more while I’m getting about five more. I know that their hardware specs are a lot better but surely not 5x better.
为什么他们的故事模式仍然需要将近一分钟才能加载?(顺便说一句,M.2 没有计算启动徽标。此外,将故事加载到网上只需要多一分钟,而我还有大约五分钟。我知道他们的硬件规格要好得多,但肯定不是 5 倍好。

Highly accurate measurements

Armed with such powerful tools as the Task Manager I began to investigate what resources could be the bottleneck.
有了任务管理器等强大的工具,我开始调查哪些资源可能是瓶颈。

在这里插入图片描述

After taking a minute to load the common resources used for both story and online modes (which is near on par with high-end PCs) GTA decides to max out a single core on my machine for four minutes and do nothing else.
在花了一分钟加载用于故事和在线模式的常用资源(这与高端 PC 几乎不相上下)之后,GTA 决定将我的机器上的单个内核最大化四分钟,而不做任何其他事情。

Disk usage? None! Network usage? There’s a bit, but it drops basically to zero after a few seconds (apart from loading the rotating info banners). GPU usage? Zero. Memory usage? Completely flat…
磁盘使用情况?没有!网络使用情况?有一点,但几秒钟后它基本上下降到零(除了加载旋转信息横幅)。GPU 使用情况?零。内存使用情况?完全平坦…

What, is it mining crypto or something? I smell code. Really bad code.
什么,是挖加密货币还是什么?我闻到代码的味道。真的糟糕的代码。

Single thread-bound

While my old AMD CPU has 8 cores and it does pack a punch, it was made in the olden days. Back when AMD’s single-thread performance was way behind Intel’s. This might not explain all of the load time differences but it should explain most of it.
虽然我的旧 AMD CPU 有 8 个核心,它确实很有冲击力,但它是在过去制造的。当AMD的单线程性能远远落后于英特尔时。这可能无法解释所有的加载时间差异,但应该可以解释大部分时间差异。

What’s odd is that it’s using up just the CPU. I was expecting vast amounts of disk reads loading up resources or loads of network requests trying to negotiate a session in the p2p network. But this? This is probably a bug.
奇怪的是,它只占用了CPU。我预计会进行大量的磁盘读取,从而加载资源或尝试在 p2p 网络中协商会话的网络请求负载。但是这个?这可能是一个错误。

Profiling

Profilers are a great way of finding CPU bottlenecks. There’s only one problem - most of them rely on instrumenting the source code to get a perfect picture of what’s happening in the process. And I don’t have the source code. Nor do I need microsecond-perfect readings - I have 4 minutes’ worth of a bottleneck.
分析器是查找 CPU 瓶颈的好方法。只有一个问题 - 他们中的大多数都依赖于检测源代码来完美地了解过程中发生的情况。而且我没有源代码。我也不需要微秒级的完美读数 - 我有 4 分钟的瓶颈。

Enter stack sampling: for closed source applications there’s only one option. Dump the running process’ stack and current instruction pointer’s location to build a calling tree in set intervals. Then add them up to get statistics on what’s going on. There’s only one profiler that I know of (might be ignorant here) that can do this on Windows. And it hasn’t been updated in over 10 years. It’s Luke Stackwalker! Someone, please give this project some love 😃
进入堆栈采样:对于闭源应用程序,只有一个选项。转储正在运行的进程的堆栈和当前指令指针的位置,以在设定的时间间隔内构建调用树。然后将它们相加以获得有关正在发生的事情的统计信息。据我所知,只有一个分析器(这里可能一无所知)可以在 Windows 上执行此操作。而且它已经有 10 多年没有更新了。我是卢克·斯塔克沃克!有人,请给这个项目一些爱:)

在这里插入图片描述

Normally Luke would group the same functions together but since I don’t have debugging symbols I had to eyeball nearby addresses to guess if it’s the same place. And what do we see? Not one bottleneck but two of them!
通常,Luke 会将相同的函数组合在一起,但由于我没有调试符号,我不得不查看附近的地址来猜测它是否是同一个地方。我们看到了什么?不是一个瓶颈,而是两个瓶颈!

Down the rabbit hole

Having borrowed my friend’s completely legitimate copy of the industry-standard disassembler (no, I really can’t afford the thing… gonna learn to ghidra one of

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值