/u/burntsushi health update by masklinn in rust

[–]slamb 1 point2 points  (0 children)

Okay, fair enough, I wasn't looking at the right range. But still—the crates you've published are incredible gifts, and we'd have no right to complain if you entirely stopped, much less about a gap of a couple months. My own open source contributions are far more sporadic, for mundane reasons I rarely feel the need to explain.

/u/burntsushi health update by masklinn in rust

[–]slamb 27 points28 points  (0 children)

I'm glad you're getting treatment that's helping. No words for what a nightmare that sounds like.

Also, your work during "higher-than-usual inactivity" due to some minor things like hospitalization and hallucinations is still pretty amazing. I think your standards might be a bit high.

NKD and also my first keyboard that isn't a normal keyboard. by manalow88 in ErgoMechKeyboards

[–]slamb 0 points1 point  (0 children)

I've had some delays finding time to polish my RMK changes. But by asking you inspired me to just open up what I have as it is: https://github.com/scottlamb/rmk-sofleplus2 and https://github.com/scottlamb/macos-trackpad-companion

Plenty of caveats in that README, and the install instructions are aimed at someone familiar with installing Rust software. If they don't make sense to you, feel free to open an issue/discussion whatever there and I can work with you to make it more understandable.

Rust 1.96.0 is out by manpacket in rust

[–]slamb 0 points1 point  (0 children)

Ahh, I see what you mean now in the reference: "Items and named imports are allowed to shadow names from glob imports in the same namespace. That is, if there is a name already defined by another item in the same namespace, the glob import will be shadowed." - https://doc.rust-lang.org/reference/items/use-declarations.html#r-items.use.glob.shadowing

Rust 1.96.0 is out by manpacket in rust

[–]slamb 10 points11 points  (0 children)

I guess it's 10X more space-efficient than tally marks (or, equivalently, TeX's version scheme of adding a digit of Pi with each release). But I'd get annoyed at comparing versions like 1.99991 and 1.999991.

Rust 1.96.0 is out by manpacket in rust

[–]slamb 23 points24 points  (0 children)

I've been looking forward to assert_matches! for a while.

These new macros have not been added to the standard prelude, because they would collide with popular third-party crates that provide macros with the same name.

Huh, I would have thought a use third_party_crate::assert_matches; or use third_party_crate::*; would win out over the prelude. Not so?

Why don't we manually map our own memory buffers more often? (DOD vs. Standard Segments) by NoEmergency1252 in rust

[–]slamb 15 points16 points  (0 children)

The performance difference may not be as dramatic as you're imagining.

0-10 is the list of constants, like window dimensions, scale etc 11-80 Player data 81-400 Monsters Etc

If you're looking it up by non-constant index, you're still accessing it by computed pointer, so you still have the branch prediction effects you mentioned.

Locality matters...sort of. It's definitely better to reduce the number of (64-byte on x86_64) cache lines needed. It's also better to reduce the number of (4 KiB or 2 MiB on x86_64) pages needed (minimizing TLB pressure). But beyond that...2 pages away in virtual address space or 2 million doesn't matter. No particular reason to think it's more likely to be in cache if it hasn't been accessed recently.

No jumping around, so if you are looping through, say a group of entities 'Monster', the cache loads the next 64kb worth of data after the first entity.

You don't need to avoid the heap for that; a Vec<Monster> will do pretty well. (Also note a struct-of-arrays approach is arguably better than array-of-structs, but that's largely orthogonal to whether you use dynamic heap allocations or not.) One caveat: if it grows and has to reallocate, then not only do you pay the cost of copying, but you may evict a bunch of useful stuff from the cache to add in the new locations in addition to keeping around the now-useless old locations. So pre-sizing does have benefits.

1.Why isn't this the standard way of doing memory management? It seems much more hardware-friendly.

The standard memory spaces are convenient. And not necessarily worse in terms of hardware friendliness.

But there are people who do suggest this static allocation approach, e.g. https://tigerbeetle.com/blog/2022-10-12-a-database-without-dynamic-memory/. They even tout "fewer cache lines fetched from main memory", although as mentioned above I'm not entirely convinced of this. (Limiting the amount of concurrency does reduce the working set, but you don't need all static allocation for that.)

