简体   繁体   English

如何将多个内核/线程组合成一个线程?

[英]How can multiple cores/threads be combined into a single thread?

I run a big minecraft server, minecraft server side is single threaded.我运行一个大型的我的世界服务器,我的世界服务器端是单线程的。 Everything is done in the main game loop.一切都在主游戏循环中完成。 If Mojang made minecraft server side multhreaded, Minecraft servers would save 2 million dollars a year from renting less hardware.如果 Mojang 使 Minecraft 服务器端多线程化,Minecraft 服务器每年将通过租用更少的硬件节省 200 万美元。

Anyway I have heard of these rumors and theories.无论如何,我听说过这些谣言和理论。 I've never been able to google it up and figure it out.我从来没有能够用谷歌搜索并弄清楚。

Is there anyway to take a multi core cpu, and convert it into a single core, single thread?反正有没有采取多核cpu,并将其转换为单核单线程?

I've been speculating that a hyperviser software would be run multithreaded and if it can be configured single core, it would convert multiple cores into a single core.我一直在推测管理程序软件将运行多线程,如果它可以配置为单核,它会将多个核转换为单核。

I approached my java programmer friend with this idea.我带着这个想法联系了我的 Java 程序员朋友。 And he told me that it was impossible because there is no way each individual threads could know what to do.他告诉我这是不可能的,因为每个单独的线程都不知道该做什么。 I don't remember what he said exactly, but he basically said it was impossible.我不记得他具体说了什么,但他基本上说这是不可能的。

Minecraft servers are spending upwards of 700 dollars a month on renting hardware overclocked to 4.5 ghz. Minecraft 服务器每月要花费 700 美元以上来租用超频到 4.5 GHz 的硬件。 Why?为什么? because default servers cost 100-150 and are at 3.8 to 4.5.因为默认服务器的成本为 100-150,并且在 3.8 到 4.5 之间。

An overclocked server will increase the single thread performance by 1/8th.超频的服务器将单线程性能提高 1/8。 This will cause the server to hold more players.这将导致服务器容纳更多玩家。 The more players a server can hold, the more money it can make.服务器可以容纳的玩家越多,它可以赚的钱就越多。

So instead of buying overclocked over prices servers, it would be much more efficient to buy quad proq E5 servers and hook them up into one thread, breaking all records for performance and player count.因此,与其购买超频服务器,不如购买 quad proq E5 服务器并将它们连接到一个线程中,从而打破性能和玩家数量的所有记录,效率会更高。

I understand the most efficient thing would be for mojang to just make minecraft multithreaded.我知道最有效的方法是让 mojang 使我的世界成为多线程。 This would require a complete rewrite of all the code.这将需要完全重写所有代码。

They don't want to do that.他们不想那样做。 A minecraft account costs 26 dollars.一个我的世界账户需要 26 美元。 They have sold 20 million.他们已经卖出了 2000 万。 They are rolling in the dough filthy rich, making stupid content updates instead of fixing minecraft servers to be multithreaded.他们在肮脏的面团中滚动,进行愚蠢的内容更新,而不是将我的世界服务器修复为多线程。

even minecraft game client isnt multithreaded.甚至我的世界游戏客户端也不是多线程的。

So the question is, is it possible to combine multiple cpu cores to achieve godly single thread performance?那么问题来了,有没有可能将多个cpu核结合起来,达到神一样的单线程性能? if so, how?如果是这样,如何?

I've heard it can be done but the overhead would be crazy.我听说它可以做到,但开销会很疯狂。

Anyway of calculating the overhead?无论如何计算开销?

If there was a way to do this, we'd be doing it.如果有办法做到这一点,我们就会这样做。 The problem is simple -- the program we are running only provides us a single stream of instructions.问题很简单——我们正在运行的程序只为我们提供了一个指令流。

Imagine the steps a person goes through to get ready for work in the morning.想象一下一个人早上准备上班所经历的步骤。 They get up, take a shower, get dressed, make breakfast, eat breakfast, and so on.他们起床、洗澡、穿衣、做早餐、吃早餐等等。 With the full list of steps, you could probably figure out efficient ways to overlap the tasks if you had more than one person.有了完整的步骤列表,如果您有不止一个人,您或许可以找出重叠任务的有效方法。 One person could pick the clothes while someone else was making breakfast, for example.例如,一个人可以在别人做早餐时挑选衣服。 But if you were only told each step when the previous step was complete, it would be hopeless.但是,如果上一步完成时才告诉您每一步,那将是无望的。

Single-threaded code only tells you each step when the previous step is complete.单线程代码仅在上一步完成时告诉您每一步。

Minecraft would require a total recode, as there is currently no way to make a program not designed to multicore use more then one core. Minecraft 需要完全重新编码,因为目前没有办法让不是为多核设计的程序使用多个核。 Fortunately, several groups have actually done a recode, with PaperMC being the biggest.幸运的是,实际上有几个小组进行了重新编码,其中 PaperMC 是最大的。 I do not know, however, if their multicore project actually worked out.然而,我不知道他们的多核项目是否真的成功了。 A mod called sodium for fabric as well as OptiFine both allow for multicoring on the client.一种称为用于织物的钠和 OptiFine 的 mod 都允许在客户端上进行多核。 You can even vote for Mojang to do this on the suggestions website at feedback.minecraft.net.你甚至可以在feedback.minecraft.net的建议网站上投票给Mojang来做这件事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM