I've been playing Minecraft with my friends and it's the first time playing since upgrading my parts a ton. Idk if that has anything to do with this but, while playing, the game will randomly start stuttering every 2-5 minutes for 10 seconds at a time and becomes unplayable. Sometimes it goes back to normal, only to do it again a few minutes later. Other times it crashes the game entirely. I have XMP enabled, a CPU undervolt, which I lowered to see if that was causing it. I've tried everything from lowering the settings to restarting my pc and resetting bios settings. Idk what to do to fix it. Any help would be greatly appreciated. Thanks in advance!

edit: this is what the graphs look like when it happens, this screenshot is from alt tabbed version, but it's almost identical to when it actually occurs
Every few minutes my Minecraft randomly drops to like 20 fps and freezes, sometimes crashes. Please help