Better HN
topnewbestaskshowjobs
Log inSign up

GrumpySloth

4,901 karma · joined Sep 13, 2020 (6y ago) · 1,641 submissions

Submissions

comment 4y ago · link · parent

This "threading" approach looks more complicated than the classic NFA->DFA transformation via subset construction.

Also, I don't see how this "threading" solves the issue pointed out in the article:

> This backtracking-based approach works, but it comes with a problem. The number of branches we need to test can exponentially increase with the size of the regex in certain situations, which means that testing all the branches would potentially take forever.

> [...]

> This approach means we only need to do an amount of tests that’s directly proportional to the size of the string we’re testing against. There’s no possibility for exponential growth, and so our algorithm is said to guarantee to match in linear time.

If the number of branches grows exponentially, then the number of "threads" will also grow exponentially. And so the number of states you step through "simultaneously" will grow exponentially. This "simultaneously" seems to be a bit of a sleight of hand in this article. (Also note that the actual code doesn't use multithreading, although that also wouldn't solve the issue --- you'd just have a big number of actual threads to start and coordinate which would probably also be slower, not faster.)

Subset construction is O(2^m), where m is the number of nodes of NFA. It looks scary, but it's important to note that it doesn't depend on the size of string which we're matching against at all. Matching against the string will be linear. And once you have the DFA you may reuse it for many different strings.

All the while, this "threading" still seems exponential wrt branches, but you can't reuse it for different strings.

comment 4y ago · link · parent

Oh, wait. You mean that this "cat </dev/urandom >/dev/null" was meant to be running in the background and not be the pipeline which is tested? Ok, my bad for not getting the point.

comment 4y ago · link · parent

I don't understand. If you're testing how fast pipes are, then I'd expect you to measure throughput or latency. Why would you measure how fast something unrelated to pipes is? If you want to measure this other thing on the other hand, why would you bother with pipes, which add noise to the measurement?

UPDATE: If you mean that you want to test how fast pipes are when there is other load in the system, then I'd suggest just running a lot of stuff in the background. But I wouldn't put the process dedicated for doing something else into the pipeline you're measuring. As a matter of fact, the numbers I gave were taken with plenty of heavy processes running in the background, such as Firefox, Thunderbird, a VM with another instance of Firefox, OpenVPN, etc. etc. :)

comment 4y ago · link · parent

> They all go slightly faster if you localize the reference to `io.write`

No noticeable difference for LuaJIT, which makes sense, since JIT should figure it out without help.

comment 4y ago · link · parent

On 5.10.0-14-amd64 "pv < /dev/urandom >/dev/null" reports 72.2MiB/s. "pv < /dev/zero >/dev/null" reports 16.5GiB/s. AMD Ryzen 7 2700X with 16GB of DDR4 3000MHz memory.

"tr '\0' 1 </dev/zero | pv >/dev/null" reports 1.38GiB/s.

"yes | pv >/dev/null" reports 7.26GiB/s.

So "/dev/urandom" may not be the best source when testing performance.

comment 4y ago · link · parent

"Web only for documents, not apps" appeals to me. However, it's not a question of just shaving off features. Some features of the web are extraneous for that purpose, and some are missing. For example, rendering maths on the web portably still requires you to make your page into an app. The defaults (wrt fonts e.g.) are poor. And while I'm at fonts and maths, you can't assume the client has fonts appropriate for displaying maths, so now you need to bundle fonts with your page. The automatic hyphenation algorithm used in browsers is also visibly inferior to the one used in LaTeX.

And Gemini solves none of that. Maths is even harder with Gemini than with the web.

comment 4y ago · link · parent

Speaking from my experience kayaking, mosquitos are a tiny bit more frequent close to water than say in the middle of a forest, but not much. The real multiplying factor are swampy terrains, particularly close to places like water locks[1].

I've been told that the reason mosquitos are in bigger numbers in those places is that this is where they lay their eggs.

[1]: <https://en.wikipedia.org/wiki/Lock_(water_navigation)>

comment 4y ago · link · parent

Thanks. Will check it out.

comment 4y ago · link · parent

For me the most frequent source of freezes was Tramp. It led me to ditch Emacs for VSCode (with the remote editing extension) at least for my dayjob (I still use Emacs for my own projects). Tramp is an official built-in package, so it's not as if I downloaded a random package from GitHub.

comment 4y ago · link · parent

Thanks. Will check these out.

comment 4y ago · link · parent

Sounds like a recipe for alcohol addiction and obesity. Otherwise maybe I'd try that. ;)

comment 4y ago · link · parent

What do you recommend to learn APL and K?

comment 4y ago · link · parent

On the other hand, I can't imagine an average user finding anything useful in Google after searching for "linux files crashed". And then when communicating with fellow humans:

- Files has a nice UI

- Huh?

Or worse: "Web is ugly".

Your local bakery probably also doesn't call itself just "bakery".

And you (figuratively) use Java and C#, not "Oracle Programming Language" and "Microsoft Programming Language".

comment 4y ago · link · parent

Unfortunately.

Similar to Haskell. While with Rust it can be justified by its novelty and status as a meme, Haskell has been here since 1990.

Maybe it's because it's hard to attract talent in that space without offering niche, cool tools that are hard to find elsewhere?

comment 4y ago · link · parent

I think it's more productive not to assume a religious stance on whether compiler has bugs one way or the other. If there is something wrong, better to read the language spec, the ABI spec and the machine code the compiler generated and judge for yourself. People who, given an extensive description of what compiler did and why it's wrong, get back at you with the religious "it's never a compiler bug" just make me not want to talk to them.

comment 4y ago · link · parent

Lambda calculus models only computable functions.

comment 4y ago · link · parent

Amdahl's law applies regardless of whether you use shared memory synchronization, CSP or Actors. CSP and Actors are easier to think about, but they aren't inherently faster.

comment 4y ago · link · parent

You can replace "cat file |" with "<file".

comment 4y ago · link · parent

Is there a tool other than dd that would allow me to skip n bytes from a file and then read m bytes? I mean one tool, not a combination of head and tail, which is too elaborate for my taste.

comment 4y ago · link · parent

If you want to write the input file at the beginning and write the command later, then you may use:

  </dev/sda pv >/dev/sdb

comment 4y ago · link · parent

To be fair, compilers and linkers can be thought of as pure functions (if we ignore stuff like including timestamps in builds e.g.). They have no special requirements language-wise. You can write them in any general purpose programming language. Even Brainfuck will do (for one-file programs fed through stdin). No argument about the others though.

Although I guess JIT compilers may be classified as systems programming, since you need to do some OS-specific tricks with virtual memory during execution of the compiler.

comment 4y ago · link · parent

I don't write web services, so it's hard for me to answer about axum, but if I were to speculate, I'd point out that PHP, Ruby and Python have good integrations with tools like Apache and nginx, while AOT compiled languages like C++ and Rust do not. There is CGI/FastCGI, but then you're parsing strings in true Unix fashion. When instead you use a web server library written in the language you use, you get to use a richer interface than functions [byte] -> [byte]. Go is nicer here since it has that in the standard library, but the idea is the same. But again: take that with a grain of salt --- I don't write web services.

> I mean i only asked for an example of a small team performing magic thanks to rust so if there's no examples of that, i can be certain there's no examples of a large team performing magic thanks to rust!

Well then, my examples of large teams should be sufficient. :)

