I've had a world for about 8 months or so and everything was fine until 1.14 and then hostile mobs wouldn't despawn all of a sudden. I would fly to this village some times (about 3000 blocks) and there will still be mobs around from the last time I was there which isn't really a big problem by its self but it adds to the mob cap making my game extremely laggy and ruining my guardian farm (note this is not just at the village but everywhere.) I'm willing to turn on cheats if there's a command i can use. please help
This can happen if your render distance is less than 10 chunks, since mobs in "lazy chunks" aren't ticked and don't despawn (even if you switch to Peaceful), including as you move away from the area, which worsens at lower render distances (at 9 chunks only a small area will be affected since the despawn radius is a sphere while chunks are loaded in a square while lower distances will eventually cause mobs to fail to despawn around all sides of the spherical range):
That aside, only mobs in loaded chunks count towards the mob cap and contribute to lag so this can't explain the lag issues you have (for example, one of my worlds has nearly 30000 entities in it, mostly passive mobs that spawned during world generation, but no more than a few hundred are loaded at any one time); more likely, this is due to 1.14 being poorly optimized (a problem which has dramatically worsened since 1.8 and 1.13). At the most, the save size on disk might be slightly increased, affecting loading times (more due to having to (de)serialize the data, not disk I/O) but you'd need a lot of mobs considering that thousands of blocks are saved per chunk, even if blocks are much simpler (the aforementioned world has more than a billion stone blocks alone).