TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Bit-twiddling optimizations in Zed's Rope

168 点作者 misternugget7 个月前

12 条评论

rgrmrts7 个月前
I really like all the blog posts and videos the Zed team has put out, thank you if you’re reading this!<p>Unrelated to this specific post I’m such a fan of Zed. It’s the first feature complete text editor in recent memory that I’ve truly enjoyed using (i.e. it stays out of the way, is really fast, feels well engineered). I’m coming to Zed after years of Emacs which I still have love for but no longer feels like a competitive piece of software (it does not take full advantage of how good computers are today, e.g. gpu rendering or multicore). I really hope Zed stays a fast and lightweight text editor instead of becoming some bloated growth-at-all-cost VC ware (not that they’ve exhibited any signs of that happening). I’d also happily pay for Zed without a subscription based thing for access to LLM features (which I do not use).
评论 #42198366 未加载
benreesman7 个月前
I really want to admire the Zed folks even though they are a new faction in the editor wars where I’m an emacs guy: they take mostly all the things I care about seriously.<p>The are serious about local vs. remote vs. shared. They are serious about hardware acceleration because they care about users who type fast and edit big files. They care about real computer science on how to push the current hardware to serve the user, rather than treating the hardware as a crutch to give the user a slightly worse experience at a fraction of the development cost. They care about code highlighting the snippets on their blog like very similar to the default Zed theme.<p>These are cool, serious people. If they give me emacs key bindings with full paredit-everywhere, I might switch my daily driver.<p>And this is about using modern SIMD-style stuff, branch less stuff, Lemire stuff in a modern and relevant context. Other commenters have pointed out that you can do the mask or popcount better with intrinsically, and yeah, but they probably know that, and B. They got the massive win, the remaining factor of K on the pop count is coming.<p>Long Zed.
eviks7 个月前
Why not store just a small u8 count of newlines in a chunk instead of their u128 positions and then only loop through the last chunk for precision?<p>You don&#x27;t need information about the position of newlines in all the chunks located before the one your offset lands on
评论 #42201548 未加载
dzaima7 个月前
SIMD can work quite well here too - with 128-bit SIMD (available on both baseline x86-64 and aarch64) this can be just ≤8 loop iterations checking for the newline character (each iteration counting the number of newline characters encountered, and a lzcnt on the last iteration), and similar for characters (assuming valid UTF-8, it&#x27;s a single comparison to test if a byte starts a new char).
dmitrygr7 个月前
<p><pre><code> &gt; &#x2F;&#x2F; Parallel bit count intermediates &gt; let a = v - ((v &gt;&gt; 1) &amp; (u64::MAX &#x2F; 3)); &gt; let b = (a &amp; (u64::MAX &#x2F; 5)) + ((a &gt;&gt; 2) &amp; (u64::MAX &#x2F; 5)); &gt; let c = (b + (b &gt;&gt; 4)) &amp; (u64::MAX &#x2F; 0x11); &gt; let d = (c + (c &gt;&gt; 8)) &amp; (u64::MAX &#x2F; 0x101); </code></pre> That &quot;parallel bit count&quot; is almost certainly slower than using two POPCNT instructions on a modern cpu. Should just call __builtin_popcount() and let the compiler do it the most optimal way. Luckily, people do this sort of thing so often that many modern compilers will try (and often succeed) to detect you trying this insanity and convert it to a POPCOUNT (or a pair of POPCOUNTs as the case may be here)
评论 #42199186 未加载
评论 #42198289 未加载
camel-cdr7 个月前
nth_set_bit_u64: wouldn&#x27;t that be __builtin_ctzll(_pdep_u64(1&lt;&lt;n, v)) with BMI2?
评论 #42199867 未加载
评论 #42198733 未加载
评论 #42200581 未加载
sapiogram7 个月前
Is there a way to adjust text contrast in light mode in Zed yet? The editor is unfortunately unusable for me, because of how washed out the colors are.
评论 #42200916 未加载
veltas7 个月前
&gt; Turns out CPUs are pretty good with zeros and ones.<p>I&#x27;ve been saying this a lot recently, that CPU&#x27;s are powerful 1-bit vector machines!
eliasson7 个月前
Does anyone know of any good presentations about the Zed architecture and internals around?<p>I know that they have some recordings from their coding session, but I am looking for something more overall.
m1keil7 个月前
This is all really cool, but I just want soft wrap to be fixed
Am4TIfIsER0ppos7 个月前
&gt; opacity: 0;<p>&gt; filter: blur(1px);<p>Wonderful styling!
ramon1567 个月前
Isnt the tab example wrong? Id assume it to be<p>aa -&gt; -&gt; bb -&gt; -&gt; bb<p>It only takes up two spaces, after all