Oh, and I've just remembered about this nice project: <https://github.com/firecracker-microvm/firecracker/>

comment 4y ago · link · parent

Another example, particularly painful to me personally: Assassin's Creed. The team behind the game changed and instantly from my favourite games of all time it turned to creating games I can't suffer through playing.

There are many other examples, but this one is especially sad for me. Sometimes I wish brands weren't transferable between people.

comment 4y ago · link · parent

> Anyway I don't believe you [...] Either you're bullshitting or you have restricted yourself to extremely simple Rust code

How kind.

> what does `for<'a>` and `+ '_` mean?

`for<'a>` allows you to introduce a new lifetime parameter which parametrizes an Fn argument independent of the lifetime parameters of the enclosing function/struct. Sounds complicated when you try to explain it in programming terms, but actually when you think about it in terms of logical quantifiers from maths (for<'a> being the universal quantifier introducing the 'a "variable", "for" -> "for all"), it's pretty simple. The idea is simple, the syntax is noisy. I've already complained about the noise in another comment: <https://news.ycombinator.com/item?id=31433427>

"+" in type constraints is just conjunction.

> C++ definitely gives you a head start when thinking about lifetimes, but there's still a huge difference between thinking about lifetimes, and writing them down to prove to a not-especially-smart borrow checker that they're ok. Obviously the latter is better, because it gives you guarantees. But it's still way way harder.

Getting a program to compile may be harder. But the whole task of writing a program long-term gets easier. Most of the complaints about borrow-checking I see online can be split into two categories:

1. syntax noise --- I agree

2. this program would work, if not for the borrow checker --- in almost all cases here people do not think about API boundaries at all. They look at the body of the functions they wrote and conclude that it should work. But they forget about one important thing: the compiler needs to ensure that changing the body of function f() without changing its signature should not break compilation of function g() which calls f(). That leads to examples where it seems as if something should compile, but doesn't, because of function boundaries which mandate that lifetimes should be correct regardless of function implementations. And there is a good reason for that: if I use a library, this library pushes out an update which doesn't change the types of anything, I don't want to be forced to update my code for it just to compile. So the work that ensures that everything stays composable throughout implementation detail changes is moved upfront.

The alternatives to "fighting the borrow-checker" are GC or difficult to debug (sometimes even to reproduce) bugs. Fixing the compilation is a lot easier for me than tracking down memory-corruption bugs I face in large C++ codebases with hundreds of contributors, so I disagree with the claim that making things work in Rust is harder.

comment 4y ago · link · parent

> If you're going to do that, would you not be better saving all that time and code bloat (it's code you wrote that doesn't contribute to solving your problem) by just using a garbage collector from the outset?

