Bay 12 Games Forum

Dwarf Fortress => DF General Discussion => Topic started by: Llamageddon on April 21, 2018, 12:46:11 pm

Title: Best CPU for DF?
Post by: Llamageddon on April 21, 2018, 12:46:11 pm
This is a bit hypothetical, I have an i5-4690K (3.5 GHz) so I assume there is not much to be gained by a new CPU, but I am curious, as given the price of graphics cards at the moment I am getting into a lot of CPU intensive games like DF.

What would be the best CPU on the market for DF if money is no concern?

What would be the best upgrade from mine if on a budget?

And I suppose for others reading this, is there an even better budget option lower than my i5?

Are there any specifics to keep in mind for a game like DF? Would things like faster ram, SDD  etc make a bigger difference?

As I say, kind of hypothetical, but any insight into how DF makes use of these resources and processes things would also be quite interesting to me.
Title: Re: Best CPU for DF?
Post by: Bumber on April 21, 2018, 01:25:56 pm
http://www.bay12forums.com/smf/index.php?topic=105554.0
http://www.bay12forums.com/smf/index.php?topic=148409.0
http://www.bay12forums.com/smf/index.php?topic=157926.0
Title: Re: Best CPU for DF?
Post by: Llamageddon on April 21, 2018, 01:42:08 pm
Ah, thanks. I searched the forums but I get so many results that are completely unrelated I can never find anything I am looking for.

How did you find those posts so easily? Are there search parameters I don't know about?
Title: Re: Best CPU for DF?
Post by: Bumber on April 22, 2018, 10:41:24 pm
How did you find those posts so easily? Are there search parameters I don't know about?
I only found them because I knew they existed. Had to try a couple different terms.
Title: Re: Best CPU for DF?
Post by: Rose on April 22, 2018, 11:28:00 pm
Best is probably 8086, but if you can't get it, 486 will do in a pinch.
Title: Re: Best CPU for DF?
Post by: wierd on April 23, 2018, 01:35:52 am
I somehow doubt that a 16bit cpu running between 5 and 10mhz is going to play DF that great. :P
Title: Re: Best CPU for DF?
Post by: Llamageddon on April 23, 2018, 09:58:15 am
Hah, great recommendations Japa. I'll dust off the old 486 then. I'm sure everything will be fine... Does a 486 have a 1gb cache? Must do.
Title: Re: Best CPU for DF?
Post by: Rose on April 23, 2018, 10:12:04 am
Close.

It has 8kb. Should be enough.
Title: Re: Best CPU for DF?
Post by: Codyo on April 24, 2018, 01:37:30 am
In the end, I'd go with a CPU that has the highest clock speed possible. With the current market and overclocking with intel CPU's you should be able to get 4.5-5.0 Ghz But that's probably overkill for this game. In this day and age if you're getting the latest hardware, you shouldn't have to worry about the size of the caches people will mention.
I agree with what others say on this topic whenever it's brought up. Having the fastest RAM should make a difference as the world has to be loaded in the background for constant calculations each month. If you didn't play before the 0.40 versions, you wouldn't have seen what a titanic hit on performance "real time" history generation made during Fortress mode. RAM would help with this aspect of the game.
Title: Re: Best CPU for DF?
Post by: wierd on April 24, 2018, 02:32:17 am
*Contemplates seeing if DF will run on a 486 using the linux version.
Title: Re: Best CPU for DF?
Post by: mikekchar on April 24, 2018, 03:14:43 am
This might be a way to try it: http://bochs.sourceforge.net/  I haven't played with it at all, but I've heard good things about it.  I think the biggest problem will be RAM, but with enough virtual memory you might be able to do it.
Title: Re: Best CPU for DF?
Post by: thompson on April 24, 2018, 03:55:01 am
General advice is a modern CPU with low latency RAM and a fast CPU to RAM memory bus.

The precise CPU isn't so straightforward. Naively you may expect a CPU with a large cache to be better, but this isn't necessarily true. Modern CPUs can actually anticipate the memory the data they need to fetch from the RAM and prefetch it to the cache before it is needed. The microarchitecture can also vary between CPUs with similar clock speeds, which can mean some CPUs can perform calculations with fewer clock cycles than others. Unfortunately, I don't know what sorts of optimizations Toady has applied (or which compiler and the settings of said compiler), so a general all-rounder CPU could be the safest bet. Edit: I should add that larger caches are slower as connections are physically larger. Whether a large slow cache works well for DF depends if CPU prefetching is effective. I have no idea if that is the case for DF.

