HP is derived from torque and RPM. To achieve high RPMs, an
engine generally needs to have a relatively larger bore but shorter
stroke. Look at bike engine design to get an idea.
Higher compression is directly related to higher torque, not HP.
This is why diesels usually have high torque. Add this to the fact
that it is not unusual to turbocharge diesels, and you have high
torque numbers.
If the compression is too high for a petrol engine, the air fuel
mixture might preignite or detonate. This is obviously very bad for
the engine, causing melted pistons, broken rods and so forth. There
are some solutions such as running higher octane fuel, lowering the
in-cylinder temperature such as using water injection, running a
less aggressive cam profile, lowering the compression by running a
thicker head gasket etc.
Most engines have 3, 4 or 5 valves per cylinder, with 4 valves per
cylinder being the most common on today's vehicles. 5 valves are
usually found on sports cars like Ferraris and even Audi. There are
pros and cons to each design, with higher number of valves
generally leading to a more snappy response in exchange for loss in
low end torque.