I suspect a garbage collector would be pretty nice. However, I can't just list the features I want and get a language (unless I make it myself, which would take a lot of time). Currently, my imaginary perfect language would actually have a garbage collector, would be pretty similar to Standard ML, but would be more focused on arrays than lists, and would have value types --- in Standard ML I can't have a value array of records (structs in Rust/C++ parlance) --- they will be behind a pointer. And if I were to stick to the standard or make sure that my code compiles with other compilers than MLTon, then I can't even have a value array of 64-bit words, although I can have a value array of 63-bit words. This one bit may seem insignificant, but for certain algorithms it's a big complication. Powers of 2 simplify a lot of algorithms (and are "faster" to be a bit loose with the language). There are other features I'd like, but already this short list makes for a currently-non-existent language. OCaml and Haskell have similar problems to Standard ML.

At the same time Rust has great support for arrays, is expression-oriented, has sum types. Value types are the default. It generally ticks a lot of boxes I care about. I can't just go and say "now give me all that but with a GC" and have it appear before me.

Also, arenas I use are linked to logical portions of my programs. They are not contrivances that I had to think long and hard about. They don't waste my time really. I've spent 0 time thinking about how they should be organized.

Now the part where a GC would be helpful is a bit of a more liberal use of closures, and eliminating code noise coming from lifetime annotations such as "for<'a>". But I can live with the current state of affairs, if I get all the other benefits.

> If you're going to do that, would you not be better saving all that time and code bloat (it's code you wrote that doesn't contribute to solving your problem) by just using a garbage collector from the outset?

If anything, Rust is an asset for large teams of devs. Even though you may sometimes argue that a handful of C/C++ devs can keep their whole project in their heads and not make mistakes (although I think that's a stretch), the moment you get a large C/C++ team, weird hard-to-debug bugs coming from memory- and thread-safety issues start to creep in. There are other high-level languages, but Rust is the one with a combination of performance competitive with C++ and large ecosystem of libraries you can use. Examples of Rust projects with a large number of contributors facilitated by the language taking the fear of intractable bugs away:

- <https://github.com/BurntSushi/ripgrep>

- <https://github.com/clap-rs/clap>

- <https://github.com/rayon-rs/rayon>

- <https://github.com/cloudflare/wrangler>

- <https://github.com/sharkdp/fd>

comment 4y ago · link · parent

Coming from C++, it didn't take months. I got a couple lifetime errors at the start, but I understood the reason behind them all[1]. Now I don't get the errors[2]. In C++ you need to think about the lifetimes anyway or your code will break at runtime, so then coming to Rust it's not that much of a problem IMO.

[1]: Except the errors about partial (non-aliasing) borrows of struct fields. That was annoying, although circumventable with some boilerplate. Luckily, it's solved now in the compiler.

[2]: Although it may be to a large degree thanks to using arenas for allocation, which simplify lifetimes a lot by grouping them into large buckets instead of tracking each little object separately with its own little lifetime.

comment 4y ago · link · parent

The URL should probably be changed to the linked post: <http://www.pmail.com/newsflash.htm>

The tweet adds nothing to the post.

EDIT: Seems like OP already posted that link as well? <https://news.ycombinator.com/item?id=31420433> IMHO that's spam.

comment 4y ago · link · parent

You're right. (Didn't notice your reply before updating my comment.)

comment 4y ago · link · parent

You write "transaction", but Unix filesystems don't know anything about any transactions from the application's point of view. To them it's just a bunch of write(2) calls. How is a ZFS snapshot going to make sure that it snapshots the state either before or after what an application considers a "transaction", but implements with a sequence of write(2), fsync(2) etc. calls? (EDIT: The rest of this paragraph is rescinded. See [1]) If an application uses SQLite, BerkeleyDB etc., then you don't need ZFS. XFS will be sufficient (and maybe even better?). If an application doesn't use any transaction-processing library ("database"), then I don't see how filesystem snapshots fix anything here --- you still can get an intermediate state in a snapshot.

As far as I understand, the only thing snapshots make sure of is that you're looking at a consistent state of a filesystem from the point of view of the filesystem, so e.g. if there was a sequence of operations "remove file a/b", "create file c/d", then you're not going to record a state with both files "a/b" and "c/d" present --- something that could happen with a backup tool not using filesystem snapshots, if it reads directory "a" first and directory "c" second. But there are no assurances about application transactions. So if KeePassXC has a bug, then if there is a sequence of operations "remove password A", "add password B", then a backup tool may pick up a version of KeePassXC database which is going to contain both passwords A and B, even if the backup tool uses filesystem snapshots.

[1]: At first I didn't get the example from TFA about Firefox and SQLite, but I've reconsidered and it makes sense now. I'll still say that you may get an intermediate state in a snapshot. However, snapshot prevents some classes of inconsistencies (though not all). Call me convinced about ZFS.

comment 4y ago · link · parent

I didn't mention it, but wind is also a plus for me. Warsaw has too little wind for my taste. :)
1
343536
55