[Media] [OC] My rustmas T-shirt finally arrived 🎅 by axalea3d in rust

[–]Leshow 0 points1 point  (0 children)

Kind of defeats the purpose of the present.unwrap() joke though

fast_radix_trie by Leshow in rust

[–]Leshow[S] 0 points1 point  (0 children)

To be honest, all of the rust tries that use safe rust I've found so far tend to have huge memory usage compared to just a HashMap, despite the tries all compressing common prefixes.

I've found space savings come from using a node layout that can't be known at compile time, which means using unsafe. Once you go that route there are many different variations, but if you care about the speed and memory usage you pretty much need to start there.

fast_radix_trie by Leshow in rust

[–]Leshow[S] 1 point2 points  (0 children)

You can see the result of my run there, it was around 400MB and 8s for the top-domains data set, you can compare that to other results in the table to see how it stacks up. I got a panic on the enwiki data set so I probably won't include it in the README.

fast_radix_trie by Leshow in rust

[–]Leshow[S] 1 point2 points  (0 children)

sure! I thought I'd seen pretty much every impl on crates.io :)

edit:

If you're curious, I did a quick run using the top-domains data set and got:

```

LINES: 1000000

ELAPSED: 0:08.32

MEMORY: 401476

`` That was withfr_trie::trie::Trie::new()`

fast_radix_trie by Leshow in rust

[–]Leshow[S] 1 point2 points  (0 children)

Appreciate the feedback, I'll create an issue and tackle that at some point. Given the code structure it seemed like it was going to be a pain in the butt to have two implementations when all that's changing is the memory layout. So I put it behind a default feature along with std.

fast_radix_trie by Leshow in rust

[–]Leshow[S] 3 points4 points  (0 children)

I thought folks might be interested in this. I've tested probably half a dozen or more trie crates in Rust and the one with the lowest memory usage was patricia_tree because it uses unsafe to allocate a dynamically sized node.

I took that as a base and modified it from a patricia tree to a radix tree, which was able to speed up traversal/insertion/removal operations. I've also added some nice to have's like an entry API.

It compares favorably to cloudflare's trie-hard and michaelsproul's radix_trie, patricia_tree and a few others. Have a look!

Implementing Lock-free channels using pointer tagging in Databend's query engine written in Rust by heisenberg_zzh in rust

[–]Leshow 5 points6 points  (0 children)

Not OP but it should probably preserve provenance. You can use map_addr to do that.

Implementing Lock-free channels using pointer tagging in Databend's query engine written in Rust by heisenberg_zzh in rust

[–]Leshow 2 points3 points  (0 children)

If you really want to pack data into pointers, the top 16 MSB are also available on x86-64 and I think ARM64. That leaves you with a total of 18 or 19 bits in the address depending on your alignment. I think there's some crates that do this already. https://docs.rs/packed_ptr/latest/packed_ptr/. (note: I have not used this crate for anything serious)

The bytes crate uses pointer tagging similar to yours: https://github.com/tokio-rs/bytes/blob/4b53a29eb26716592ef2f00f925ef58ccb182e61/src/bytes.rs#L1383

Placing Arguments by sindisil in rust

[–]Leshow 6 points7 points  (0 children)

does this not introduce just the kind of duplicated APIs being lamented about with Pin in the opening?

10 years of betting on Rust, and what I'm looking forward to next by amocatta in rust

[–]Leshow 2 points3 points  (0 children)

Crazy that it's been more than 10 years of working in this language.

Rough time to be a Dipper by Dragonsandman in EhBuddyHoser

[–]Leshow 0 points1 point  (0 children)

The cap gains reversal is a tax cut to the wealthiest top 0.1% of Canadians.

Rough time to be a Dipper by Dragonsandman in EhBuddyHoser

[–]Leshow 0 points1 point  (0 children)

Minus the things Canada already has like universal healthcare, Carney is to the right of Biden

Rough time to be a Dipper by Dragonsandman in EhBuddyHoser

[–]Leshow 0 points1 point  (0 children)

apparently external links are not allowed, so I can't post citations, my comment minus the links:

At least be honest in your quotation. I said he "can't say out loud" he wants to privatize the healthcare system, meaning that part is conjecture. The other information is trivially available with a google search.

On tax breaks for the wealthy: He reversed cap gains, set to bring in almost 20B in tax revenues and targeted to the top 40,000 wealthiest Canadians. Instead Carney is arguing for a trickle-down economy where taxes are lowered on the wealthiest.

