u/killercup

4,502 post karma · 12.3k comment karma · joined Dec 2013

  1. 23points

    BufWriter and LZ4 Compression (deterministic.space)

    8 comments · source

  2. 195points

    How Bevy uses Rust traits for labeling (deterministic.space)

    13 comments · source

killercup

Good idea, tried it now and was between 1% slower to 1% faster. Also tried with bigger buffer capacity and bigger lz4 block size -- this was actually 5% faster now for my 186MB output file.

killercup

Good question! I don’t know — Maybe ask on the bevy discord?

killercup

Not sure there's something specific to Bevy, but rocket and actix_web use a similar "implement trait on generic functions" trick to allow users to write route handlers IIRC.

killercup

Oh! I've actually been meaning to write about some of the type system tricks Bevy is using. Originally, I wanted to go for how the System trait is used, but now that you mention it, the label traits are also super interesting (and less specific). Let's see how far I get :)

Edit: Post is live! https://deterministic.space/bevy-labels.html

killercup

I think serde_json::StreamDeserializer works for this, but doesn’t care about there actually being newlines.

killercup

Are humans gonna edit the yaml files? If so: You might want to generate json schema files from your serde structs (e.g. using schemars) and recommend people use it with an editor extension like this so they get autocomplete and inline errors.

killercup

Awesome article! I have recently cargo-culted the "fast cargo config" from bevy, and I think it helped quite a lot. In addition to using lld on Linux it also uses -Zshare-generics=y -- which might have tricked me into using nightly which was faster anyway :D

killercup

You can create a build.rs file that cargo will run at compile time :)

killercup

16

killercup

Just clicked on the post and saw this near the top:

Both formats sport maximum image dimensions of 65536 x 65536 pixels. Video professionals will recognize this as the size of an 8K video frame.

Uh, what? This is totally wrong. Like, the numbers are one order of magnitude off and intuitively are closer to 64k, not 8k? Wikipedia says

8K UHD (7680 × 4320) is the highest resolution defined in the Rec. 2020 (UHDTV) standard.

Hope this is the only thing wrong with this post :)

killercup

Ah, I see. Given the quoted description, I was expecting something visual, for humans, to look at, not JSON 😅

killercup

aesthetic, human-readable documentation

What does this look like? Are there any screenshots?

killercup
killercup
killercup

In addition to what other commenters already said: Think of Option as a marker of whether the field is set, not as a true "optional" value. This makes it easier to understand why APIs like str::find return Option IMHO.

If you want to have default values – and the default for Option is None – you can drive the Default trait and initialize your struct like Bag { owner: "me".into(), ..Bag::default() }.

killercup

Just a quick shout out to Ed and Andronik -- they are the driving force behind this and have been doing an amazing job at maintaining cargo-edit recently! ❤️

killercup

Bonus: If you're using rust-analyzer, you can set it to run cargo clippy instead of cargo check.

killercup

I have no clue about kernel dev myself but there are some pretty great resources put there, like https://os.phil-opp.com/ (a full guide on how to write an OS in Rust) and https://redox-os.org/ (a working OS written in Rust).

killercup

with a bit if creativity: sword

killercup

Just wanted to say I really enjoyed watching this! Made me want to build a small game with bevy myself :)

killercup

I think https://lib.rs/crates/jemalloc-ctl does offer this

killercup

Try to

  • download in parallel as other commenters say
  • stream directly to a file (not sure you do this)
  • also buffer writes to files using BufWriter
killercup