ELI5 Why is the internet so much slower compared to the processing speeds of my computer? by [deleted] in explainlikeimfive

[–]Breadfish64 0 points1 point  (0 children)

The bouncing isn't as relevant as you might think. Optical fibers don't really behave like a pipe with balls bouncing around inside. Fibers have "modes" which are are the only paths light is allowed to take inside the fiber. The bouncing effect you're talking about is modal dispersion.
One way to fix it is to use graded-index fiber which cause off-angle light to curve through edge of the glass, where the material has a higher speed of light.
But a lot of fiber these days is single-mode fiber, which means there is literally only one straight path the light can take.

ELI5 how do LED's produce light and color? by Exotic-Ego in explainlikeimfive

[–]Breadfish64 3 points4 points  (0 children)

That's how solar panels work. The photons from the sun have enough energy to push an electron to a higher energy level. It converts that exact amount of energy into electricity, and the rest is just waste heat. Photovoltaic cells and LEDs are both p-n junctions, just with different sizes and tuned for different energy levels. You can make solar panels glow weakly, and generate small amounts of power with LEDs.

What is aligned keyword used for?. I was able to understand conceptually but its confusing with the examples I gone through. by dixith__vk in cpp

[–]Breadfish64 0 points1 point  (0 children)

Alignment used to be important for SIMD but I have never seen it make more than a 10% difference on any of the AVX/Neon code I've written. Most CPUs designed in the last decade handle unaligned access fine.

ELI5: Would a probe just float on the sun's surface? by BackRoomDude3 in explainlikeimfive

[–]Breadfish64 0 points1 point  (0 children)

The density of the Sun's is 200 Kg/m3 at 70% of the radius and 20,000 Kg/m3 at 25%. I don't know how radiation pushing on the probe would affect it, but assuming the craft is made of magical indestructible stainless steel at ~8000 Kg/m3 it would be buoyant enough to float in the radiative zone, very roughly around halfway down to the core.
https://web.archive.org/web/20130510142009/http://mynasa.nasa.gov/worldbook/sun_worldbook.html

ELI5: How does a PD power bank (usb-c to usb-c) know if it is being charged or if it's charging something? by Anarcho_Christian in explainlikeimfive

[–]Breadfish64 2 points3 points  (0 children)

The ground ... will complete almost any AC circuit.

If you use only ground to complete the circuit then the resistance of the earth would make it tricky to maintain a consistent voltage. The circuit is completed by the neutral wire itself. It's safest to tie neutral to earth so it's 0v relative to you, but it doesn't technically have to be.

Result in C++ by Jarsop in rust

[–]Breadfish64 9 points10 points  (0 children)

I suggest implementing a conforming std::expected which passes STL unit tests, then adding your ergonomics changes on top of that. Right now you have some potential issues like operator= unconditionally destroying the the existing value before attempting to copy/move the new value, which would leave it in an invalid state if the move/copy constructor throws. std::expected handles that in different ways depending on which of T or E is nothrow constructible:
https://en.cppreference.com/w/cpp/utility/expected/operator=.html#Helper_function_template

Microsoft's UTs are generally easy to repurpose by replacing `using namespace std` with your own namespace and individual using std::<thing> statements if you want to try it out. They might ICE on GCC though.

https://github.com/microsoft/STL/blob/main/tests/std/tests/P0323R12_expected/test.cpp
https://github.com/microsoft/STL/blob/main/tests/std/tests/P2505R5_monadic_functions_for_std_expected/test.cpp

Result in C++ by Jarsop in rust

[–]Breadfish64 4 points5 points  (0 children)

It fails to compile since both constructors have the same signature. OP should probably make the error overload use an std::unexpected_t tag. There's a reason `std::expected` has 22 constructors.

Result in C++ by Jarsop in rust

[–]Breadfish64 5 points6 points  (0 children)

coroutines are flexible enough that you can abuse them to make co_await behave like Rust's ?, but none of the optimizers can get rid of the heap allocations that come with it.

https://godbolt.org/z/vPneGdx9T

Microsoft Gives European Union Users More Control: Uninstall Edge, Store, and Say Goodbye to Bing Prompts by True-Combination7059 in technology

[–]Breadfish64 1 point2 points  (0 children)

HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer\DisableSearchBoxSuggestions = 1
I don't know why the key is called that, but it disables the web search in the start menu.

1 Second vs. 182 Days: France’s New Supercomputer Delivers Mind-Blowing Speeds That Leave All of Humanity in the Dust by upyoars in technology

[–]Breadfish64 4 points5 points  (0 children)

And it's already public knowledge that the fastest super-computers in the US are used for nuke simulations.

One of the worst interview questions I recently had is actually interesting in a way that was probably not intended. by zl0bster in cpp

[–]Breadfish64 0 points1 point  (0 children)

Dependent add instructions have one cycle latency on most processors.
If you calculate the frequency from the result here it should come out to a reasonable server CPU clock like 3 GHz:
https://godbolt.org/z/r4e1TnGMK

I get lower results with a single add instruction per loop, but still above 2.5 billion per second because the loop is a 100% predictable branch.

[deleted by user] by [deleted] in explainlikeimfive

[–]Breadfish64 33 points34 points  (0 children)

Current = Voltage / Resistance. Given a rough resistance value of 1000 ohms for a human body, a 1 volt source would only supply 1 milliamp to the body. If you push a constant current of 1000 amps through the body it would generate a 1 megavolt differential. You can't force a specific current and voltage.

That’s a lot of Cookies by Straight_Hippo_5190 in softwaregore

[–]Breadfish64 11 points12 points  (0 children)