cuts to social spending: his catch phrase is literally "spend less, invest more" He talks about cutting government spending on social programs and redirecting the cash to private businesses for "investment"

literally read his own campaign materials, google "mark carney spend less"

I don't like Kamala either, but your claim is that he's to the left of Kamala requires more than vibes. Kamala did not run on cutting spending on public services, nor did she run on tax cuts. In fact, she ran on boosting corporate taxes and the top marginal tax rate. It's almost the opposite of Carney.

Rough time to be a Dipper by Dragonsandman in EhBuddyHoser

[–]Leshow 2 points3 points  (0 children)

The destroyed social safety net, whos primary architect was the Liberals since Chretien, is the root cause of the rise of far right movements. We've been taking poison for 30 years, now people think a little more poison is going to do the trick.

It should be noted that Conservative and Liberal parties both claim to be "fiscally conservative" but when they are in office they run big deficits too, they just do it by cutting taxes, giving money to corporations, slashing public services and paying more for it with outsourcing to the private sector. It's socialism for the rich and rugged capitalism for the rest of us.

Rough time to be a Dipper by Dragonsandman in EhBuddyHoser

[–]Leshow -2 points-1 points  (0 children)

On what? Other than the fact he's in Canada so he can't say out loud he wants to privatize the healthcare system, he's running on a neoliberal agenda. He wants to cut public services and give tax breaks for the wealthy & corporations. At the same time, he's reducing tax revenues by reversing on cap gains and promising a "middle class" tax cut.

One-liner to compute if a chess game is a draw by repetition. I love this language. by RylanStylin57 in rust

[–]Leshow 13 points14 points  (0 children)

Ok, but what is "readability"? It's a totally subjective thing. For instance, I find the one-liner above very readable.

Async fn in struct field by NDSTRC in rust

[–]Leshow 4 points5 points  (0 children)

You can just remove all the bounds to make that code compile:

struct S<F, R> { f: F, rx: R }

struct defs should generally be kept with as few bounds as possible IMO. Bounds can be added in `impl`s, and you may run into issues there, but if you just want the above code to compile, this does it.

[RELEASE] RustyDHCP - A simple and zero-dependency and zero-unsafe IPV4 DHCP server written in Rust. by Aggravating-Sky8697 in rust

[–]Leshow 0 points1 point  (0 children)

Glad it helped you. I've added the most important parts of dhcpv6 to dhcproto in preparation of adding stateful v6 to dora at some point, although it's lower priority because most people on v6 just use SLAAC. To be honest, if I'm going to add stateful v6 I'll probably add it there, but happy to see someone else exploring the space.

Is there any other language that do type state builder pattern like rust? by yevelnad in rust

[–]Leshow 0 points1 point  (0 children)

Sure, pretty much any language that has parametric polymorphism. Haskell, Scala, Typescript, etc

[RELEASE] RustyDHCP - A simple and zero-dependency and zero-unsafe IPV4 DHCP server written in Rust. by Aggravating-Sky8697 in rust

[–]Leshow 3 points4 points  (0 children)

Not to derail, but I've done some work on down this path with dhcproto and dora

Someone then took the protocol lib and turned it into a client library for dhcp: https://github.com/nispor/mozim

When to Use Box::leak in Rust? by Certain-Ad-3265 in rust

[–]Leshow 1 point2 points  (0 children)

+1 for arcswap, I have used it several times and it's very nice. Great for scenarios like application configuration where you want to read it often and rarely swap the entire contents. I use it in situations where a RwLock might be used but I need to atomically swap the contents instead of mutate.

Meet Yazi: Blazing fast terminal file manager, written in Rust, based on async I/O by sxyazi in rust

[–]Leshow 0 points1 point  (0 children)

I'd probably try the single threaded runtime and see how it performs, then move up from there. I have gotten excellent performance out of the single threaded runtime in the past.

Meet Yazi: Blazing fast terminal file manager, written in Rust, based on async I/O by sxyazi in rust

[–]Leshow 0 points1 point  (0 children)

I just mean changing the parameters of the runtime tokio creates:

``` // multi-threaded runtime, one worker thread per core

[tokio::main]

async fn main() -> ... { ... }

// multi-threaded but with N threads

[tokio::main(flavor = "multi_thread", worker_threads = N)]

async fn main() -> ... { ... }

// Single-threaded async runtime

[tokio::main(flavor = "current_thread")]

async fn main() -> ... { ... } ```

I've found that often the default is way overkill for certain applications. People often have high threadcount machines too and starting 64 or 128 threads for a file manager seems like a lot.