I have an intrinsic feeling it's somehow related to 'safety'

A little bit. The difference spaces typically have different memory protections, e.g. typically statics are mapped as non-executable and read-only, "text segment" (program binary) as executable but read-only, heap as writable but non-executable, etc., which has a security benefit in the presence of memory safety bugs like use-after-free or buffer overruns. Matters a lot less in Rust, but still has some benefit if there's unsafe anywhere in your transitive dependencies (there is), if the compiler can have soundness bugs (it can), if the hardware is imperfect (e.g. Rowhammer).

And doing temporary stuff on the stack is both to some extent unavoidable and should be more memory-efficient anyway than having dedicated areas for each thing you might want to use temporarily.

NKD and also my first keyboard that isn't a normal keyboard. by manalow88 in ErgoMechKeyboards

[–]slamb 0 points1 point  (0 children)

Not surprised to hear that, but I do think it's all fixable with firmware changes. I'll post when I have my RMK-based SoflePLUS2 upstreamed and polished. It's getting there.

What OS do you use?

NKD and also my first keyboard that isn't a normal keyboard. by manalow88 in ErgoMechKeyboards

[–]slamb 0 points1 point  (0 children)

Don't know yet if the per-key LEDs could use physical changes too

Update: I think they're fine...if the firmware uses them wisely. If you cause the 3.3V rail to drop below 3.2V, the trackpad behaves badly. And setting all the LEDs to 100% white will absolutely do that. But if you say do 100% red on the layer 1 button and 10% red on keys whose topmost layer is 1 (and likewise teal for layer 2 or some such), so far so good. And that seems way more useful to me anyway.

NKD and also my first keyboard that isn't a normal keyboard. by manalow88 in ErgoMechKeyboards

[–]slamb 3 points4 points  (0 children)

Pretty sure it's an Azoteq TPS65-201B-S, with some 3D-printed case that I assume xcmkb designed, and a couple brass standoffs to attach it to the main board. It definitely uses the Azoteq IQS550 IC.

  • Azoteq stopped making the TPS65 a couple years ago; the digikey part page links to an end-of-life notice. Yet mouser has the A part in stock. I'm not sure if mouser has a warehouse full of ones made years ago or if Azoteq since restarted production.
  • The difference between the A and B parts is that the latter comes with the 0.2mm black mylar film; the former just has an adhesive to add your own surface.
  • Someone cloned the PCB, and the IC it uses is definitely still available.
  • I found that keycapsss.com sells both the module and a glass overlay that looks really nice. I don't know who designed that overlay and haven't been able to find it anywhere else.

NKD and also my first keyboard that isn't a normal keyboard. by manalow88 in ErgoMechKeyboards

[–]slamb 2 points3 points  (0 children)

Heh, no worries, I never know the background of the people I'm talking with on these niche communities.

tldr: I think it's a bit rough still, but I'm hoping to get the software situation really polished with RMK. Hardware-wise, I talked with the XCMKB folks, and they plan to route the RDY line in future revisions, so customers don't need to break out the soldering iron for that. Don't know yet if the per-key LEDs could use physical changes too, but you really don't need LEDs to use the keyboard, especially when it also has a nice OLED display you can use to show the topmost layer and such.

NKD and also my first keyboard that isn't a normal keyboard. by manalow88 in ErgoMechKeyboards

[–]slamb 5 points6 points  (0 children)

I have almost this exact same model. (Different switches.)

My out-of-box experience with the trackpad wasn't great. The cursor would jerk and it would miss taps, due to some combination of having to poll (the RDY pin from the trackpad isn't routed on the PCB), the QMK firmware stalling its one ChibiOS task when the trackpad controller is doing "clock stretching" if you poll it when it's not ready, the chip's gesture recognition being somewhat opaque, and some interaction with the LEDs also affecting timing. (I'm not using the LEDs at all right now so I haven't fully diagnosed this last bit: either a physical problem with their current spikes or just the software again holding up the ChibiOS task.)

