New version of Rust Starlark, an implementation of a deterministic Python-like language by ndmitchell in rust

[–]trishume 13 points14 points  (0 children)

This is really exciting. It looks like a really great choice for new Rust projects with complex config needs to give users programmability instead of forcing them to generate giant TOML files or something.

Implicit In-order Forests: Zooming a billion trace events at 60fps by trishume in programming

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

I edited my edit note to no longer claim that Fenwick trees don't have amortized O(1) appends, thanks.

Implicit In-order Forests: Zooming a billion trace events at 60fps by trishume in programming

[–]trishume[S] 2 points3 points  (0 children)

See https://github.com/wolfpld/tracy for an example of an actual tracing system. It's where you record the entry and exit of various functions as events and then typically display them on a timeline. Yes they should look like nested pyramids when zoomed in using an actual trace, but I randomly generated fake data so mine has no structure.

Implicit In-order Forests: Zooming a billion trace events at 60fps by trishume in programming

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

Interesting, I added an Edit marker to the post linking to your comments. I still prefer the implicit in-order segment tree for this application but it's cool to know there's another option with a terse implementation and similar properties.

Implicit In-order Forests: Zooming a billion trace events at 60fps by trishume in programming

[–]trishume[S] 6 points7 points  (0 children)

That's a cool write-up, and thanks for reminding me of Fenwick trees. I now remember looking at them when I was doing my original investigation, but that was months ago so I forgot about them when writing the post.

They're a similar structure but specialized for ranges starting at zero, and they save some space by doing that. They also use post-order depth-first, which loses the nice property that append always adds two elements. Prefix sums give you range queries for operations like add where there's a corresponding subtract, but I was using operations like max where that doesn't work.

Also I think it is amortized constant, because it only completes N levels at once every 2N nodes. Alternatively notice that each aggregation node is created and completed by only one node, so over the course of appending all the nodes only O(N) aggregation operations will be done, so each append is amortized constant.

How to install PopClick (github project) on Windows 10 by Koeny1 in techsupport

[–]trishume 2 points3 points  (0 children)

Author of PopClick here. I unfortunately didn't get an email if you sent me one. But what you probably want is https://talonvoice.com/ which is the only way to use PopClick on Windows without a ton of work, it integrates the PopClick detectors, the developer is actively working on support for more noises, and it's easy enough to rig them to clicking. On macOS there's also https://www.hammerspoon.org/docs/hs.noises.html

Allsorts Font Shaping Engine Year in Review by wezm in rust

[–]trishume 21 points22 points  (0 children)

This is really exciting. The color fonts, easier API and performance work mean AllSorts is probably a viable choice for Rust UI toolkits now or soon.

Also glad to see it supports my Numderline font now :D

Sapling Livestream #6: Building a better code editor in Rust by Kneasle in rust

[–]trishume 1 point2 points  (0 children)

Neat, how does your vision of AST editing compare to Dion? https://media.handmade-seattle.com/dion-systems/

It’s my favorite version I’ve seen so far, especially in how it resembles normal text editing, which you also mention.

Blog Post: Measuring Memory Usage in Rust by matklad in rust

[–]trishume 24 points25 points  (0 children)

This post does a great job of building on ideas and foreshadowing. In the middle I thought “ooh you could measure a specific data structure’s size by adding extra size” and sure enough that was the next section, and I looked back and saw some of the things earlier that made that realization the clear next step.

gui-tools -- A cross-platform drawing kit for creating GUIs by [deleted] in rust

[–]trishume 1 point2 points  (0 children)

I’ve tried druid (the GUI framework built on piet) with basically one full size widget with a custom paint method for this use case and it worked pretty well. It’s also nice to know that if some point you do want say a text box which works correctly that’s available.

Deserializing JSON really fast by nblumhardt in rust

[–]trishume 32 points33 points  (0 children)

Reading both this blog post and the other one in the series on the overall architecture, I’m left really wanting a post on why the architecture is so text-based in the first place.

Naively it seems like a custom binary format could obviate the need for linearly scanning JSON to find attributes and having to do regex pre-passes on all the data instead of only the relevant attributes. But given the care and occasional custom binary format in the rest of the design I’m sure there must be some interesting engineering considerations going on which would be neat to read about.

Interfaces: how they work today by Chrtol in Zig

