HNHacker News
TopNewBestAskShowJobs

Farmadupe

162 karma · joined January 21, 2021

submissionscomments
Farmadupe··on ZF makes magnet-free electric motor uniquely compact and competitive
Out of interest, what could make such a design better than a traditional inductive motor? Such motors already suffer inductive losses, and do not need slip rings or brushes, and presumably do not an additional set of windings to transfer power to excite the stator?

Just could the two sets of coils be optimized for their own purposes?

Farmadupe··on ZF makes magnet-free electric motor uniquely compact and competitive
I know press releases never describe anything that's actually novel, but it looks like they're just describing an asynchronous induction motor? I'm wondering if this release is implicitly pretending that some "low slip ratio" motor is "basically" synchronous

Just guessing, does ZF mostly put out induction motors, and they need to make them look less unfashionable so that people choose them for new designs?

Farmadupe··on Railway Oriented Programming
Download counts don't mean very much here as I'm fairly sure both crates are common transitive dependencies. Or in other words, millions of programmers aren't individually choosing Anyhow or Thiserror on a monthly basis -- they're just dependencies of other rust crates or apps.

And agreeing with the other reply, nobody jumps up and down with joy when choosing an error handling crate. You pick the right poison for the job and try not to shed a tear for code beauty as you add in error handling.

Farmadupe··on Exploring the Internals of Linux v0.01
Im assuming the "halt and catch fire" thing is only really possible on pre-microprocessor machines built of discrete components, where the individual parts are small enough to overheat by themselves if driven wrong.

I'd guess the physical CPU package of an i386 would cope just fine with the few (hundreds?) of gates toggling in that small loop.

I wonder if it might be possible to do on a modern FPGA, if you artifically create some unstable circuit and pack deliberately it in a corner of the die?

There's probably some AVX512 concoction that would be the closest equivalent on a modern X64. There's probably an easy experiment -- if that concoction makes CPU freq drop and also makes whole-package thermals drop, it /could/ be due to localized die heating.

Farmadupe··on The Power of 10: Rules for Developing Safety-Critical Code [pdf]
just a few drive-by comments:

First and most important, the title claims these are safety-critical rules, but the conclusion says that they are only being used on mission-critical projects. I get the feeling that there might have been some late-change copyediting done here, as the content is far too generalizing to be taken seriously in any specific safety critical context, and hopefully the author would have known that.

* Agree that many safety-critical coding standards are a grab-bag of sometimes dubiously-valuable rules.

* Agree with the implication that stylistic guidelines are almost totally worthless, and may distract reviews from their core task of finding functional errors.

* The document states that manual review of large cases may be infeasible, but I have never worked on a project that didn't mandate it. Drudgery goes hand-in-hand with safety-critical, and mindnumbing close review is an accepted element of this.

* Agree that less rules is good, but the author doesn't justify why 10 rules is the best. Unfortunately this is a field where correctness trumps easiness or simplicity, and any class of error with unacceptable risk to life/limb must be prevented. Thus any ruleset cannot justify itself simply because it is small.

* In fact, there are many wordings in this document that are generally-unacceptable because they are admitting incompleteness in the general case (and therefore unsuitability for any safety-critical purpose), such as "Although such a small set of rules cannot be all-encompassing" or "In return, it should be possible to demonstrate more convincingly that critical software will work as intended"

commentaries on specific rules:

* rule 4: "No function should be longer than what can be printed on a single sheet of paper". In my experience, readability is not always improved by limiting function length. The main goal of safety-critical be correct (and hopefully be obviously so). Sometimes splitting up code is harmful to this. (also this is actually a stylistic rule of the kind rejected in the 2nd paragraph of the document.)

* rule 5: In the safety-critical domain, defensive checks and "assertions" are usually considered at low-level-design. It's generally unacceptable for a coder to "just" insert defensive behaviours into the implementation, because all such behaviours must be analyzed for correctness. I don't disagree with the idea behind this rules, but a coding standard is the wrong place for it.

Farmadupe··on Show HN: RISC-V core written in 600 lines of C89
Considering it's allocation-free, maybe it's an ultralight/ simulator for checking large quantities of compiler output? (i.e no VM to create and destroy for every testcase)

Or the same but for testing some verilog/vhdl CPU implemetation in a simulator?

Or since it's only 500SLOC, maybe it's just for fun!

