question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extraocular framerate boosting

See original GitHub issue

Some of the most fps heavy features of TMPE are around junctions - priority signs, traffic lights, junction restrictions (enter blocked junction), etc.

Vehicle AIs need to use collision detection at junctions just like anywhere else. Which means they are also using vehicle grid.

Could we create a OcularGrid which is like vehicle grid but just contains flag per cell as to whether that bit of the map is in camera view? (Is there already something like this in vanilla game?) The existing vehicle grid “coordinate” could then be used to check against the ocular grid, minimising grid inspection overheads.

An ‘outer rim’ region could be defined where stuff that’s just out of camera view is treated as in camera view so that if the camera pans a little things on the periphery look more correct.

The OcularGrid would be recalculated whenever camera moves/tilts/zooms/etc, but would otherwise remain static.

We could then basically skip collision detection and all sorts of other stuff for junctions that are outside camera view. Vehicles would ignore (or just use significantly more basic computations for…) priority signs, traffic lights, junction restrictions and collision detection, and anything else that eats up CPU, when not in camera view.

To retain some sort of reality in terms of traffic congestion reporting, noise pollution, etc., the segments at those junctions would be heavily speed nerfed (in such a way to avoid affecting pathfinder) to compensate for the ignored computations at the junction. We already have speed nerfing architecture as part of priority signs tool (and possibly traffic light tool, especially if #666 is implemented) so it would just hook in to that.

The feature would be optional, via mod options setting, as some users would prefer to keep things as realistic as possible. But for people who want max fps with “good enough” simulation, extraocular framerate boosting could help.

EDIT: We also have simulation accuracy setting (currently missing from mod options) - that too could be greatly reduced for stuff outside of camera view.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
originalfoocommented, Feb 26, 2020

we could always use an extra set of hands 😃

1reaction
krzychu124commented, Nov 7, 2020

Test to check if simulation bottleneck fps is pretty simple and you already did it. Move camera to location with nothing to render but still not too far from moving objects (citizens/vehicles). If you stop simulation you should see fps boost, sometimes is little sometimes is significant. I noticed two issues. If you have big city with a lot of moving instances:

  • game uses up to 4 pathfinding threads, path requests are spread across threads to their internal queues. If all queues exceed 100 paths to calculate PathManager is trying to slow down simulation using this code:
Thread.Sleep((num - 100) / 100 + 1);

num is the max queue length of all PF internal queues, so each additional 400 queued path more slows down simulation by 1ms

  • render manager is reading simulation data -> needs to synchronize, so if your simulation speed (step clock) is lower than fps it’s likely to see slowdowns due to that synchronization. Not to mention that 4 busy PF threads also needs to synchronize with simulation (e.g. save found path)

A bit more off-topic: I did few experiments trying to figure out if we can add few more PF threads. Here the conclusions:

  • I don’t have super fast CPU(i7 3.2GHz (4c/8t)), so 655k test city stress my rig to about 90% CPU, GPU and full 16RAM usage (fps was okeyish, mid 30fps with “big booster”, probably max 15fps on full vanilla xD)
  • as a part of experiment I added one additional PF thread, so 5 in total. Game was considerably slower with big fps drops and simulation was lagging horribly, especially camera movement using keys lag on start and stop was about 1-2 seconds, because game had demand more than 100% CPU. On simulation pause game was still running 50% CPU because of processing queued pathfinds (about 10k in queue)

Summarizing, vanilla game needs 6 fast threads (1 render, 1 sim, 4 PF) and 2 for other less important stuff (audio, water sim, file monitor etc.)

p.s. contact me on Steam or TM:PE discord

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to improve your eye perception (visual frame rate, ...
1.Blinking · This is to exercise your eye muscles and increase their flexibility. This is quite a simple exercise but a good one....
Read more >
How many frames per second can the human eye really see?
What is the maximum framerate the human eye see? ... “[Games are] unique, one of the only ways to massively increase almost all...
Read more >
The ultimate guide to 60 fps frame rate conversion in 2022
Unlike the perception of increased image quality solely based on more megapixels, increasing the frame rate of your footage has a material ...
Read more >
Why your eyes and brain strongly prefer games at 60 fps
When it comes to gaming, higher frame rates are often perceived as better, even if it's not always clear why. New theoretical work...
Read more >
Dynamic Imaging of the Eye, Optic Nerve, and Extraocular ...
This work presents an MRI technique that enables high-frame-rate dynamic imaging of the ... per reconstructed image, increasing the temporal span per image....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found