"Octane" is an additive, which is added to gasoline. In short, it "stabilizes" the fuel, such that it doesn't explode during combustion. That's the very short explanation. When the octane rating in gas is too low for the engine, the fuel explodes in the cylinder which does a lot of things, the more important things it does is akin to striking the top of the piston (and consequently the rod, bearing, crankshaft, block, etc) with a sledge hammer with all your might. Using the correct octane for the engine is more like using a rubber hammer rather than a steel one. The load is the same or similar, but it is much less concentrated.
A diesel engine ain't got no spark plugs. The glow plugs only aid in cold starting, once running, they are off. The only thing that gives the engine enough heat to ignite the fuel that is injected is the heat from compressing air; and to an extent the heat from the engine due to normal operating temperatures. Basically at 180 degrees the air gets a "head start" to get hot enough for the fuel to combust on contact with the compressed and superheated air. Let's stop and think about that. On a gas engine, say on my race car, it may have 250-275 psi cranking pressure, which heats the air to roughly 200 degrees or so and that is also based on the volume of air in the cylinder at the intake valve closing event (which is well after bottom dead center...about 50 deg ABDC on mine), the initial air pressure (I use 14 psi but it changes with throttle opening), and a few other variables. On diesel engines, the intake valve is closed much closer to BDC, creating a high dynamic compression ratio, and that air pressure can be 600 psi on some of the smaller ones, and up to 1000 degrees F air temp-that's before the fuel is injected. Fuel is injected at precise timing and precise amounts over a precise duration, such that it burns more slowly and that in itself lends the engine to torque-it can't run 9000 RPM because the burn rate of the fuel is slow and as RPM increases things have to happen a LOT quicker. Anyway, lets say we decide to "inject" Ether into the air intake as a starting aid. You may normally have 600 psi air at or near TDC, and 1000 degrees air temp under compression (using that number as an example), but the Ether will ignite-at a MUCH lower temp and at a MUCH faster rate, and much earlier than TDC, than diesel ever will. This causes a HUGE cylinder pressure spike which the piston, rings, rods, and crankshaft all feel, akin to comparing that 5 lb sledgehammer to using a 20 lb sledge swung 5 times harder on the same surfaces. I've seen head bolts stretched, head lifted off the block, pistons broken (like on my mom's kubota mower), damaged crankshafts and especially bent connecting rods. In the years I did kubota repairs, of all of the engines I had to rebuild or replace, the majority of them were due to starting aids. TONS of them. Overheats were #2 issue. Ran out of or low on oil, #3. Only one normal wear, had like 18,000 hours on a L2900. I guess he must have used it all day every day, dunno. Worn out. Oh and air filters and lack of air filter maintenance, also a big no-no, and expensive lesson to learn.
carbon buildup (usually due to burning oil) just makes the top of the piston "taller" and the bottom of the head "shorter", putting the piston and head closer to each other, and the carbon can cause contact between piston and head. If anything, carbon buildup increases the compression a little which helps the burn, which I think is why on diesel engines if they are using a little oil, you generally don't notice much of a power loss-until it just won't run anymore. By then the compression is just blowing past the rings. Usually. Maybe my theory is wrong on that but that's what it is, a theory.