I can’t remember where I picked up this tip, but it has been a game-changer in how I practice technically-challenging passages. (If you know a source, please let me know!)
The idea is this: practice only as many notes as you can keep in your head. So, if I’m practicing an unfamiliar passage, and can only memorize the first 3-5 notes at a glance, that’s the size of chunk I should practice.
If the music has an obvious or familiar pattern, such as a common scale or arpeggio, I might be able to memorize more of it at a glance, so I can practice a larger chunk. Or, as I get increasingly familiar with the piece, I might be able to hold more of it in my memory at once, and can graduate to longer passages.
It’s tempting to practice in larger chunks, but start smaller at first to really develop your muscle memory. Gradually build to larger segments as you are able to store them in your short-term memory.