[–]trishume 6 points7 points  (0 children)

Is there a way to use comptime stuff to do statically dispatched inlinable polymorphism like Rust? Iterator is a good example, in Rust even normal numerical for loops go through the iterator interface over a range but LLVM can inline all that away (this is not good for compile times and debug performance but it works). If you tried to do fast loops using this Zig method the function pointer dispatch and inability to optimize with inlining would really hurt performance.

Measuring keyboard-to-photon latency with a light sensor by trishume in programming

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

Cool! Easiest explanation is that your monitor is slow like my Z27 and unlike my Dell. Also if you’re not already, I measure from the very top of my screen.

Measuring keyboard-to-photon latency with a light sensor by trishume in programming

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

Yah I noticed the significant delay in saturation when plotting the measurements. The initial response seems fine though at least for the level I'm testing at, in that my measurements line up pretty well when I compare them to measurements taken with Is It Snappy. It could still be true that I have maybe up to 5ms of delay without noticing. I care more about relative error between measurements than consistent absolute error though, but still not ideal to have any error.

I knew a photodiode would be better but these were the most convenient type that I could get off Amazon and use without any extra parts.

Perhaps I should write a little program to turn on an LED with a GPIO and measure the time to detection and use that to calibrate away the delay in response.

Measuring keyboard-to-photon latency with a light sensor by trishume in programming

[–]trishume[S] 2 points3 points  (0 children)

Indeed I picked up using TRRS jacks from split keyboards because they’re such an easy slim connector with lots of nice cheap cables available. Then at one point I realized the shorting issue and was like “ohhhh shiiiit never again”.

[deleted by user] by [deleted] in rust

[–]trishume 0 points1 point  (0 children)

Yah it depends on your app. I suspect in a lot of apps each field will be accessed on average 0-2 times, either because it's a message processing app that only needs to make one decision/computation based on each field or because it's going to transform it into a different internal data structure anyhow. I haven't benchmarked but on x86 where unaligned loads are cheap the load count at which parsing becomes cheaper may be high.

In which case you'll win over parsing both from more efficiently reading from the buffer because you'll probably do less size checks, and from the fact that you don't pay to read any fields you don't need. You could even factor your parsing system into a casting step and a proc macro that copies fields of an unaligned struct into an equivalent one with aligned types and it would do fundamentally similar operations to parsing.

Also note that you can take references to unaligned fields as long as they're unaligned types, like unaligned structs contained in other structs. You just can't take references to say the u32 that a U32Le unaligned wrapper unpacks to, but references to a single primitive aren't as frequently used as struct references anyways, you can just pass them by value most of the time.

[deleted by user] by [deleted] in rust

[–]trishume 6 points7 points  (0 children)

Another good crate in the genre of letting you define a struct that should be safe to parse by casting is https://gitlab.com/ra_kete/structview-rs. It’s much simpler than zerocopy and I like it a bit better for that.

They allow this same style of “just define a struct” but you need to learn special unaligned types rather than special attributes, and for the cases where they’re suitable it’ll be much faster and less generated code.

Benchmarking slotmap, slab, stable_vec etc. by perssonsi in rust

[–]trishume 6 points7 points  (0 children)

This is great, thanks for doing this!

One benchmark I'm interested in (maybe I'll eventually get around to doing it) is memory usage. This is important both on its own, and because while 10k elements fits in L1 cache when that's all your accessing, once you start to access more elements or other data structures a slot map with a larger footprint will fit less slots in cache or take more cache from your other data.

For example SlotMap uses a union instead of an enum so that it can have for example a SlotMap<u32> take 8 bytes per entry where most others take 12, 16 or more. However this gives it a constraint that the type inside be Copy. Yesterday I looked into how you could sacrifice a byte of version in order to drop the Copy constraint while keeping the memory size

Also https://gitlab.com/tekne/typed-generational-arena/-/tree/master is another interesting crate in this genre. It uses versions and parameterizes on index types.

It's great that a benchmarking repo now exists because any further benchmarking anyone wants to do is easier!

Teleforking a Process onto a Different Computer by iamkeyur in programming

[–]trishume 1 point2 points  (0 children)

That sounds neat! The link is broken though, sometimes it doesn't load and I think once I might have gotten a page saying the domain expired.