158 points · by lopkeny12ko · 3y ago · 169 comments
I don't want to be that person who says "mrahhh a new CS graduate could have built Teams in 2002 and it would have been faster!" But I'm also like, whatever is stopping it from being faster, I can't imagine what that is from where I'm sitting!
I've built high-complexity, high-performance web apps, and while there are challenges (the smooth infinite scroll without any placeholders in the video was actually pretty slick), there are other things like 900ms to switch tabs and 9.1s to boot that are just really hard to believe (and those are the improved numbers!)
Some of it's probably back-end; Slack for sure has back-end performance problems, where the UI is snappy but then sits there and loads the conversation for several seconds (or has synchronization problems, or loads an old version of history, or...). And I can understand having some performance challenge here- these apps deal with huge amounts of data per-workspace. But also... it's very simple data. Mainly a series of messages, displayed in chronological order. That's one of the most straightforward possible things to optimize.
I'm just so fascinated. The HN commentary around this topic is usually lazy, but there is a genuine mystery here.
Edit: A light overview of the new version was posted below (https://news.ycombinator.com/item?id=35352521) but I'm linking it again here for visibility: https://techcommunity.microsoft.com/t5/microsoft-teams-blog/...
For example, speaking completely independently from the problem here but putting on my performance hat, I would expect that if we take all things as a given (“no major architectural changes allowed”) Teams should not take 10 seconds to start up to show UI. We know that the tech stack they’re using isn’t fundamentally that bad. This suggests that there is probably a handful of things they are doing that are low-hanging fruit but haven’t been identified yet. Once they find those and bring down the time to something more reasonable like a second things will get much harder for them to fix.
So I highly doubt the people driving this initiative are just "unfamiliar with how to improve their software's performance". Something else is going on here: maybe they were saddled with something so bad it could only be fixed so much, maybe there's some technical hurdle we're just not appreciating, maybe it's an organizational problem (this is my guess). But Slack has a similar problem, so I doubt it's the first possibility (the 1.0 of the app just happened to be botched). There's something going on here
Here's my wild uninformed guess: Teams has lots of features/integrations, and they're constantly expanding because it's in the limelight right now, so they've got too many engineers on it working on different features at the same time and not talking to each other enough. The system is now too sprawling to be considered (or optimized) as a whole, which means there's tons of redundancy and toes-stepping going on. Shipping the org chart, etc.
(Ask me where this vivid picture came from)
They started with Electron, and are now moving to WebView2. When the project started Edge was still not Chromium based (it was the IE fork) so they couldn't even use that.
"We always run at 60 fps, because if we finish the game, then try to optimize our way to 60, we'll never hit it."
>> This suggests that there is probably a handful of things they are doing that are low-hanging fruit ...
The Quake annecdote suggests the opposite. If I had to guess (from personal experience with web development), it's probably a million-billion little things that, when added up, make your whole project a slow, gelatinous pile.
That's not to say there's not also low-hanging fruit that might make switching between conversations take less than a second, but .. it should take .. like .. a short amount of time, like 16.6ms, including the network trip.
(note that a game running at 60 FPS does not mean that you get 16.6ms mouse-to-screen latency at all)
Then they aren't "engineers" yet. Engineers can figure out how to use a profiler and how to improve performance of their software. Calling themselves "engineers" while being unable to do so should be a signal to everyone in their circle that they're incompetent hacks. They should at least be honest and give themselves an appropriate title, like "apprentice" or "intern" or "novice" or "student".
> A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyse a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly.
I think all software engineers should be taught to be able to handle a profiler, poke around in a debugger, write a short correctness proof, and consider how an attacker might abuse the APIs they expose. I know a lot of people who are working to make this dream a reality right now. Until this happens, though, gatekeeping the definition of an engineer is inappropriate and does nothing to help improve the situation, because people are generally resistant to learning these things if you call them "incompetent hacks".
They don't?? If that's true, it's a pretty sad commentary on software engineering these days.
It's not just that Teams is failing at solved problems, it's also that they aren't using Microsoft's own SDKs and APIs themselves anymore. Windows has good fast UI frameworks and all that cool stuff like SuperBoost which can make app startup appear instantly. Why is nobody using it?
And there is no useful integration to speak of. Why do I need to re-upload an OneDrive file into Teams? The exact same file is already stored on the exact same server. Does nobody there know about the magic of SHA512?
And how come if the internet has a hiccup while I upload a file, I have to re-upload the whole damn thing? In 1980 we already had resumable uploads via FTP.
Oh and who's the vendor creating one of the best performance tracking and optimization tools? Microsoft themselves. Did nobody ever dare to run this in a proper Visual Studio?
Telegram does that wit just a handful of people.
But yeah I won't blame them not to use xamarin/maui.
> it's very simple data. Mainly a series of messages, displayed in chronological order. That's one of the most straightforward possible things to optimize.
When a company grows and add features that customers need, the data model has to grow with it. Queries necessarily become more complex.
I used to work at a big video sharing site. I wasn't there in the beginning, but I imagine the initial profile pages had code like
SELECT * FROM user_videos WHERE user_id = ?
Then some users said "hey, we want some of our videos to be private".So then the simple query became
SELECT * FROM user_videos WHERE user_id = ? AND privacy = ?
Then they said "ok, but I want people who are mutual friends to be able to see some just-for-friends videos".And then the query suddenly became much more convoluted. We started loading all of a users' videos in memory, then in-memory filtering, returning only the videos the viewer had access to (slow for users with thousands of videos).
Then some users came along with 30,000 videos and we had to abandon the in-memory filtering because we were getting OOMs, so we developed a hybrid system that could run queries either in-memory or in the DB depending on volume.
This is a trivial example (there are much more painful examples of data model bloat) but it illustrates the point: if you think it should be easy, you probably have an innacurate mental model of what needs to happen behind the scenes.
That's like saying that Chrome is a modern UI for what used to be Lynx. Those tools offer very different features, even if they share a rudimentary set of behaviours.
E.g., clicking the "emoji" window in Slack. I'll permit the custom emojis in the LRU emoji list to delay, but even the stock Unicode "text" emoji take palpable time to "load".
Now think about the average chat app like Slack or Teams. Those have a very different read-write ratio. Some things can be cached for long periods of time, but many other entities become invalidated quickly, and are subject to intricate permissions policies.
As for sharding, Slack uses Vitess: https://slack.engineering/scaling-datastores-at-slack-with-v...
Users don't care because Teams still basically functions and the performance problems are at most a minor inconvenience. As a result, organizations don't care because Teams is cheap and does everything they need it to. As a result, Microsoft doesn't care because dedicating dev resources to something which neither saves them money nor attracts more customers is a waste.
Microsoft employs many smart people and I'm sure Teams' performance could be improved by orders of magnitude if they wanted to. But why would they want to?
(And to reinforce my point, when the performance _did_ get so bad that people apparently actually started caring, Microsoft not only improved it but made a video advertising it. It's just that there's no incentive to optimize any further than is necessary.)
In my experience, the further up the org chart you are, the less likely you are to use Slack directly, instead deferring to assistants or at least only posting announcements periodically.
Ditto goes for Internal IT who I've commonly found never use these chat platforms instead deferring (correctly) to ticketing systems.
Those two groups are both the ones who would probably advocate for adopting these platforms yet they never use it in any regular sense so they don't feel the sharp edges
People definitely care. If you actually listen to them. They will tell you what a hot pile of slow garbage it is.
Presumably, Teams was so unbelievably slow that it crossed over to being an actual problem for customers and not just a mild nuisance. So Microsoft improved performance just enough to stop affecting sales. Is the performance _good_? No, it's still comically slow. But there's simply no incentive to improve the performance further.
When you work in orgs with hundreds or thousands of developers working at a breakneck pace churning out feature after feature for years, on a perpetual "sprint", your architecture tends to resemble a multi-layered bowl of spaghetti. A single button click may result in hundreds of database calls (maybe concurrent, maybe cached), or at a minimum invoke dozens of javascript packages in a Rube Goldberg-esque fashion to perform an action which should take a modern computer a single digit number of milliseconds, but instead results in 10 second load times. Sometimes people just completely forget about entire code paths, and then it becomes dangerous to delete since the persons(s) who wrote it either no longer work there, or got reorged and moved on.
There are absolutely people who care about software performance, but it isn't a priority because it usually doesn't make you more money, won't get you or your boss promoted (unless it saves money), and is difficult to maintain in the long-term given the pace of change in large codebases. When you do tackle performance problems, it's because you were absolutely forced to due to necessity. In certain domains it is also more important e.g. games, embedded systems, ML applications, etc.
One other thought, is that many developers today cannot build software from first principals, as they never learned how. Many only know how to build within the context of a browser environment, and think a "minimal" app is https://create-react-app.dev/ . That's not just me grumbling, it's how our industry works. You forget the layers below you, and build new ones, each generation forgetting most of what the prior knew. The result is giant bloated applications, and a normalization of slowness in software.
I still have hope for small teams of dedicated devs. Fast, coherent software gets written by tiny teams or single individuals.
I too am curious of what sort of... dynamics are going on internally. I blame Agile/Scrum lol.
Probably a few thousand features you have never heard of and will never see or use. And the vast majority of their customers will never see or use. But each one has one or two clients for whom someone decided it was vital at the time to implement that feature to please that client.
You can probably imagine one small feature that only one or two clients use that adds a very tiny, almost imperceptible amount of loading time. Now just multiply that by several thousand.
Seems like when you hire bean counters and MBAs, the incentive/value structure of your team/org/company changes for the worse.
Sounds like they just rewrote the whole thing from scratch, down to replacing Electron.
This is what you get when your developer team has only ever known programming through the lens of terrible tools and practices. They’ve probably never worked on good software before.
they replaced electron with a MS Edge Web View which is still running V8. I wouldn't say they rewrote it "from scratch"—that would be more like rewriting it in C#
Making software is not challenging. A CS graduate from 2002 could build Teams. And it would be faster! You can hire dozens of engineers based on whiteboard problems, throw them into a disjointed cacophonous open-plan work environment, give them arbitrary deadlines and 10 layers of middle management, and somehow, somehow, software will still be built!
There's no reason to streamline the architecture, or the workflow of the team. If the software is going to be made regardless, why bother? Just do whatever feels normal.
Contrast this with the engineers who built the Saturn V. I'm sure a lot of brainpower went into thinking about the overall architecture of the rocket, and how the teams would be structured, and how they would communicate. Tons of process.
Anyway, as a result of this lack of organization, software teams usually self-structure into a network of arbitrary mini-siloes. The way this works at FAANGs is you'll have the Foobar Core team, the Foobar Presence team, the Foobar Video team, the Foobar Audio team, the Foobar Notifications team, etc. etc. It's like microservices for teams. And they barely communicate (unless two of these teams are lucky enough to share the same corner of the same open-plan floorspace!)
Anyway, these mini-siloes ensure that there are lots of seams between modules, and no one can optimize across boundaries easily, without stepping on the toes of someone else's team. And unless customers are actually switching to other products, there's no political willpower to do that toe-stepping in the name of saving the product.
Maybe modern software is like that. Just a hundred small inefficiencies that don't look like much when benchmarked on an individual part of the stack but combine into a monster.
...I can't write CSS and nobody moans so why should web devs be expected to engineer software?
Architecture suffers, code health, and performance suffers. Silly things are done, but it's hard to see they're silly because it's hard to see the entire picture
Could you build it better from scratch rather then organically? Of course. And often that's part of the solution to these situations.
tl;dr Building software is hard, and its difficulty does not scale linearly with complexity. (And yes, Teams/Slack are complex, even if they "shouldn't be")
One way to test this...MSFT could open the Teams API and some 16 year old could try building a client.
You're not "starting Teams.exe", you are deploying a server and booting an operating system.
Seen in those terms, 9 seconds is actually pretty good.
Seen in more... sane terms, showing 1 KB of text after 9 seconds is about a billion CPU instructions needed per character.
Even React isn't all that slow. If you look at benchmarks you may be impressed by how quickly it can do some operations. It's consistently a bit slower than other frameworks, but not that far off. There are (big) React apps that are quite fast, too.
So writing performant applications with these technologies isn't impossible.
Yet a lot of apps built with them are slow. The fast ones are rare.
I don't know what it is yet (happy to be pointed somewhere), but I'm fairly convinced that these technologies have common footguns that encourage programming things in slow ways. I can imagine it being related to React's coarse-grained and easy mismanage reactivity and wonder how much of an improvement Solid is in comparison (it is also functional, but is built to always recompute as little as possible rather than saying "whatever, it's cheap", which React does).
It is absurdly slow compared to any compiled language.
> Even React isn't all that slow.
Yes, it is.
> I don't know what it is yet (happy to be pointed somewhere) [..]
It is using a web browser to show some text and images.
Correct me if I'm wrong, but on a 3ghz CPU (3bln cycles per second), there are 27 billion cycles per character for 1kb of text. Take into account that on any non-stone-aged CPU you've got probably 4-16 cores, and can do ~4-8 SIMD ops per cycle (at full clock rate), so at the limit we're actually talking .. something like _3.4 TOPS PER BYTE_ ..
SIMD is a little unfair, because virtually none of what an app like Teams does is amenable to vectorisation. If we allow SIMD, then we have to allow the GPU, and then we're talking about an entire different order of magnitude.
A decent last-gen GPU has something like 30 teraflops, so about 265 billion instructions per displayed character!
> SIMD is a little unfair
Yeah .. I agree, but I wanted to illustrate (to your point) just how much juice modern chips have.
But yeah, it is incredible when stuff used to load on single core 500 MHz CPUs.
Or that I had a full graphical desktop on a 20 MHz CPU once. And it really wasn't that different? Launcher of apps at the bottom, even, despite being a completely different OS…
Sounds about right and, actually, is quite a feat.
I just wonder how they went from "build a chat app with some filesharing built in" to "include everything and the kitchen sink and oh, in your own universe" kinda thing...
It's striking to try and imagine the relevance of the course to the average web programmer. Like a React developer is so far removed from these considerations that I'm not sure where he'd even begin to try and apply these lessons. That's crazy to me, that this stuff is what the computer is actually doing, and modern programmers' model of software development doesn't even have the concepts or language to relate to these ideas.
There's all sorts of room for optimization. Those familiar with 3D programming probably know the "use distance², not distance" to avoid needing to sqrt(), and similar tricks apply (you don't need to work in miles: e.g., you can convert the target distance to arc distance, and use that, which is what haversine speaks natively). We were also trying to get Go to inline some of the wrapper calls (so that we could work in more sane units, like lat/lng, and have a wrapper convert to, IIRC, radians) … but alas, Go only inline leaf functions, and the trig calls haversine requires basically meant we were never a leaf.
Also hit the uniquely human problem of: if you compute the query, you can spend infinitely long doing it: the right circle is fine if centered over Wyoming, but quite a problem if centered between NYC & Philly. (So as to overlay both.) If you don't detect the case, you'll time out, and users are unhappy. If you detect it and abort, users don't get data … and are unhappy. There's no way to win.
… then the "higher level" stuff knocks you down three pegs for trying to eek a few milliseconds out of haversine when you find out the protobuf library encodes the response slower than JSON, despite being binary. (But protobuf was written in Python, vs. the JSON library is in C. There's a C protobuf lib … but its own unittest segfaulted at the time. I hope it has been since fixed, but ugh.)
Also looked at our point type in Python. As you can imagine we alloc'd a few million of those, and the simple definition in Python of,
class Point:
__slots__ = ('x', 'y')
def __init__(self, x, y):
self.x = x
self y = y
contains three heap allocations, and not small ones either, for what can be done for 16 B on the stack in some languages.(And then we'd done some rather dumb things … which I see repeated a lot, not just at this job, like SQL databases with an ENUM column declared as VARCHAR, and the same string repeated forever and ever through the DB. All you needed was a SMALLINT, an ENUM if its supported…
And so much CSV.)
The back button in the new Bing DOES. NOT. WORK. and it's absolutely wild to me that this isn't talked about more. "Don't break the back button" is a trope in web development.
I genuinely thought Bing was a better search engine than Google and tried switching my default (this was just before all the ChatGPT stuff). After a week I just couldn't handle it and had to revert back to Google
Is it? I’ve been having an inner rant about how modern web ignores the back button.
Reddit and YouTube completely breaks the back button. Click a video, click back and a completely new list of videos are shown. Same for Reddit.
On top of that almost every news site inject their front page behind the article you clicked so back keeps you on their property.
Clicking back on Facebook gives you a new feed.
Also Google Shopping doesn't let me change my search terms: I type something new, press enter, and nothing happens.
And Google Search has been showing the wrong dates for Reddit threads, showing older posts than the time range I selected.
All of these issues have shown up only in the past month or two (maybe massive layoffs lead to massive mistakes?).
No! I clicked back for a reason, respect that!
Technically I blame mainly platform bloat and everything being a webview pretending to be native app these days.
But from a human perspective, younger developers never experienced how snappy desktop stuff was back then. So what seems 'ok' or 'fast enough' to them is just how sluggy stuff is, in average, nowadays.
>> If you were making a parody video, you would imagine it would look exactly like this video - like joking about how people would be proud of these timings. But IT'S REAL!
Also, I just tried the boot up example and old teams finished loading faster than the videos new teams.
Cynicism about modern software aside, I’m glad to see Teams, an app that many of us are forced to use by our employers, improve performance. It was desperately needed.
I don’t think this type of performance is some kind of horrid modern software epidemic, it’s just Teams being a garbage application that was thrown together to try and answer to Slack.
It is certainly aesthetically displeasing for such a relatively simple product to be slow, but it often makes business sense that it's not a top priority.
The real problem is just the general practice of how software is developed now. If we lived in a world where software development was sane, it would be possible to prioritize speed of development and cut some corners to ship faster, and get a result that is somewhat slower but not ten whole seconds to start up slow.
I watch her screen sometimes to see the differences in our workflows. It is incredible the high latencies and low speeds she has come to view as acceptable in application performance. 2-3 seconds to toggle a menu that’s toggled 30 times in a day; 4 seconds for a small file list update that is performed regularly; tabs in Edge frequently hanging; on and on this goes.
Just sad, really, especially when we have a half gig connection going both ways. The work being performed (and the features designed to do it) should not be seen as resource heavy… because it isn’t. It’s the same exact bs that was done on computers in corporate settings 20 years ago. We’ve added collaborative editing and auto save as defaults - that’s the extent of the difference.
How did we get here?
Software optimization on the whole would be a lot better off if developers took a lot more time to think about the scale of the products they work on and if users refused to put up with software and systems that don't respect users' time and agency.
If someone wants to calculate the lifetimes lost to Windows Update, I'd be interested in knowing how it compares to historical wars.
Sometimes good old tools beat the new shiny turd.
I had to do this once for a large piece of JSON that ballooned quite large when loaded into RAM. But in my case I could wait until after json.loads to do the interning; but I think you can do it on the fly with object_hook or object_pairs_hook.
Alternatively, Rust+Serde & doing as bare-bones a computation to get it working, again with an eye out to whether the decoded form will fit. (Hopefully, since Serde'ing into a struct should make the keys 0 bytes, essentially, but there would be some memory lost for pointers and the like.)
Alternatively, a 20 GiB swap file.
Naturally I was curious what such a shell script consisted of, but most tools choked on it. IIRC, even vim and less couldn't open it, but emacs could.
https://stedolan.github.io/jq/manual/#Streaming
You have to rewrite your criteria, but it's what's allowed me to process huge json files without issues.
Frankly, if someone says that to you and they're not shipping software that runs locked at 60fps, fuck them.
I keep a couple old laptops kicking around for perf testing on and, can confirm, I routinely find perf hiccups that when added together would create a huge amount of debugging work.
While I like doing dev with a threadripper & beefy GPU, I certainly support the idea of having crappy, old test machines around.
[1] https://twitter.com/cmuratori/status/1640827575437250561
As the speed of computers increases, software speed remains pretty much the same. Teams is an Electron app, I think, so the whole thing needs a huge baseline in order to work.
Being proud of a chat app now only using 500MB instead of 1000MB is odd.
The problem is they've only cared for like, the last 3 years, and everyone was enslaved by that "premature optimization is the root of all evil" quote for the last several decades, while blaming "complexity" for slowness.
Direct link to “new teams vs old teams”: https://youtu.be/CT7nnXej2K4