Poor First Run Performance

When I start my application for the first time after a reboot, I get poor performance and the Nvidia driver reports 250+ MB of evicted memory. However, if I kill my app and restart, then the performance is much better and the driver doesn't report any memory eviction. But, there is only 1.5 MB free on the GPU. Both runs are identical.

I tried removing the on-disk shader cache, but subsequent runs were still ok.

Obviously, I have to fix the memory eviction, but I wonder why the first run is different from subsequent runs. Is the driver caching a file that gives it memory information about my app? Is there anything else that could explain this?

Obviously, I have to fix the memory eviction, but I wonder why the first run is different from subsequent runs.

Hmm... Not sure if the shader cache thing is related here, though it might be. If so, maybe its causing a different timing and a different ordering of GL operations (?) The first run it's going to take longer because the disk cache is cold.

What happens if before the first run you forceably read the on-disk shader cache into the memory cache. For instance, on UNIX/Linux, assuming sh/bash and that you haven't relocated where your shader/kernel caches are (you may have, so plug in the appropriate path here):

Code :

find ~/.nv -type f | xargs cat > /dev/null 2>&1

Or just disable the shader cache to force the same behavior every time (i.e. slow recompiliation and reoptimization).

Also, related to the memory overrun scenario, might validate that you're creating all your big framebuffer and renderbuffers first, and that these are not being freed and recreated later, potentially creating odd-sized holes to fill.

Hmm... Not sure if the shader cache thing is related here, though it might be. If so, maybe its causing a different timing and a different ordering of GL operations (?) The first run it's going to take longer because the disk cache is cold.

That's what it turned out to be. It was shader cache related. When the shader cache is already on disk, apparently the driver can prevent the eviction.