Live data from Hacker News

Xi-Editor Retrospective

raphlinus.github.io

71–80 of 162 posts

Re: Xi-Editor Retrospective

#71
post #29

This was solving problems nobody really has, so its fate was predictable. Here's what I think could take off like a rocket: a VSCode-like experience that runs completely in terminal, and therefore does not require a "remote" of any kind. Better yet if it takes most of the same plugins, to reuse the immense amount of work people have done there (and are not going to re-do for some hotshot new editor). Note how none of…

I don't want to speak too much for raphlinus here [1], but I don't think it was ever the goal to make an editor that gets a lot of downloads like a startup pitching a product. All the things you've listed are non-goals, or at least lower-priority goals.

The goal was to make an editor based on sound technology principles, and that included investigating said technology principles. It turned out some of those principles were bad ideas, and that's that.

[1]: My involvement with xi was limited to being part of conversations he had about rendering performance on Windows in the winapi crate's IRC channel.

Re: Xi-Editor Retrospective

#72

Earlier quoted context omitted.

This is probably already implemented if it does exist, but I know with a bunch of fixed text strings you can create a NFA/trie thing using Aho-Corasick. Does such a thing exist for regexes (specifically: one that can match "all of them at once"), and is it used for the fast regex engine?

You will probably find https://github.com/BurntSushi/aho-corasick/blob/master/DESIG... good reading. I believe captures get in the way of using the fastest of these NFA-style techniques, though. There's a comment from burntsushi to this effect in: https://lobste.rs/s/fq8uil/aho_corasick ETA: Heh, I'm amused to find the latter link to be another point in what seems to be an extended conversation between Andy Chu and t…

Ha yes, as far as I remember, my claim about Aho-Corasick had validity, but I definitely learned a bunch of things from that thread.

If you scroll way down you will see a benchmark I did for the "constant string" problem.

So you can see that re2c does scale better from 1000-6000 fixed strings than either RE2 or rust/regex. But I uncovered a whole bunch of other problems, like re2c segfaulting, the output being slow to compile, egrep blowing up, the non-regular heuristics of "grep" playing a role, etc.

https://github.com/oilshell/blog-code/blob/master/fgrep-prob...

    # grep is faster than both fgrep and the "optimal" DFA in native code
    # (generated by re2c).  I think grep is benefitting from SKIPPING bytes.

    # All times are 'user' time, which is most of the 'real' time.
    #        re2c compile | re2c code size | re2c match time | ripgrep time | RE2
    # n= 100         7 ms          11 KiB           1,566 ms         687 ms   1,398 ms
    # n=1000        66 ms          57 KiB           2,311 ms       1,803 ms   1,874 ms
    # n=2000       120 ms          93 KiB           2,499 ms       3,591 ms   2,681 ms
    # n=3000       204 ms         125 KiB           2,574 ms       5,801 ms   3,471 ms
    # n=4000       266 ms         159 KiB           2,563 ms       8,083 ms   4,323 ms
    # n=5000       363 ms         186 KiB           2,638 ms      10,431 ms   5,294 ms
    # n=6000       366 ms         213 KiB           2,659 ms      13,182 ms   6,397 ms
    # n=47,000   2,814 ms
    #
    # NOTES:
    # - egrep blows up around 400 strings!
    # - RE2 says "DFA out of memory" at 2000 strings, because it exhausts its 8 MB
    # budget.  We simply bump it up.
    # - at 48,000 words, re2c segfaults!
    # - At 10,000 words, GCC takes 36 seconds to compile re2c's output!  It's 74K
    # lines in 1.2 MB of source.
I meant to blog about this but never got around to it ...

As mentioned, I think you would uncover similarly interesting things by benchmarking Sublime-like workloads with re2c's capture algorithm. They use some fundamentally different automata-based implementation techniques.

Re: Xi-Editor Retrospective

#73
post #29

This was solving problems nobody really has, so its fate was predictable. Here's what I think could take off like a rocket: a VSCode-like experience that runs completely in terminal, and therefore does not require a "remote" of any kind. Better yet if it takes most of the same plugins, to reuse the immense amount of work people have done there (and are not going to re-do for some hotshot new editor). Note how none of…

I don't want to speak too much for raphlinus here [1], but I don't think it was ever the goal to make an editor that gets a lot of downloads like a startup pitching a product. All the things you've listed are non-goals, or at least lower-priority goals. The goal was to make an editor based on sound technology principles, and that included investigating said technology principles. It turned out some of those principle…

This is a bit complicated. My main goal was to make something good. I would have liked it to be so good that lots of people would use it, but I wasn't optimizing for popularity, and, indeed, had I been, I would have done quite a few things very differently.

