HNHacker News
TopNewBestAskShowJobs

jtrueb

227 karma · joined October 15, 2023

Rust, C++ full full-stack (embedded wearables to ML)
submissionscomments
jtrueb··on Shift-to-Middle Array: A Faster Alternative to Std:Deque?
Since I often use a sliding window, I made a Rust implementation and was surprised with how performant the VecDeque implementation was.

The MidVec was only faster than VecDeque when doing batch inserts and removals with my implementation.

https://gist.github.com/trueb2/9c0a23aa012f56d4c3d50afe8acf6...

jtrueb··on Silicon Labs Shrinks Wireless SoCs to Extend BLE to Miniature Devices
The nRF54L15 looks better in most aspects. I mention the nRF52840 as it is a veteran in the space with a rich ecosystem at 1mm larger.
jtrueb··on Silicon Labs Shrinks Wireless SoCs to Extend BLE to Miniature Devices
Is this not just a worse version of the nRF52 and nRF54 lineup? Larger size, fewer hardware peripherals, lower radio sensitivity. What is the new thing for this chip?
jtrueb··on Samsung Q990D unresponsive after 1020 firmware update
A lot of folks in this thread say rollback to a known firmware version is required. Where are they getting all this microcontroller ROM?
jtrueb··on Tips for using Gemini 2.0 for PDF ingestion
Anyone have recommendations for chip datasheets? Ive explored a couple options so far, but getting some bitfields wrong is super annoying.

I see plenty of examples like the one here that are on easier extractions. A PDF to HTML or Markdown converter will probably get it right with OCR.

jtrueb··on The best way to use text embeddings portably is with Parquet and Polars
Polars + Parquet is awesome for portability and performance. This post focused on python portability, but Polars has an easy-to-use Rust API for embedding the engine all over the place.
jtrueb··on Rust Is Eating JavaScript
You left out Leptos!
jtrueb··on Using 2 Editors Because Xcode Is Dumb
Xcode is so slow and painful that I primarily use Cursor now to pseudo-lint, format, and generally edit. Switching over to Xcode just for the things that have to be done in Xcode.

There is something wrong with the IDE if an LLM has better response times.

Separately, Cursor Composer is awesome.

jtrueb··on Kalman Filter Tutorial
You can keep telling this, but this “esoteric” math is often too much for the people actually implementing the filters.
jtrueb··on Kalman Filter Tutorial
Every time that one comes up, this one comes up https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Pyt... (and vice versa)
jtrueb··on Compiling C to Safe Rust, Formalized
Yes, I’m just saying how it kicks in basically immediately (O1).
jtrueb··on Compiling C to Safe Rust, Formalized
Interesting how higher optimization levels didn’t really help speed up rust in the O level comparison
jtrueb··on Fish shell announces 4.0 release
If there was a good headline on here to drop in the “Written in Rust” slug, this would be it.
jtrueb··on Error Stacking in Rust
Which statically typed language do you find most agreeable?

Same question for any language.

jtrueb··on Asynchronous Rust on Cortex-M Microcontrollers (2023)
The main executor that you get when main is spawned is preemptive. You can do compression, math, etc there for as long as you like. You can spawn other executors from the main with assigned priorities. Using SWI executors for high priority cooperative scheduling can be great for timely handling of hardware peripherals. You slap an async Channel in between tasks that run on the same or different executors.
jtrueb··on Asynchronous Rust on Cortex-M Microcontrollers (2023)
Async embedded rust is fantastic. Absolutely nailed it once a couple more unstable features stabilize.

Also on cortex-m, you can put an executor on each cooperative priority but also you can put an executor on the main priority. That means you have one preemptive executor for blocking tasks and a couple cooperative choices.

I should add that I saw a huge reduction in RAM usage going to Embassy from Zephyr for a couple complicated applications. (on the order of 100KiB with all the stack and buffering reductions)

jtrueb··on Show HN: Unbug – Rust macros for programmatically invoking breakpoints
Is it a minority? Are there stats posted for this?

Only recently have I had some projects switching to stable after their required features stabilized.

jtrueb··on Battery-Free Bioelectronic Implants
Hey, that’s our stuff. we do a ton of different types of battery free stuff beyond this.

Check out bioelectronics.northwestern.edu and rogersgroup.northwestern.edu

jtrueb··on Creating Runtime and Application Images with JLink (2021)
This has nothing to do with SEGGER JLink. I wonder which is older.
jtrueb··on Perhaps Rust Needs "Defer"
I would totally use a Swift-style concise defer. Writing the idiomatic wrapper struct and implementing Drop is obtuse and repetitive. Both wrapper structs and the scopeguard macro approach have to be wasting compilation time.

I have a lot of FFI code paths that end up easier to understand if you use the C-style instead of the Rusty approach.

Readability and comp time should be important even in FFI code paths

jtrueb··on Brush – A new compatible Gaussian splatting engine
async_std is a nonstandard choice these days, no? I assume this is related to the style of blocking spawned work?
jtrueb··on Blocking code is a leaky abstraction
“This highlights one of the main disconnects between "async advocates" and "sync advocates", which is, when we say something is blocking, what, exactly, is it blocking?”

When I have work on a cooperatively scheduled executor for optimal timing characteristics. Sending work/creating a task on a preemptive executor is _expensive_. Furthermore, if that blocking work includes some device drivers with interactions with hardware peripherals, I can’t reasonable place that work on a new executor without invalidating hardware timing requirements.