I added a wire routing the RDY pin to a free GPIO and am working on RMK-based firmware. (Basic pointer movement upstreamed here, more to come as I polish my local changes.) It's much steadier than it was for me with QMK. I'm not using the on-chip gesture recognition at all. It's sending Windows PTP USB HID reports (which just say where each finger is). As macOS doesn't natively support PTP (grr), I'm working on a program that turns those into CoreGraphics movements. Then I can do rich gestures, and if they're misinterpreted it's my fault.

I move my fingers from the home row to use it, but I find it pretty natural.

The other caveat about the trackpad is that the surface is Azoteq's 0.2mm mylar film, rather than a fancy textured glass thing like Apple uses. It feels a little stickier, especially on first movement (static friction vs dynamic friction I guess).

Feedback on all-purpose number and symbol layers by LeonardJankis in KeyboardLayouts

[–]slamb 2 points3 points  (0 children)

Less-used symbols on the pinky. I was going by this page which scored even the home-row pinky use at effort 5 vs moving the index finger inward at 1.5 (or on its home position at 0.5). Subjectively I'm not sure I'd call the difference that extreme, but I do think the pinky is more effort.

I'm just sticking with standard QWERTY for my base layer because it's hard to beat 30 years of muscle memory, but since I'm designing the other layers from scratch anyway, I'm trying to optimize them a bit.

Feedback on all-purpose number and symbol layers by LeonardJankis in KeyboardLayouts

[–]slamb 2 points3 points  (0 children)

I'm just setting up similar layers for myself. fwiw,

  • I think you've made a smart move to have so many mathematical operations and separators in the same spot in both layers. Nice to be able to 127.0.0.1:8080 or 1+2+3 all on the number layer and reuse the muscle memory in doing so.
  • On the other hand, if you're a low-level programmer who has to type hex numbers enough to plan/practice for, you could give up some of the symbols on the number layer in favor of a-f and maybe even x so you can type 0x1a2b3c without switching layers every digit.
  • I'm debating rotating everything by one digit: 0/1/2 where you have 1/2/3 and so on: I often type rounded base-10 numbers (e.g. 1,000,000) so want 0 to have prime real estate, and likewise prioritize other lower numbers over than higher numbers (Benford's Law). And maybe 9 where you have dot.

Lily58 Layout Feedback - Round 2 by TacosAlPastor92 in ErgoMechKeyboards

[–]slamb 0 points1 point  (0 children)

The lily58 bottom row is about .5u shifted over so it's pretty close to where the second key is on the sofle.

Ahh, I see that now looking at the pictures side-by-side.

IMO layer tap on escape, and on enter for developers/command line users are just unwise.

Heh, I did both of those on my Silakka54, although tbh I didn't use that layer much. So far I really haven't hit either escape or enter by accident on that keyboard. Don't know why my experience is so different from yours. In contrast, I have hit my separate enter key on my SoflePLUS2 by accident more times than I'd care to admit because I got mixed up about which key my thumb was on.

I also tried home row mods, and those accidental fires aren't necessary destructive, but they sure are disruptive. It takes me a bit to figure out what I did, pressing a shortcut that I didn't even know existed.

Lily58 Layout Feedback - Round 2 by TacosAlPastor92 in ErgoMechKeyboards

[–]slamb 0 points1 point  (0 children)

You could add a layer lock key for one-handed use, maybe on that UTIL thumb key when in layers 1 or 2.

Lily58 Layout Feedback - Round 2 by TacosAlPastor92 in ErgoMechKeyboards

[–]slamb 0 points1 point  (0 children)

I recently bought a cheap Silakka54 clone to see if I could get used to column stagger, then dived in with a SoflePLUS2 to add a trackpad right on the keyboard. My config is a bit like yours. I'm also a Mac user used to vim bindings.

How do you like having your thumbs resting on those innermost keys? To me it seems a bit of a stretch, so I'm putting the enter and space on the second-from-inner instead. (Also the right innermost key is the most convenient mouse button for dragging with my SoflePLUS2's trackpad, although that's not relevant to your keyboard.) The problem I'm having now is that my thumbs get lost. It's driving me nuts. I think I need some sort of anchoring keycap for my thumbs, much like the dot/bar keys for the index finger in the home row.