One of the biggest microarchitectural differences is the length of the pipeline. It determines how far in advance the CPU had to fetch information. Deep pipelines are faster, but if you get a branch prediction failure there will be longer delays. It would be good to do some science on this to see if there is an optimal microarchitecture.

A good science project would be to create a standardized fort (let's call it DFSF2018), save it, then compare FPS across different CPU/RAM combinations. If we could get enough data we might be able to work out if any specific CPU architectures are better than others, and whether the need for low RAM latency can be mitigated by a CPU with better prefetching, if deep pipelines are better than shallow ones, and how important cache size is. Note: to do all that we'll need an absolute ton of data.
Title: Re: Best CPU for DF?
Post by: Werdna on April 24, 2018, 10:59:07 am
There's likely to be some serious AMD vs Intel uP performance differences after things settle from Meltdown (Intel) and Spectre (both) fixes and OS workarounds.  I haven't been keeping up to date with it, maybe someone else here is better informed and can comment. 

I mention it because if you guys are going to do science with CPU/memory keep in mind that there are Meltdown and Spectre patches for the OS (and I think Windows already has issued several patches of the patches) that will likely change performance, so you may see different results depending on where you are in your updates.  I believe Spectre will result in mobo patches, so ditto there.
Title: Re: Best CPU for DF?
Post by: Larix on April 25, 2018, 05:22:08 am
Just random empiric observation:
An Athlon 64 X2 with 3 GHz clock (pub. 2007) ran DF adequately, somewhat but not notably faster than a 2 GHz (mobile) Core2Duo. A mobile 7th gen. i3 gets about 40% higher FPS at 2.4 GHz clock. The important differences in favour of the i3 are: more cache (3,5 MB vs. 1 MB (nominally 2, but only one per core) on the AMD), more RAM bandwidth (DDR4/2133 vs. DDR2/800), something like 80% higher IPC. A fairly recent Intel Atom with 1 GB (DDR3/1600?)RAM can execute the game, but i wouldn't call it "run". All this to me suggests that a modern CPU with good single-thread performance, backed up with fast RAM should work well.

For all those joking about running DF on old systems: i tried out an older, probably 0.28.xx, version on a Celeron 633, running Windows Me (yes, Me; worked alright for me :P ) with all of 64 MB of PCI 66 MHz RAM, shared video memory. It ground horribly trying to show the intro movie, so i escaped out of that after five minutes of sporadic disorganised letters flying across the screen. The game itself did start and reached something like 2FPS at embark. I didn't play it for long. I've no idea whether that was just the issue of having to do tons of memory accesses at 66 MHz or if it went over the built-in memory and kept swapping stuff on and off the harddisk (a.k.a. pagefile).
Title: Re: Best CPU for DF?
Post by: mikekchar on April 25, 2018, 07:25:00 pm
I expect Spectre to chew a good 10% off of DF performance, unfortunately.  But who knows.  It really depends on the code.

It's interesting about the system comparison.  For people who are serious about FPS, I think you'll get better gains from being very careful about fortress design that you will from processor or RAM upgrades (assuming you are already on a reasonably modern CPU).  Or putting it differently, I think an expensive computer won't really appreciably save you from bad fortress design.  It would be interesting to see if I'm right, though.  I'd love to see a challenge for maxing FPS on a productive fortress of 100 dwarfs, opened caverns, full vegetation on the surface and temperature turned on.  I'll bet there would be examples with almost an order of magnitude difference.
Title: Re: Best CPU for DF?
Post by: jecowa on May 01, 2018, 10:41:21 pm
Clock speed and single-threaded performance does not matter after a certain point since cache misses are the bottleneck. With that in mind, I think second gen Ryzen processors would probably be a good candidate for the best CPU for Dwarf Fortress since they have low cache latency.

Having lots of cache is helpful, but from what I understand, I don't think you can judge a CPU's cache capacity just from its listed spec. This is because not all of the listed L3 cache included with a CPU is going to be available to a single thread. Ryzen has 16 MB of L3 cache, but it's split into 2 groups of 8 MB. Half the cores share one 8 MB L3 cache and the other half share the other 8MB.
Title: Re: Best CPU for DF?
Post by: Larix on May 02, 2018, 04:39:27 am
I fired up one of the system management apps and as i remembered, that one has a "cache misses per second" parameter. Looked at two mildly cluttered forts (yes, that's totally unrepresentative):
first one - 84 FPS: cache misses/s typically ranged between 150 and 300, with rare spikes to 1000+. About 250 on average, i'd say
second one - 33 FPS: between 200 and 400 misses/s, spikes of just over 2000. Estimated average just above 300.

Naively, this looks to me like at this range, it's not cache misses that matter: assuming one cache miss costs 200ns, even 2000 in one second would amount to just 400µs, while the average even in the more-cluttered fort should sit comfortably below 100µs/s, i.e. less than 1% of 1% of operation time. I'd assume that purely cache-miss driven operation would be extreme lag spikes of under one FPS.

I'm almost certainly missing something fundamental, but i think it'd help if knowledgeable people tried to run some analytics on what influences FPS. I get the feeling we're still mostly dealing with assumptions that have little research behind them.

***
I've also looked at the parametrics on the old Core2Duo under Linux, and there, the manager shows a processor load of 100% on both cores, with no intensive process other than DF running. Curious...
Under Windows 10, with a 2C/4T processor, all threads show similar workloads, 25-40% mostly. The process gets moved between threads so often that load averages out over the measurement times. Thread switching is part of thermal management, i guess. The Core2 heats up from ~45 °C to ~75 when playing DF, and it's certainly better if it heats the cores evenly.
Title: Re: Best CPU for DF?
Post by: jecowa on May 02, 2018, 11:22:10 am
Previously someone tried over locking his CPU and got no performance boost. Then he tried overclocking his RAM and was able to increase the FPS (I think it went up from 10 to 12, but I haven't found the post yet.)

What app shows cache misses per second?

Edit: Here's one were he upgrades from i5-2400 (1203 cpu-z benchmark single thread) to i7-3770K (1910 cpu-z benchmark single thread) and got maybe a 11% FPS boost. Then he upgraded his RAM from 1600 MHz to 2400 MHz and got a 50% FPS boost. https://www.reddit.com/r/dwarffortress/comments/5kyyb5/faster_ram_gave_me_a_nice_fps_boost/
Title: Re: Best CPU for DF?
Post by: TV4Fun on May 03, 2018, 06:23:14 pm
Without detailed profiling data on how DF spends its time, it's difficult to speculate, but I suspect that in more cluttered fortresses, much of the game's time is spent on pathfinding, and is probably computation-bound. With that in mind, you want to find the highest single-threaded computations-per-second CPU you can get. Number of cores won't make a difference as DF is not multi-threaded. RAM speed may make some difference, but I doubt it's a deciding factor. Clock rate is an indicator of performance, but different CPUs will have different computation rates at the same clock speed. I don't think DF does much with floating point numbers, so integer performance is more important. Beyond that, the best way to determine performance would be by testing with different CPUs on the saved game. It's very hard to predict performance based on purely theoretical notions.
Title: Re: Best CPU for DF?
Post by: lethosor on May 08, 2018, 09:04:50 am
Ah, thanks. I searched the forums but I get so many results that are completely unrelated I can never find anything I am looking for.

How did you find those posts so easily? Are there search parameters I don't know about?
A bit late, but use Google! With "site:bay12forums.com", you'll only get results from the forum. I got all of the threads that Bumber linked plus several others on the first page with "site:bay12forums.com best cpu".

Usually this is a lot better than forum-specific searches, unless you want to use forum-specific filters like the ones found on http://www.bay12forums.com/smf/index.php?action=search (http://www.bay12forums.com/smf/index.php?action=search).
Title: Re: Best CPU for DF?
Post by: Schmaven on May 08, 2018, 05:29:11 pm
I just upgraded my i3-6100 3.7 GHz dual core to an i7-8700 3.7 GHz 6-core processor. 
In order to do that, I also upgraded my motherboard from an msi Z-170A Pro to an msi Z-370 SLI Plus.

Now I don't know exactly which part is responsible, but my FPS jumped up from around 37-45 to 65-75 on average with the same fort.  The important part for me is my Dwarves move about twice as fast now, so that's cool. 
Title: Re: Best CPU for DF?
Post by: jecowa on May 10, 2018, 10:01:44 pm
I wish someone would do some Dwarf Fortress test to compare these processors:

Disadvantage of the Broadwell is the DDR3, but it has that nice 128 MB L4 cache with the eDRAM.
Coffee Lake has the highest single-threaded performance, but Zen+ has the best cache latency.
Title: Re: Best CPU for DF?
Post by: Chief10 on May 11, 2018, 01:17:51 am
I don't think DF does much with floating point numbers, so integer performance is more important.

Just curious what makes you say this?
Title: Re: Best CPU for DF?
Post by: Putnam on July 06, 2018, 06:15:40 am
I don't think DF does much with floating point numbers, so integer performance is more important.

Just curious what makes you say this?

there aren't many floats in the raws and  from what i recall anything represented with divisors tend to have actual written out divisors-as-integers in the memory. temperature is a fixed point rather than a floating point (i.e. 32 bits for each side of the'decimal' [well, binary] place); in fact, looking through df-structures, it only uses floats in 1. graphics and 2. trigonometry, and the latter is all precalculated
Title: Re: Best CPU for DF?
Post by: Musaab on July 06, 2018, 07:05:24 am
my i7-7700k seems to be doing pretty well.
Title: Re: Best CPU for DF?
Post by: Rose on July 06, 2018, 07:40:29 am
I don't think DF does much with floating point numbers, so integer performance is more important.

Just curious what makes you say this?

there aren't many floats in the raws and  from what i recall anything represented with divisors tend to have actual written out divisors-as-integers in the memory. temperature is a fixed point rather than a floating point (i.e. 32 bits for each side of the'decimal' [well, binary] place); in fact, looking through df-structures, it only uses floats in 1. graphics and 2. trigonometry, and the latter is all precalculated


Even the physics uses fixed point math.
Title: Re: Best CPU for DF?
Post by: Devast on July 06, 2018, 08:30:00 pm
I love these threads even if they are often remade every 9 months. (maybe make a sticky?).
I wonder if having many dwarfs on a 2x2 would be comparable to few dwarfs on a 8x8.
Title: Re: Best CPU for DF?
Post by: Putnam on July 06, 2018, 10:45:28 pm
I love these threads even if they are often remade every 9 months. (maybe make a sticky?).
I wonder if having many dwarfs on a 2x2 would be comparable to few dwarfs on a 8x8.

We can actually determine this with some simple math.

As the amount of dwarves go up, the complexity of pathfinding increases quadratically, and the same is true for fort extents:

(http://quicklatex.com/cache3/e9/ql_388e98c50474a8129ff480e156d086e9_l3.png)

However, in practice the effects are very unlikely to be equal, and I would guess that number of dwarves causes FPS death much more efficiently due to how few places the dwarves will actually path.
Title: Re: Best CPU for DF?
Post by: lethosor on July 08, 2018, 11:46:53 am
Did you come up with that yourself, or is the graphic from somewhere else? In particular, I find the dwarves^2 term hard to believe. Paths are usually computed only once per trip and then cached, and other units occupy relatively few map tiles, and they don't block each others' paths. Even if they do meet at the same time, some units simply lie down when that happens. At most, adding another unit requires computing an additional path for just that unit occasionally - it isn't slowed down by every other unit on the map.

Also, fort x/y/z dimensions are constant - I'm not sure why you dropped the z term. Paths are also influenced by tile properties indicating which groups of tiles are actually connected (see DFHack's "pathable" and "gui/pathable" tools), so they're restricted to much smaller sections of the map to begin with - DF knows almost instantly if a path can't be found between two locations.
Title: Re: Best CPU for DF?
Post by: carewolf on July 09, 2018, 12:11:41 pm
What you need is fast memory. So look for CPUs that can do quad-channel memory and install four identical memory blocks on it. Or if you already have a machine, make sure you have the memory fully upgraded.
Title: Re: Best CPU for DF?
Post by: carewolf on July 09, 2018, 12:19:00 pm
In continuation. If you play from a laptop, make sure it uses real DDR memory and not slow low-power memory like LDDR3. If it is not written anywhere explicit, you can check what the top RAM configuration is, a laptop using slow mobile ram maxes out at 16GB, where laptops with desktop memory can go much higher.
Title: Re: Best CPU for DF?
Post by: Putnam on July 09, 2018, 10:47:22 pm
Did you come up with that yourself, or is the graphic from somewhere else? In particular, I find the dwarves^2 term hard to believe. Paths are usually computed only once per trip and then cached, and other units occupy relatively few map tiles, and they don't block each others' paths. Even if they do meet at the same time, some units simply lie down when that happens. At most, adding another unit requires computing an additional path for just that unit occasionally - it isn't slowed down by every other unit on the map.

True, I was wrong

Also, fort x/y/z dimensions are constant - I'm not sure why you dropped the z term.

I dropped the Z term because Z is indeed constant--when you consider a generalized fort, though, X and Y can be anywhere from 1 to 16.
Title: Re: Best CPU for DF?
Post by: carewolf on August 24, 2018, 05:49:29 am
Following the theory here I upgraded the memory in my PC. It has a quad-channel CPU, but I only had two memory modules, after upgrading my fortress went from 20-30FPS to 40-60FPS