User reported that JSNES on OS X 10.6 gets around 20FPS on Megaman. I can reproduce this on my MBP, getting around 30FPS without sound and 25FPS with sound. Chrome gets 50+fps either way. Shark profile is suspicious, might be something obvious, so we should try and investigate this before 4.0. 19.2% 19.2% XUL js::PropertyTable::search(long, bool) 2.8% 2.8% XUL js_GetProperty(JSContext*, JSObject*, JSObject*, long, js::Value*) 2.7% 2.7% XUL js_SetPropertyHelper(JSContext*, JSObject*, long, unsigned int, js::Value*, int)
9 years ago
blocking2.0: --- → final+
It looks like JSNES creates a ~61KB array and then sparsely/lazily initializes it. Our heuristics slowify this almost instantly. Dumb idea is to just not slowify arrays <= 64KB. With this patch JSNES runs fast again. Another idea would be to make the heuristics take into account both length and capacity, since I'm assuming if someone creates an Array(X) they intended a dense array, even if they first set slot X-1. But I don't know much about the original heuristics, what they were measured for, etc, so any knowledge on this is appreciated.
Attachment #493831 - Flags: review?(gal)
Comment on attachment 493831 [details] [diff] [review] heuristic change This heuristics is super brittle and may mess with peacekeeper so take a look at that.
Attachment #493831 - Flags: review?(gal) → review+
Hmm. Do we have any idea why search() is being so expensive? Are we just doing lots of calls, or are we ending up with a lot of collisions, or both?
Audio generation in jsNES seems to be very inefficient (slows down fps a lot). My emulator "GameBoy Online" doesn't seem to have this problem, so the audio code in jsNES needs to be looked into some more for bad algos.
Yeah, enabling audio seems to be a consistent 4-5fps slowdown. It seems like it's copying one of these slow arrays extremely frequently, much moreso than with audio disabled. Anyway, I tested on Friday and this patch seemed to lower the Peacekeeper score by about 100 points (out of ~6,000). Unfortunately I can't find any reasoning behind the old heuristics and neither the new heuristics nor the bug where they were introduced cite Peacekeeper problems. I'll try to get a shell test case for both problems later this week.
On my desktop, I currently get 60FPS on this site, and 45-50fps on my MBP. That puts it in the range of playability, which I think is enough to unblock this, and probably RESOLVED as well. The likely cset for changing the heuristics was bug 603318. The post-4 solution for getting this to perform really well, consistently, is probably bug 586842.
Status: ASSIGNED → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.