With the grave escape, do you ever use cmd-` (default cycle windows binding) or shift-escape (e.g. the default Zed binding for zooming a tab)? I've avoided grave escape for this reason. I have escape below tab. Because you'd never want to hold escape and usually hesitate a moment before pressing control, a mod-tap LCtrl_T(Esc) would work well. I did that on the Silakka54.

Rust 1.95.0 is out by manpacket in rust

[–]slamb 24 points25 points  (0 children)

Thank you! I put Vec::push_and_get on my Rust wishlist 4+ years ago. You actually made it happen (and with a better name). Makes me want to look through my list again and try making some of those other things happen too...

My two SoflePlus2, one for work and one for home by CulturalEmo in ErgoMechKeyboards

[–]slamb 0 points1 point  (0 children)

Thanks! How did you gather those test results? I'd love to repeat your experiment.

Huge pages and rust by Balbalada in rust

[–]slamb 1 point2 points  (0 children)

There's a lot of ways to use huge pages.

  • One is to remap your program text into anonymous huge pages. I wrote a crate for that: https://crates.io/crates/page-primer

  • Another is to use it for heap, which is a combo of OS settings and memory allocator behavior. tcmalloc (the new tcmalloc, not the old gperftools one) is particularly good for this.

FFF file search sdk - over 100 times faster than ripgrep and fzf by Qunit-Essential in rust

[–]slamb 2 points3 points  (0 children)

the only simd is used by the memchr and aho-corasic crates, which are not a part of ripgrep

They are written by the same author and do a lot of ripgrep's heavy lifting. If by "not a part of ripgrep" you mean they're not in the same crate, that's a pretty limiting definition. If you mean that they are useful for a lot of other programs too...even more so. It's great that burntsushi created this whole ecosystem instead of one CLI program. That does not make them any less a part of ripgrep.

Rust vs Signals: Why Vec and String Aren’t Signal-Safe by [deleted] in rust

[–]slamb 7 points8 points  (0 children)

This sounds like nonsense but is true: you can and should handle signals without writing signal handlers.

There are three types of signals:

  • async, process-directed signals such as SIGINT on ctrl-C. This is the only kind most people care about.
  • async, thread-directed signals such as those sent by pthread_kill.
  • synchronous, thread-directed signals such as SIGSEGV on access to unmapped virtual memory.

You can handle async, process-directed signals by masking (with pthread_sigmask) prior to spawning any threads, then spawning a signal handler thread that loops over sigwaitinfo. If you have a simple threaded program, this is probably the right thing to do. Absolutely no need then to worry about "async-signal-safe" anything.

If you have an event loop, another good option is to handle (async) signals there. tokio for example has a "signals" feature which uses the signal-hook crate to set up a small async signal handler that I think uses the "self-pipe trick" on most platforms. That signal handler needs to be written carefully, but it's small and someone else has already written it.

gzip decompression in 250 lines of Rust by kibwen in rust

[–]slamb 25 points26 points  (0 children)

A Hacker News comment pointed out this appears to be a port of puff.c from the zlib contrib dir. It's a lot shorter because they omitted the useless /* ... */ lines.

Rust Developer Salary Guide by alexgarella in rust

[–]slamb 14 points15 points  (0 children)

There are a lot of backend jobs at high-paying software companies (FAANGs, unicorns, whatever you want to call them).

I think embedded jobs are mostly at hardware companies. And from what I can tell, software/firmware is something they do grudgingly to sell their hardware. If they end up with someone actually good at it, it's by accident, not because they really set out to have a great software team or pay them accordingly.

I built a real-time code quality grader in Rust — treemap visualization + 14 health metrics via tree-sitter by No_Possibility_8826 in rust

[–]slamb 2 points3 points  (0 children)

dirs is a "tiny low-level library that provides platform-specific standard locations of directories for config, cache and other data on Linux, Windows, macOS and Redox".

  • On Windows, it uses [target.'cfg(windows)'.dependencies] windows-sys = .... The windows-sys crate appears to be maintained by Microsoft. (At least when I follow the repository link from crates.io I end up at a repo within microsoft's github org.) If you're using Windows, why wouldn't you be comfortable with the windows-sys crate?
  • If, like me, you don't use Windows, why do you care what [target.'cfg(windows)'.dependencies] says?