llvmpipe: high address space consumption right after initialization which increases with CPU core count
With the help of @axeldavy, we've discovered that llvmpipe allocates larges chucks of virtual address space right after initialization, which increases with the available logical CPU cores the system has. Gallium-nine always initializes llvmpipe at start-up to use it for certain d3d functions and that causes problems with 32-bit games (99% of d3d9 games) running out of address space and crashing on high core-count CPUs.
For example, the game
Dragon's Dogma: Dark Arisen is heavily affected and is unplayable on high core-count CPUs on gallium-nine as a result. Here are some numbers of VA usage on a 16 thread CPU and on the same CPU with all but 4 logical cores disabled:
16 threads: 3900MB (frequent crashes)
4 threads: 3200MB
16 threads + LP_NUM_THREADS=1: 3200MB
16 threads + patch to disable llvmpipe in nine : 2900MB
The address space cost of llvmpipe with gallium-nine can also be reproduced without the involvement of wine with the Xnine triangle samples (Makefile can be modified for 32-bit builds).
Address space usage for the
triangle_SDL sample 32-bit build:
16 threads: 930MB
4 threads: 500MB 16 threads + LP_NUM_THREADS=1: 600MB
Now, while llvmpipe's address space usage isn't a problem for 64-bit applications at all, for 32-bit apps and gallium-nine it's the difference between perfectly playable games and just crashing - and the problem is only going to get worse the more CPU threads are available, it seems. I think @axeldavy has some ideas to work-around the problem from nine, but we thought it might be worth hearing if there are ideas to limit llvmpipe's address space usage for 32-bit builds for within llvmpipe itself.