1frame
Not sure I understand why you have 'while true:' there, as imagine if a collision occurred it would just repeat endlessly?
Try with this?
for raycast in raycasts:
var result = space_state.intersect_ray(raycast.global_position, raycast.global_position + raycast.cast_to,[instigator] + colliders, raycast.collision_mask)
if result.has("collider"):
results.append(result)
colliders.append(result["collider"])
Also, 8 ray casts on 50 objects would be 400/frame unless you are offsetting frames per object (i.e.
Objects 1-10 check on frames 1,6,11,16
Objects 11-20 check on frames 2,7,12,17
Objects 21-30 check on frames 3,8,13,18
Objects 31-40 check on frames 4,9,14,19
Objects 41-50 check on frames 5,10,15,20)
This would improve performance, but result in checks only occurring ~ 12 times a second, which may not be suitable depending on your use case.
Finally, (maybe not a thing with 2D) you can limit the amount of queries with spatial hashing, effectively culling out checks that would occur for objects beyond a set distance away.