Every key-frame edit was updating all grease pencil & mask data-blocks. Change the logic to only update edited data-blocks.