A PI who is known to kick out some students, and graduate others after 10 (!!!!!) years, is not one you are likely well-placed with. I would certainly look into other labs. Leaving after such few months, when the period additionally was not officially grad school, might not be very hard. Just talk to other PIs, and, if possible, just profess greater interest in their topics as opposed to fleeing a colleague of theirs; it's better to leave on officially good terms, even if they weren't so good.
However, you cannot expect to always have a thesis topic served on a plate, and for sure not right when you start your Ph.D. - at least judging this from the U.S. perspective (if you are elsewhere, ignore the first half of this paragraph as all my experience is with the U.S. system). In many fields, finding your topic is an important part of writing your Ph.D. You might want to ask around in other groups or labs how things are there. Some advisers (I call them 'drawer advisers' - "What should I work on?", and the adviser opens a figurative drawer with topics they could not pursue yet) will do this for you; others won't. You also should listen to suggestions, and it's a bit early to expect your "optimizations" to be really, and always of use. If you genuinely dislike the PI's approach, you should see this as another reason to consider another lab (and try to be reasonably patient there).
The first version of this answer was wondering what exactly the adviser says or does which is upsetting. After your clarification, he seems unduly harsh, and I can see how that makes you feel depressed about your situation. I'm not convinced (yet) that this is because of sexism, but he sounds rude in ways that are simply not constructive for the close work necessary in a lab. Whatever the reason, it sounds bad, and I wouldn't take it. Some reasons (sexism for sure) could allow you to officially complain using your university's grievances procedures, but that's not a great start 4 months in.
Really, ask around, and see what else is out there. If nothing works at your current school, consider a gentler Ph.D. program approach with a period of coursework first, at another university, maybe in another country, a larger program size, and the almost inevitable student bonding which can be your support network.