My advice is to change the frame of your problem. Right now, you are wondering how to cram more mathematics into the same amount of time. Instead, I suggest thinking about how you can make the best use of the time available. There are only so many hours per day, and far fewer of them that we can reasonably dedicate to thinking really hard.
First of all, supplementing your coursework with additional study is a perfectly fine thing to do. Working out problems is a great way to help learn the concepts, and using additional texts can help to clarify issues compared to looking at only one textbook. Your experience here can also help to direct your further study, when it comes to selecting topics within your degree work, and making career choices in general: paying attention to what you find interesting or boring, easy or hard, will yield good information. But burning yourself out by trying to solve all the problems no matter the cost, is obviously very bad.
Overall, "there is no royal road to commutative algebra", and we shouldn't expect it to be easy to learn. I'd like to propose to you that since the road is indefinitely long, and there are other roads to travel as well, it would be useful to do a few things to shape the study -
- Set concrete milestones for what you would like to learn. There is no limit to the time that you could spend, especially if you are just working through a textbook linearly from front to back, and judging for yourself whether you have a sense of feeling proficient at what you are doing. Instead, you should decide on specific topics that you feel are necessary, and on success criteria that are more measurable. Rather than "achieve total godlike mastery of algebra", the goals can be more like "be able to reproduce the definition of the field of fractions of an integral domain and prove its universality property". This allows you to not focus on other things, and also gives you a stopping condition for the thing you are focusing on currently (i.e. no matter how fascinated you are by the concept of torsion submodules, you must allow yourself to stop thinking about them at some point, or you will never do anything else). Feel free to discard topics ruthlessly; you can always come back to them if need be.
- Take note of your short-term progress. In pursuit of one of these milestones, at any given moment you might be stuck or making only very slow progress. It is surprisingly hard to notice when you are stuck. Very often, the correct tactic at these moments is not to carry on. If you are tired, hungry, etc., then you will be better off addressing that than desperately ploughing on with the mathematics. After a break you can also determine whether it is actually worth sticking with the specific problem. Maybe the right move is to work on something else, and return to the original issue later or never. You have still learned something, even if it's only that the topic is harder than you estimated. Or, now feeling fresher, you may come up with the breakthrough technique after all.
- Set a strict time-box. It's tempting to feel that the key insight is just around the corner. If you are having trouble with actually disengaging, then pre-commit to setting a timer (literally!) for when you are going to leave your desk. When the bell rings then it's time to drop the pencil. At times you may feel like you're racing against the clock - but another session will come along soon enough. The point is that by budgeting your time, you are not only protecting the rest of your life against mathematical intrusion, but also being more effective at using the resources you do have - diminishing returns set in pretty quickly, when it comes to slogging away.
What this boils down to is a change in mindset. Instead of trying to cram more and more study into a finite time, you treat your time as fixed and then carefully select what to do with it. Recall that even top athletes do not train all through the day and night. They make the best use of the time available and try not to destroy themselves in the process.