Farmadupe··on Is life too short to fight Rust's borrow checker?
Honestly I think your observation is mostly right... if you don't have a hard performance requirement, then rust probably isn't the best language to write your code in...
Farmadupe··on Avoid exception throwing in performance-sensitive code
GP might have been referring to undefined/invalid behaviour (whether in the language or in some OS syscall or whatever). After the demons came out of your nose you can never fix the problem, so there is no point trying to handle the error.

Otherwise I agree with you, that library code should not fail/crash/exit(1) just because of some judgement about recoverability, and out to clean up after itself before passing control back to the caller. If the user wants to fix some ENOSPC deep in my library by shelling out to "rm -rf /" and then trying again, that's fine by me, and this should be reflected in the API.

Farmadupe··on Boeing’s 737 Max Software Outsourced to $9-an-Hour Engineers (2019)
Aerospace still uses traditional waterfall processes (usually called the 'V' lifecycle in the industry because if you put a 90 degree bend in the waterfall it looks like a V).

The flow of responsibilities is strictly hierarchical. If Boeing specified to to their outsourcers that the software should have read from two sensors, then the outsourcer would be 'in the wrong' if they didn't implement that. With a strict interpretation of the rules Boeing doesn't necessarily have to check their outsourcer's work (In Safety-Critical the outsourcer has not just a commercial but also a moral obligation to perform all actions with competence)... But at the same time, because Boeing retains overall responsibility for its products no matter who it subcontracts to, it would be a mistake to not double check the work.

So to at least some extent (at least with moral-tinted glasses), it doesn't actually matter whether or not the fault was introduced by the subcontractor or not. Boeing is responsibility either way, Answering your question only tells us if the subcontractor is also at fault.

It's very important to note that in the Aerospace world, the subcontractor's moral duty only requires them to do exactly what they're told to do (assuming that the subcontractor was only reponsible for software design and not systems design). If Boeing told them to use one sensor, then the subcontractor has done nothing wrong if they failed to notice that this was fundamentally unsafe.

Farmadupe··on This Year in Embedded Rust
Yes I agree such a system is definitely embedded.. I think I was deliberately constructing a straw man in a (bad) effort to poke fun at people such as myself who have 'opinions' on what embedded 'really is'... "640k is enough for anyone" "C compilers are for people who cant write good assembly" etc etc.. https://xkcd.com/378/

I think it's possible to accidentally use that straw man to justify fears when looking at embedded rust.. But as other people have pointed out in this thread, just because rusty interrupt handlers look weird doesn't work any better or worse than one written in C.

Farmadupe··on This Year in Embedded Rust
> 1. A huge chain of dependencies.

I think there is another side to this coin though. IMO there are too many embedded shops that overlook reliable 3rd-party code in favour of spending man-hours growing their own code from seed instead. Or if not that you spend days debugging some greybeard coworker's "Oh I think I wrote something like that 25 years ago for a PDP-11, I'll just email it to you.."

But to be honest I don't really disagree all that much -- As much as the embedded world needs to keep up with the times, there's no way that the level of audit required for a reliable embedded project just can keep up with how quickly crates are being changed.

> 2. A big departure from how things used to be done in this world.

Sometimes I cringe too when takes a massive server board with 9999GB of RAM and a 4g modem and calls it "embedded" just because they screwed it to the side of a helicopter... But if the root question is "will rust be viable on a puny AVR" I hope that the answer is definitely yes.

Farmadupe··on Does the Bronze Garbage Collector Make Rust Easier to Use?
I'm not 100% sure, but I think the OP was talking about the overhead of lifetime management for objects that don't live for a very long time. Or maybe objects that don't have "interesting" lives.

One example in my head individual strings that need to be constructed dynamically but live for the lifetime of the application (better to leak it with Box::leak or lazy_static! than pollute all code with lifetimes)

Another is writing in lifetimes for single purpose objects that live on the stack and might only ever get passed by ref into a single function and then get destroyed soon after.

Lifetimes are super important in rust and are a core part of the language, but in such degenerate cases they take up a lot of programmer effort for little benefit. In my head a "automatic" solution such as GC /could/ have a home in the language. Perhaps this would make rust a slightly better fit for really complex monolithic GUI apps (word processing, spreadsheets, CAD) where full GC would be performance-onerous but data lifetimes would be too complex for rust's strictly ordered lifetime concept

Farmadupe··on Some Whales Can Eat Upwards of 16 Tons of Tiny Shrimp a Day
One of the most thought-provoking aspects of information theory is that when someone says something interesting in a small amount of words, it's indistinguishable from line noise.

tldr; I've never read Overshoot either but I thought the post had an interesting perspective

