Hacker Newsnew | past | comments | ask | show | jobs | submit | mtklein's commentslogin

My first skim had me thinking he sent the package in the 90s; sadly it was just three weeks ago.

That's kind of exactly what floats are. You store the log2 of the number, a bit for its sign, and in what remaining bits you have left some fixed-point scaling between adjacent powers.


No, that is not what floats are. A logarithmic number system literally just stores the logarithm of a number (and a sign bit) and manipulates it as a logarithm. The significand is 1, always. So multiplication & division are simply addition & subtraction, respectively. But this simplification for multiplication, division, roots, and powers is counterbalanced by more complex addition and subtraction.[1]

[1] https://en.wikipedia.org/wiki/Logarithmic_number_system


Floats are actually rational numbers with denominators of power of 2.

https://en.wikipedia.org/wiki/Dyadic_rational#In_computing


I think they mean storing just an exponent instead of an exponent + mantissa. Makes multiplication much easier to implement.


As a former Skia contrib, this is cool as heck to read. It's exactly the sort of optimization work we had in mind when we wrote that SkRecord system, and I'm pleased that you were able to make use of nanobench. Back in those days we had just a few small optimizations that we could apply, mostly trying to eliminate unnecessary saveLayer() calls. Very cool to see it done in a modern way with Lean.


Thank you! The SkRecord system was _perfect_ for doing these optimizations. I don't think it would have been possible to do this project without it.


Let me also add that nanobench was a huge help, not just because it was a good benchmarking tool but also because it gave us some confidence that we're measuring the right thing. It's easy to make _something_ faster but hard to know if it's the right thing. Having that come pre-packaged from the project answers a lot of tricky questions that would otherwise be easy to get wrong.


That's how we felt answering performance questions of our own... we needed to know if our work was important, and the tools help keep that focus locked in. I'm no longer on the Skia team, but like, welcome to the Skia team; if you use nanobench, you're legit. :)

I'm the same user name @gmail.com if you ever have any questions. It's been a while but I'd be happy to try to page things back in for a good cause.


Hey, I am the first author of the paper, and thank you so much for the kind words. I am very grateful to you and all the other Skia contributors who've made the Skia codebase so easy to build and develop. I learnt so much about performance benchmarking by reading the nanobench source code too!


Decades ago they used to pull completely off the can (think Jimmy Buffet "stepped on a pop-top").


I should barely be listed as a co-author on what Claude does for me. Hiding Claude's contribution feels about as true as a combover to me.


That's kind of what reddit used to feel like when it was brand new. Can you believe it?


I have found qwen 3.8's coding quality using opencode to be similar to claude or gpt from 6-9 months ago, except much slower.


My rule of thumb is that integer ops cost 1 cycle except divides, floats 3 but maybe divide is a bit more, then integer divides are like infinity at 20+ cycles that cannot be amortized by vectorization.

When you code simd it's best to assume the integer divide instruction does not exist. Just an impossibility, if you need to divide ints, rethink your whole program.


Float divides are still pretty expensive; 8-10 cycles of latency on modern hardware, integer divides being 8-20 cycles. (on Apple M1 both are 8-10 cycles; int div is much worse on older x86 hw)

Integer multiply is also pretty universally 3 cycles of latency, i.e. basically the same as float multiply (or even add!).

What float div definitely has over int div is throughput, as float div comes in vectorized versions on x86 & ARM, and it usually is actually parallelized.

On top of generally fp div generally having higher throughput (M1 gets down to 1 instr/cycle! though int div isn't bad either at 0.5 instrs/cycle; x86 numbers are messy but even 32-bit int div is never better than f64 div, though they're close; also an annoying aspect is that x86 division instrs actually always take a 128-bit divisor, though hopefully a sign-/zero-extended 64-bit value skips the extra work)


Though, if you happen to be dividing by constants, compilers can do a good job of optimizing for that, simd too probably.


They're typically like a 3-cycle op, right? Obviously that's not zero, but as far as floating point ops get it's a cheap as it gets, like an add, mul, fma, that sorta thing.


I am probably dating myself here, but in C the default rounding mode is round-to-nearest and the cost of switching the x86 FPU to truncate (and back) in order to perform the truncation is extremely expensive. Perhaps other instruction sets have truncate-to-integer instructions that ignore the active rounding mode.


Don't forget SubEthaEdit! That was the first multiplayer editor I recall.

Never found a use for this sort of thing once novelty wore off. :/


Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: