[mac performance] Setting a map beacon causes extreme lag
complete
observeur Resident
After setting a beacon on the world map, here is what happens : while i am standing still, (not moving at all), the animations around are smooth according to the displayed fps (120fps). but once i try to look around, the viewer becomes so slow it becomes unusable. then if i stop looking around it goes back to smooth animations.
Log In
This post was marked as
complete
Atlas Linden
tracked
observeur Resident
Atlas Linden I've been investigating this issue a bit deeper, and i wanted to share my observations which might lead to a solution. I identified the code responsible for this, it's in lltracker.cpp in the drawBeacon function. This function uses a triangle strip to render the beacon, and this leads to serious performance drop (only when moving or looking around) on apple silicon vs more modern rendering methods used in the word. To improve things, i lowered the BEACON_VERTS constant from 256 to 8 (which lowers the number of triangles to render the beacon, with has not much negative impact on the rendering, as i think the higher complexity is used to render a finer simulated fog effect). it still has a strong impact on the fps, but it makes it way more manageable. As a side note ... i suspect, but that only a guess, that it might also explain the same performance issues with the 2D UI elements causing a slow down when being moved).
EDIT May 23th:
I have a better understanding on the issue now. I actually fixed the issue in this particular drawBeacon function in my own build. There were a few optimization mistakes in this function, the worst one being, the triangle strip draw function being called inside the loop, while it should actually be called outside of the loop (otherwise using a triangle strip doesn't really makes sense ..). It appears that the opengl driver on apple silicon is specially sensitive to this. One sure thing is that multiplying opengl draw calls has an enormous impact on the apple silicon chip. it's possible that on other gpus, this kind of error is automatically fixed /optimized by the driver ? i don't know.
So while my optimizations fix the issue, it remains 2 observations :
I proceeded to the tests in a very light/optimized sim, with very high fps, with quite low settings, to be sure there is no "interference" in the results.
1) looking around will still impact the fps, specially if it was very high in the first place ( without the fix, it went from 500fps to around 5fps , with the fix it goes from 500 to around 100fps).
2) if i disable the displayed label (in the code) the fps when looking around goes up to 150 to 200fps (from 500). This means each draw call (like the one here made by the llfontgl class) will impact the fps.
conclusion:
This beacon issue reveals some other potential performance related issues on apple silicon, mostly related to draw calls.
Last thing: I'd be happy to share the optimized code, but i wouldn't know how to do that. I'm not familiar with git / commits (for now) and i don't even know if you accept participation from "freelancers".
Thank you for reading :)
Atlas Linden
Thank you observeur!
This comment has been copied to the linked GitHub issue here: https://github.com/secondlife/viewer/issues/999
If you're interested in becoming familiar with GitHub and contributing your own code, please see the following pages for more info: https://wiki.secondlife.com/wiki/Feature_Contributions
observeur Resident
Atlas Linden You are welcome, and i'm going to see the proper way to submit code modifications, thank you for the links.
VvDrakevV Resident
Atlas Linden Is there any kind of update on this? Its a huge quality of life issue. It makes things like aviation or driving difficult if not impossible for users on Apple silicon...
observeur Resident
VvDrakevV Resident I made a proper fix for it for a 3rd party viewer that is a fork of SL Viewer. so now i get to figure out how to commit this to secondlife. I'm going to try to do this today.
EDIT: I managed to do a pull request to secondlife viewer, with some help since i'm really not familiar with git. I hope the changes will be accepted.
As a temporary workaround you can set this debug option to false : renderTrackerBeacon
Additional note: I tested this on Windows and Linux as well, and those also benefit from it. The fps on non patched viewers is dropping, specially on NVidia cards (compared to AMD where it drops but .. less), while on a patched viewer it's not dropping at all (while on Mac it still drops with the patch but not to extremely low values, so the viewer remains responsive).
Atlas Linden
Thanks for filing this observeur!
We were able to reproduce this and the issue will be imported in GitHub
observeur Resident
Atlas Linden
Thank you !
VvDrakevV Resident
Atlas Linden
Seeing this on newer Macs as well.
CPU: Apple M3 (2400 MHz)
Memory: 16384 MB
observeur Resident
I figured the strange origin of the issue: the beacon !
So, i can reproduce the issue at will by opening the world map, clicking somewhere on the map to make a beacon. The viewer becomes extremely laggy as soon as i look around. (Walking forward is quite smooth) .. and if i click on "hide beacon", the viewer goes smooth again. This seems to be specific to some mac platforms, like mine (Macbook Pro M2 PRO).
Also..
I would add that it "might" be related to the overlay, i mean the 2D part of the display, as i noticed many performance issues related to the ui elements and how severely they impact the viewer performance. For instance, showing the statistic window that shows the fps will actually divide de fps by 2 (from 120 to 60 .. ). Moving a window also impacts performance by a lot. overall any 2D element seem to cause issues on my machine. (also see my post about the spell checker causing lag to extreme lag in text editors).
Friends with intel mac don't seem to suffer from this , or at least they don't perceive it the way i do on this Apple silicon machine.
The issue is barely existent on windows (i say barely because it does lower the fps just a little bit but it's not really perceptible).
As i'm testing multiple viewers, i can also say the Megapahit viewer that is a fork of SL Viewer compiled for arm has the same issues, while showing an overall boost of performance (up to x2) because of the native code. (so we can imagine it's not related to Rosetta). As for Firestorm latest beta, the same issue with the beacon is there. and on Alchemy, it's much less perceptible .. so they must have found and modified something .. that would be interesting to see. (however Alchemy, while showing good fps, has some micro stuttering that makes it not as smooth as it should on this test machine).