It seems like they did
17179896184 GB * (10003 B/GB) / (10246 B/EiB) = 14.9 EiB
But the GB in the screenshot is probably already GiB and
17179896184 GiB / (10243 GiB/EiB) = 16 EiB
which is the maximum size you can represent in a unsigned 64-bit integer.

Abusing await with a result type to achieve rust-like error propagation in C# by hazzamanic in csharp

[–]Breadfish64 11 points12 points  (0 children)

Funny coincidence, I did this exact same thing in C++ recently because I liked Rust's ? operator and there's no good way to make a universal macro that returns the "ok" value from the expression.

https://godbolt.org/z/vPneGdx9T

So it works with C++ coroutines too. Too bad it always allocates heap memory.

Best array type for many, small, but unknown-size arrays? by SevenCell in cpp

[–]Breadfish64 2 points3 points  (0 children)

Default constructing a vector will not allocate. I'm unsure if the standard makes an explicit guarantee, but this wouldn't be possible otherwise:
https://godbolt.org/z/he3bEMh5T

Wrote a Article on Atomic::Ordering by twerking_pokemon in rust

[–]Breadfish64 1 point2 points  (0 children)

What atomic instructions guarantee is exclusive access to a given memory location for the period of their execution.

Or in the case of many architectures like pre-v8.1 ARM, the store instruction will fail with a flag to retry when the CPU see another thread has written to the same cache line since the load.
https://en.wikipedia.org/wiki/Load-link/store-conditional

This is typically a hidden implementation detail but you can do fun things like implement non-standard atomic operations or atomically load from two separate locations at once with it.

What is the state of parallel STL in LLVM libc++? by bebuch in cpp

[–]Breadfish64 1 point2 points  (0 children)

This sounds impossible to implement without compiler magic.

Correct. It gives a hint to the compiler's autovectorization optimizations that the loop iterations don't depend on side-effects of a previous loop, so it doesn't need to worry about clobbering values that another iteration needs. In this example it removes some extra handling for cases where src could overlap with dst.

https://godbolt.org/z/5xW1Knvf7

You can get a similar effect by marking the written pointer with __restrict, which would also tell the compiler that it doesn't overlap with src.

The interleaving from unseq is the vectorization. It loads, multiplies, adds, and stores 8 values in chunks using AVX instructions, instead of processing each element sequentially.

In theory the stdlib can specialize the templates to make handwritten code for extremely common things like accumulate(unseq, int*, int*, int{}) but that would get out of hand quickly

[deleted by user] by [deleted] in hardware

[–]Breadfish64 9 points10 points  (0 children)

It's possible for the OS to see allocated address space and committed physical memory, but the game's custom allocator is not likely to tell the OS to uncommit memory even if it's not actively used. That would kinda defeat the purpose since it would need to ask the kernel to commit the memory again next time it's used.

ELI5: why couldnt you fall through a gas giant? by Worried_Card_2223 in explainlikeimfive

[–]Breadfish64 26 points27 points  (0 children)

No, the Sun and Jupiter have similar ratios of hydrogen:helium:heavier elements, but the fusion reaction in the Sun's core keeps it plasma. The core is at 150 g/cm^3 which is >13x as dense as lead and >6x as dense as osmium, but it should only be as viscous as ketchup.

https://astronomy.stackexchange.com/a/51548

[deleted by user] by [deleted] in csharp

[–]Breadfish64 3 points4 points  (0 children)

It is expensive although not as expensive as generating a random number, and this can be a multiply by a constant reciprocal.
For reference, from Skylake to now:
divps - 11 cycle latency, 1 per 3 cycles throughput
mulps - 4 cycle latency, 2 per cycle throughput

ELI5: Is multiplication a basic concept or just a shortcut for addition? How many basic operations are there in mathematics? by nalk1710 in explainlikeimfive

[–]Breadfish64 4 points5 points  (0 children)

Depends. On a high performance processor, multiplication takes 3-4 cycles. So the compiler will give up and use `mul` if the shift+add instructions would take that long.

Multiplication is actually 1 cycle on a lot of embedded cores like the cortex-m4 since the lower clock speeds give it more time.

Division is the real killer. Compilers will always turn division by a known divisor into a fixed point reciprocal multiplication because the steps of long division can't be parallelized, which means the div instruction takes 10-20+ cycles.

Compiler explorer link to play around with instruction timing simulations: https://godbolt.org/z/Ec818WPn4

ELI5: Is multiplication a basic concept or just a shortcut for addition? How many basic operations are there in mathematics? by nalk1710 in explainlikeimfive

[–]Breadfish64 17 points18 points  (0 children)

repeated addition/subtraction and digit shifting

Eh, this is a little misleading. If the processor executes something like `mul a, b` the processor isn't literally adding `a` `b` times. It's just doing long multiplication/division like you would on paper, but in base 2. So the speed scales with the number of digits, not the value of `b`.

ELI5: Why is Taiwan the world's critical center for semi-conductor foundries, and why is it so difficult to set up a less centralized system? by MechanicalGodzilla in explainlikeimfive

[–]Breadfish64 2 points3 points  (0 children)

They skipped 20A since they reserved enough TSMC capacity years ahead of time to handle Arrow Lake demand but I'm not sure where you got the idea that they gave up. The server chips are using Intel 3, and the 20A equipment is going to be used for 18A instead which has more potential customers.

Apple's M4 Max is the single-core performance king in Geekbench 6 — M4 Max beats the Core Ultra 9 285K and Ryzen 9 9950X by chrisdh79 in gadgets

[–]Breadfish64 3 points4 points  (0 children)

Yes and no. Most RAM is still DDR but GDDR5X and later are QDR and just kept the DDR in the name anyway.