Also, thanks for those early winapi discussions. The attitude of Rust towards winapi is one of the early reasons I started seeing Rust as being viable for actually building GUI.

Re: Xi-Editor Retrospective

#74

Earlier quoted context omitted.

Author of syntect here: This isn't why TextMate/Sublime/VSCode/Atom style regex parsing is slow. The main reason is that the parsing model is applying a whole bunch of unanchored regexes to the unparsed remainder of the line one after another until one matches, then starting again for the next token. This means each token parsed can require dozens of regex matches over the same characters. I implemented a bunch of ca…

This is probably already implemented if it does exist, but I know with a bunch of fixed text strings you can create a NFA/trie thing using Aho-Corasick. Does such a thing exist for regexes (specifically: one that can match "all of them at once"), and is it used for the fast regex engine?

I replied elsewhere, but to answer more concisely: that's exactly what "regular language" / automata-based engines do, as opposed to Perl-style backtracking engines (which are more common).

Here are hundreds of regexes OR'd together so the lexer reads the input exactly once, not 100 times:

https://www.oilshell.org/release/0.8.pre6/source-code.wwz/_d...

And in the lobste.rs thread linked below, I was basically saying for all practical purposes you can ignore Aho-Corasick and use the more general regex version. Since the "fgrep problem" (fixed strings) problem doesn't involve captures, you should get a DFA that runs at the same speed either way. (I don't recall if the compile time was longer but I don't think so, it is buried in the thread probably :) )

https://news.ycombinator.com/item?id=23665569

Re: Xi-Editor Retrospective

#75
post #32

The assertion that gpu is required for good text rendering caught me off guard. I can't claim it is wrong, but it does feel like it should be wrong.

I sure wish it were wrong. If macOS’s text rendering primitives could be used asynchronously or concurrently the situation would be significantly better. I’ve spent probably hundreds of hours trying to make it fast but I’m convinced it’s only possible if you work at Apple (as they have done quite well with Terminal by using lots of hacks that are unavailable to me)

Re: Xi-Editor Retrospective

#76
> it might be able to safely save the file, but you can also do that by frequently checkpointing

It is always amazing to discover niches where the conceptual and practical power of logging has not yet penetrated.

Re: Xi-Editor Retrospective

#77

Earlier quoted context omitted.

My first test of any text editor is to open something like 4-gigabytes log file with one gigabyte line. If editor works fast, it's good. So far very few editors pass this test, so most are not suitable for general use, only for some niche use like editing tiny text files.

I am curious which editors pass this test, as pretty much everything I have tried chokes on long lines, even things like nano, vim, Sublime Text…

I read the previous comment as sarcasm...

Re: Xi-Editor Retrospective

#78
post #58

Earlier quoted context omitted.

Author of syntect here: This isn't why TextMate/Sublime/VSCode/Atom style regex parsing is slow. The main reason is that the parsing model is applying a whole bunch of unanchored regexes to the unparsed remainder of the line one after another until one matches, then starting again for the next token. This means each token parsed can require dozens of regex matches over the same characters. I implemented a bunch of ca…

The main reason is that the parsing model is applying a whole bunch of unanchored regexes to the unparsed remainder of the line one after another until one matches, then starting again for the next token. This means each token parsed can require dozens of regex matches over the same characters. Hm but why can't you just OR them together? That is perfectly fine with a regular language engine. For example, I OR togethe…

Two reasons: captures, and it needs to know which of the regexes matched. I meant to but forgot to mention in my original comment that the reason Sublime's built-in highlighter is the fastest is they wrote a custom regex engine which basically does the equivalent of or-ing them together but unlike all other regex engines handles captures and information about which one matched properly while doing so. The custom engine doesn't do backtracking and it falls back to Oniguruma for regexes that use fancy features. So yah it's in theory possible you just need to write a custom regex engine to do it.

Re: Xi-Editor Retrospective

#79
This is an excellent read.

I was always wondering if CRDT would really achieve encapsulation, but this kind of things are very hard to know without trying. Thank you for you works!

Re: Xi-Editor Retrospective

#80
On the github page https://github.com/xi-editor/xi-editor:

  JSON. The protocol for front-end / back-end communication, as well as between the back-end 
  and plug-ins, is based on simple JSON messages. I considered binary formats, but the actual 
  improvement in performance would be completely in the noise. Using JSON considerably lowers 
  friction for developing plug-ins, as it’s available out of the box for most modern languages,
  and there are plenty of the libraries available for the other ones.
4 years later:

  The choice of JSON was controversial from the start. It did end up being a source of friction, but for surprising reasons.

  For one, JSON in Swift is shockingly slow.
Surprising reasons?!
Post reply on HN