bookmark

Building a High Performance Text Editor – Will Bond


Description

I think a fair number of these questions are implicitly asking how we make Sublime fast. The answer is probably more mundane than most people expect.

At our core, we do less.

Our codebase is full of purpose-built code that does exactly what we need it to, and no more. I think this has been a combination of intentionally pursuing the simplest solution, and the fact that Jon built Sublime Text by himself for the majority of its existence. As the product has matured and we’ve added more engineering resources, we’ve tried to continue walking the balance of making the codebase more robust, while continuing to pursue simplicity.

Sublime Text is written in C++. I could talk about how we avoid exceptions, use move semantics, and how a bunch of our code looks rather like C. These aren’t why Sublime products are fast, but they contribute some. Choosing the right data structures is important, yes. Surprisingly, a vector is more often the correct choice than I would have originally presumed. Our code pre-allocates vectors to their final size. We use memory arenas and intern strings. We pay attention to struct padding and use contiguous memory allocations for improved cache locality.

You’ll probably notice there is an overarching theme. We use less memory. We allocate fewer times. We invalidate the cache fewer times. We do less work. In reality, we have the user’s machine do less work. Sometime we end up doing more work, to chase that goal. Yes, we profile things to improve performance, but the little decisions add up!

Preview

Tags

Users

  • @bshanks

Comments and Reviews