Farmadupe··on Practice Problems for Hardware Engineers
For context I'm in the safety critical industry where everything is old and slow, and you're slightly more likely to see FPGAs for "traditional" non-signal-processing reasons (bundle of logic with deterministic timing, custom PHY when you can't use a COTS PHY for cert reasons, Heterogeneous backup for an MCU etc). So my own thoughts probably skew a bit old fashioned -- strangely that also means that none of the things that you listed are important in view of the world!

In short, what we see in our graduates' teaching is a wrong-assumption that VHDL/verilog design is a bit like designing for 74-series chips, where you work out that you need to splat down a load of and/or/not gates and individually wire them up to some flipflops. This is reflected in section 18 of the problems, where students are asked to design simplistic low-level entities (sregs, muxes, and a single transparent latch). This is wrong because the true building blocks in the bottom of an FPGA are not individual and/or/not gates so there's no use in designing as if they were.

This leads to a situation where people have done their VLSI/FPGA module at university but they arrive without knowledge of core fundamentals such as: * Not clocking flops with data * Design for even mild levels of concurrency (it's common for courses to never get students to make two FSMs talk to each other even in the same clock domain -- pretty sure this document doesn't do this in section 18) * Thus everyday problems such as race conditions and deadlock will never have been covered.

IMO the very-incomplete nature of such courses also which attempts to pile concepts on top of each other too quickly without adequate explanation means that people come out of courses without really understanding how little of the basics that they know.

I accept that universities only ahve so much time to teach their students, and there is little academic pedagogical value in spending time on specific technologies, but the general poor approach could definitely be a lot better.

tldr; I agree that there hasn't been any revolutionary development in HDLs, but most universities missed the mark on teaching the basics when they first wrote their FPGA courses in the 1990s, and they haven't got much better since.

(P.S. if anyone wants to create a HDL without the crippling expressiveness flaws of either VHDL or verilog, I will personally transmute myself into a solid gold toilet especially for them)

Farmadupe··on Practice Problems for Hardware Engineers
Gone over sections 16..19 - Several questions are clearly nonsense, eg 17.11) "MISR the BIST out of Z!Xussia" or vague eg 16.4b) "Explain at least 2 different types of data Perl/Python can handle". Question 18.h) "33-Dimensional Maze Router" is more of a strange fever dream than an actual question

Section 17 is mostly testing for rote learning, I'm guessing these questions are taken from some university course?

My favourite quesiton is 18.a) "Verilog Syntax/compile errors" which asks you to spot all the mistakes (while ignoring behaviour) and hint at a fix -- but since you're allowed to ignore all behaviour a valid (and reasonable) fix is actually to delete it all.

Beyond these superficial issues I'm mostly interested because my company takes in a lot of EE graduates for beginner FPGA roles, and in our experience almost all undergraduate instructive material is 30 years out of date. Almost all graduates still seem to get taught that VLSI design is done by manually instantiating combinatorial gates and D type flip flops.

And in honesty, I think this document falls into the same trap, section 18 asks the learner to design a transparent latch as a single module. It's very rare to want put a transparent latch in an FPGA, and you'd never dedicate an entire entity to describing one. It also asks for an 8-to-1 mux, a 4 bit shift register, and a 16 bit shift register.

However I think question 18.f) "FSM – Verilog Design of a Crosswalk Controller" is actually a very good example of the right sort of question (for, say midrange/advanced beginner), which will focus the students' attention on "normal" RTL design. Specifically I like that is requires specific clock timings (assert X for 32 clock cycles, assert Y for 10 cycles), as I think off-by-one timing errors in FSMs are a very common problem for beginners.

