Posts tagged "Performance"
Some people reported performance issues in my games recently. After debugging I found that there is indeed a serious performance bug in some situations. For example, viewing the standings page and auto playing a season took 3x as long as it did a couple weeks ago. That's pretty bad!
After looking in my past commits to identify exactly when the slowdown started, I found it happened when I upgraded @rollup/plugin-commonjs from version 21 to 22. That's a package used in compiling JS for production. Annoyingly, it's only used in production mode and not in dev mode, which makes it harder for me to notice a bug like this. But for this package to cause a slowdown is strange... it feels more like something that should either work fine or completely break, not cause a performance issue. So while I could stop here, switch back to the old version, and call it a day... let's go further.
This post has nothing to do with basketball or sports or video games. It's just about some technical details that helped me make Basketball GM run faster. If you're interested in that, keep reading :)
This probably won't be noticeable unless you have played hundreds, or even thousands, of seasons in the same league. I know most people don't do that, but some do. And for those who enjoy BBGM so much that they play thousands of seasons, I feel that I am obligated to make things work well for you.
Things still aren't perfect, but they're better. For example, viewing the Hall of Fame in a league with 3000 seasons played used to take about 5 minutes on my computer. Now it takes 2 minutes. The performance increase was by denormalizing part of the database, allowing an N+1 query to be removed (getting player stats for each of N players). With a relational database that could be done with a join, but BBGM is built on IndexedDB which does not support joins. Humorously, this part of the database was originally denormalized, and I had only normalized it because that improved performance. But after Project Iversion, normalization is actually worse than denormalization in this case.
Basketball GM 4.0 was released a week ago. It made game simulation about 10x faster. After releasing it, I was very curious how players would respond. If they played the same amount of time, they could simulate 10 times more seasons. Or they could play 1/10 of the time, but simulate the same amount of seasons. Or something in between. Or maybe they'd even change how they play, like focusing more or less on the details of the game.
Let's look at some numbers.
Basketball GM 4.0 technical details - caching, Shared Workers, IndexedDB/Promise interactions, Safari being a tease, McDonald's, and more
Google made me do it.
Basketball GM has always allowed you to open up the same league in multiple tabs, so you can easily view multiple different screens. This was originally implemented by running the entire game in each tab. Game data was always saved to disk via IndexedDB. And when an action resulted in a change to the data (such as playing a game, signing a contract, trading a player, etc), then a signal was sent to all other tabs telling them to update their data. This was kind of a crude approach, but it worked.
When life hands you lemons, make lemonade. Since Google decided to totally invalidate the tradeoffs I had considered when designing Basketball GM, I decided to re-evaluate. I came up with two ideas:
This is not an April Fool's Day joke! Basketball GM 4.0 is really here, and it's awesome. For those who haven't been following along, here are the biggest changes:
- The game runs ridiculously faster than it used to.
- It's so fast that it's actually playable on phones and tablets (iPhone/iPad support is pretty flaky still, but should improve in the near future).
- You can easily apply complex filters to tables.
I'll make another post with more technical details soon, for those who are interested in such things.
Thanks you everyone for testing the first beta! All of the bugs people found have been fixed. The biggest change from the first beta is that multi-tab play is back. There are two caveats. First, you can only have one league open at a time. I figure this is not a huge problem, but let me know if you often do have multiple leagues open. Second, it is a little slower than the first beta, but still much faster than it used to be.
Also, multi-tab play does not work in Safari, so you can either play one tab per league in Safari or use another browser.
With that being said, here's the link to beta 2, please give it a try. To make sure you're on beta 2 and not the original beta, look at the bottom of the page. It should have a date of 2017.03.24.1059 or later.
I'll make another post with more details later, but right now, the beta brings some good and some bad:
Good: Performance, performance, performance. Depending on your computer and browser, you will find it about 10 times faster. That is a lot.
Good: It works in Safari now, although it's not that well tested.
Bad: You can only open a league in one tab at a time. I do have plans to restore multi-tab play, but I didn't want to hold up the beta for it. And single-tab mode will be needed as a fallback mode in some browsers, so it will be good to test it. Please do give me feedback on this. If single-tab mode is horrible, I will prioritize multi-tab mode.
(Also, accounts don't work on the beta. They aren't supposed to. That's not a bug.)
Performance in leagues with many seasons has long been an embarrassment to me. It should be faster. And as of today, it's at least a little better. Game simulation is now a little slower in new leagues but significantly faster in leagues with many seasons. Although it might be about 5% slower in a new league, the performance improvements are pretty big in old leagues. For example, leagues with 50 seasons are about 25% faster. And that number keeps getting bigger with more seasons.
Now I'm not claiming all performance problems are solved. It still gets slower the longer you play, and that still sucks. But the rate at which it gets slower has just been decreased a bit.
After a long beta (thanks for testing!), the new version of Basketball GM is ready. All your leagues will be upgraded automatically. The main difference is that game simulation is about 20% faster. Additionally, there are some minor bug fixes (the NaN bug is finally gone, I think) and enhancements (real injury descriptions show in old box scores and uploading exported league files is much faster).
On the downside, Internet Explorer is no longer supported. If you're an IE user, you can export your leagues still. Then you have the option of switching to Chrome/Firefox or using an old version of Basketball GM. Hopefully IE support will return to the latest version eventually, but I'm not holding my breath.
On my computer, I can simulate a week of games in a new season in 20 seconds. For a league 20 seasons in, a week of games takes about 45 seconds. This is unacceptable, especially since I know that some people play literally hundreds of seasons in the same league.