Threads and executors can be infeasible or impossible to spawn. I have 1 preemptive priority and the rest are cooperative on bare metal. I can eat the suboptimal scheduling overhead with a blocking API/RTOS or I need the async version of things.

jtrueb··on Building a compile-time SIMD optimized smoothing filter
I think scientific computing in Rust is getting too much attention without contribution lately. We don't have many essential language features stabilized. SIMD, generic const exprs, intrinsics, function optimization overrides, and reasonable floating point overrides related to fast math are a long way from being stabilized. In order to get better perf, the code is full of these informal compiler hints to guide it towards an optimization like autovectorization or branch elision. The semantics around strict floating point standards are stifling and intrinsics have become less accessible than they used to be.

Separately, is Julia hitting a different LA backend? Rust's ndarray with a blas-src on Accelerate is pretty fast, but the Rust implementation is little slower on my macbook. This is a benchmark of a dot product.

```

    const M10: usize = 10_000_000;
    #[divan::bench]
    fn ndarray_dot32(b: Bencher) {
        b.with_inputs(|| (Array::from_vec(vec![0f32; M10]), Array::from_vec(vec![0f32; M10])))
            .bench_values(|(a, b)| {
                a.dot(&b)
            });
    }

    #[divan::bench]
    fn chunks_dot32(b: Bencher) {
        b.with_inputs(|| (vec![0f32; M10], vec![0f32; M10]))
            .bench_values(|(a, b)| {
                a.chunks_exact(32)
                    .zip(b.chunks_exact(32))
                    .map(|(a, b)| a.iter().zip(b.iter()).map(|(a, b)| a * b).sum::<f32>())
                    .sum::<f32>()
            });
    }

    #[divan::bench]
    fn iter_dot32(b: Bencher) {
        b.with_inputs(|| (vec![0f32; M100], vec![0f32; M100]))
            .bench_values(|(a, b)| {
                a.iter().zip(b.iter()).map(|(a, b)| a * b).sum::<f32>()
            });
    }
    
    ---- Rust ----
    Timer precision: 41 ns (100 samples)
    flops             fast    │ slow    │ median  │ mean
    ├─ chunks_dot32   3.903 ms│ 9.96 ms │ 4.366 ms│ 4.411 ms
    ├─ chunks_dot64   4.697 ms│ 16.29 ms│ 5.472 ms│ 5.516 ms
    ├─ iter_dot32     10.37 ms│ 11.36 ms│ 10.93 ms│ 10.86 ms
    ├─ iter_dot64     11.68 ms│ 13.07 ms│ 12.43 ms│ 12.4 ms
    ├─ ndarray_dot32  1.984 ms│ 2.91 ms │ 2.44 ms │ 2.381 ms
    ╰─ ndarray_dot64  4.021 ms│ 5.718 ms│ 5.141 ms│ 4.965 ms

    ---- Julia ----
    native_dot32:
    Median: 1.623 ms, Mean: 1.633 ms ± 341.705 μs
    Range: 1.275 ms - 12.242 ms

    native_dot64:
    Median: 5.286 ms, Mean: 5.179 ms ± 230.997 μs
    Range: 4.736 ms - 5.617 ms

    simd_dot32:
    Median: 1.818 ms, Mean: 1.830 ms ± 142.826 μs
    Range: 1.558 ms - 2.169 ms

    simd_dot64:
    Median: 3.564 ms, Mean: 3.567 ms ± 586.002 μs
    Range: 3.123 ms - 22.887 ms

    iter_dot32:
    Median: 9.566 ms, Mean: 9.549 ms ± 144.503 μs
    Range: 9.302 ms - 10.941 ms

    iter_dot64:
    Median: 9.666 ms, Mean: 9.640 ms ± 84.481 μs
    Range: 9.310 ms - 9.867 ms

    All: 0 bytes, 0 allocs

```

https://github.com/trueb2/flops-bench

jtrueb··on Averaging is a convenient fiction of neuroscience
It is a low-pass filter in the frequency domain with a roll-off that is not smooth. I quite like [1] as a quick reference.

https://www.analog.com/media/en/technical-documentation/dsp-...

jtrueb··on Scientific Visualization: Python + Matplotlib (2021)
How do you use those outside of Latex? Lots of figures are coming from Matlab or Python, where Latex is a non-starter. Is there a cookbook to pollinate?
jtrueb··on One in five genetics papers contains errors thanks to Excel (2016)
Quit using Excel in research!
jtrueb··on Extreme Pi Boot Optimization
I’m sure there are others, but as mentioned elsewhere in this thread ESP32 or NRF70 could take care of this for a lot less (off of bare metal or RTOS if you just need WiFi and Camera.)
jtrueb··on Extreme Pi Boot Optimization
Just stay booted and use a lower power microcontroller … 105mA … that’s not the right order of magnitude
jtrueb··on Linus Torvalds talks AI, Rust, & why Linux is the only thing that matters
That was pretty toxic for a kneejerk reaction.
jtrueb··on Small Strings in Rust: smolstr vs. smartstring (2020)
I made humanize-bytes[1] for that formatting reason (1000 vs 1024). Coincidentally, it uses smartstring to avoid allocations.

[1] https://crates.io/crates/humanize-bytes

← PreviousPage 2 of 3Next →