A more difficult extension (perhaps a part of student's first introduction to concurrency in an FPGA) would be to design a crosswalk controller with slightly more complexity.. maybe multiple buttons or multiple junctions or whatever.

Farmadupe··on Videohash – Perceptual video hashing python package
I get that decoding only keyframes will be much faster, but how can codec independence be maintained when different codecs will insert keyframes at very different points?

Could such an algorithm ever find a duplicate between say a GIF (every frame is a keyframe) vs any modern codec with very few keyframes?

(or is this optimization specifically for videos known the be encoded with the exact same codec, and specifically with a static keyframe interval?)

Farmadupe··on Videohash – Perceptual video hashing python package
As other posters have commented, hashing schemes like this are not really robust to a few very simple transformations, such as slight offsets in time, and cannot detect if one video is a clip from another.

Practically you can only expect such a tool to match up "reencodings" from one format to another.

Because of this IMO it's worth including the video length as a separate field within the hash. That way when you are doing a search you can sort the videos by length then only calculating the hamming distance for videos of similar length (a short video will never be a duplicate of a long one even if the perceptual hashes are close)

Unfortunately when all videos are the same length this doesn't change the O(n*2) time complexity, but assuming that they are not, this optimization should give a significant search time benefit and false positive reduction for large datasets.

I haven't actually checked what the author is doing, but for the sake of not having to decode entire videos (very CPU intensive) it's worth limiting the hash generation process to a small portion from the start of the video (somewhere between 30 seconds and 5 minutes has worked for me depending on the content). As well as being saving time this helps you detect reencodings where the time base is slightly altered (the frames will diverge more and more as time goes on)

(just adding some of my own experience from my own similar video hashing project!)

edit: inb4 someone complains about O(n*2) and mentions BK trees, for numbers up to ~500k hashes in my own testset a BK tree has always been slower than doing the naive search over a neatly aligned stripe of sorted-by-video-length hashes in memory. (Maybe I need to learn how to do memory arenas for cache locality) (or maybe I need to make my own video hashes be not 500 bits long)

Farmadupe··on When people ate people, a strange disease emerged (2016)
Any chance we've got time for the meta question.. Does anyone have a clue why prion diseases are so popular on HN at the moment? AFAIK it's not something that often turns up in mainstream media? Not even as something they keep in the 'slow news day' draw..

Are we genuinely scared by the idea of getting a prion disease? Is there an actual risk of a prion epidemic? ..or putting my Freud hat on, does everyone on HN share a weird masochistic fetish about 'the next big pandemic'?

For my part I don't really get it, but then maybe it's because I'm british and for us prion diseases have been boring (or rather the news isn't interested in prion diseases) since mad cow disease stopped being a thing 20 years ago.

Farmadupe··on Major disruption on UK rail network after 'cracks found on high-speed trains'
I'm guessing this is probably the usual fight between media trying to overexaggerate stories like this, and PR departments trying to downplay them into nothingness.

GWR's PR might be expecting some a newspaper to release a inflammatory story like "Foreign built trains are so dangerous that they will explode if the hit a bumblebee", and so they will try and put out preemptory statements trying to guide perception and downplay the severity of the situation.

And the media will be expecting GWR's PR to be putting out equally disingenuous releases like "we redefined the metric system for the purposes of measuring cracks and now all the cracks are within acceptable tolerances", so they'll be trying to guide perception to make it as hard as possible for GWR to do that.

Maybe I'm too cynical but but given that this is a fairly new story, I'd assume that GWR's statements would be entirely doublespeak as you say, and media fearmongering to be entirely speculation. There hasn't been enough time for anyone to do enough sleuthing to work out what's really happening.

I guess we'll find out in time whether this is really a big problem or just a flash in the pan. Being a safety critical engineer I'm much more interested in the nature of the problem rather than the scale of the disruption, but quite often the media stops being interested as soon as the problem is fixed. So unless this ends up being a long disruption (like boeing's recent groundings) I guess we'll probably never know.

Farmadupe··on C++ Is 9.4 Times Faster Than Python in Prime Number Test
I think given the naive algorithm of both implementations, and the fact the python and cpp are near transliterations of each other, the article isn't really trying to make the literal statement of the words of its title. Of course the relationship between language semantics and actual raw performance on real hardware is probably a neverending topic.

I guess the article is more trying to make a statement along the lines of "here's how you benefit if you know python and pretend that means you know CPP too", (which seems like a fairly valid way to suck people into learning CPP to me)

Farmadupe··on C++ Is 9.4 Times Faster Than Python in Prime Number Test
I think this feels like an underestimate of the performance difference? I generally keep in my head that C/CPP is roughly 100x faster than python, and the computer language benchmarks game seems to support this (I admit that the solutions on there are uncharacteristic of idiomatic code in many cases but hopefully the python and CPP solutions are equally horrible there).

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

I wonder how you can characterize the difference in speed between the two languages. I think I read somewhere that in the reference implementation of ruby, calling a method in the general case can require several hash table lookups to find the implementation associated with the name of the method. Is that mostly the same in python as well?

Farmadupe··on Parsing baseball files in Rust instead of Python for an 8x speedup
I noticed in the git repository's Cargo.toml that no optimizations are enabled.

If you add opt-level=3 to the [profile.release] section, you might be able to speed up your rust code a little more.

← PreviousPage 2 of 2