Repository: godot
Issue: FPS tanks when accessing large arrays or spans from _PhysicsProcess
Labels: topic:dotnet,performance

### Tested versions

- Reproducible in 4.3-dev6, 4.1.1-stable, 3.5.3

### System information

Godot v4.3.dev6.mono - Windows 10.0.22635 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 (NVIDIA; 31.0.15.4601) - 13th Gen Intel(R) Core(TM) i7-13700K (24 Threads)

### Issue description

#### While accessing accessing `Array<bool>` elements

##### The setup

Single scene of type `Node` with a script attached:
```csharp
using Godot;

namespace ArrayAccessRepro;

public partial class RootArray : Node
{
    private bool[] _array;

    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        _array = new bool[14_000_000];
        // _array = new bool[10_000_000];
    }

    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _PhysicsProcess(double delta)
    {
        var stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();
        Iterate();
        GD.Print($"Elapsed time: {stopwatch.ElapsedMilliseconds}ms");
        GD.Print($"FPS: {Engine.GetFramesPerSecond()}");
        GD.Print($"Delta: {delta * 1000:F3}ms");
    }

    private void Iterate()
    {
        for (var i = 0; i < _array.Length; i++)
        {
            _array[i] = !_array[i];
        }
    }
}
```

##### The issue

Running such scene would produce logs among the lines of:
```
Elapsed time: 17ms
FPS: 7
Delta: 16.667ms
```

Uncommenting the `_array = new bool[10_000_000];` line and running such scene produces logs among the lines of:
```
Elapsed time: 12ms
FPS: 101
Delta: 16.667ms
```

It can be seen that iterating over the array with 40% more elements tanks the FPS from ~100 to <10. I would not expect such a huge drop of FPS.

#### While accessing `ReadOnlySpan<bool>` elements

##### The setup

Single scene of type `Node` with a script attached:
```csharp
using System;
using Godot;

namespace ArrayAccessRepro;

public partial class RootSpan : Node
{
    private bool[] _array;

    private ReadOnlySpan<bool> Array => _array;
    
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        _array = new bool[2_000_000];
        // _array = new bool[1_000_000];
    }

    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(double delta)
    {
        var stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();
        Iterate();
        GD.Print($"Elapsed time: {stopwatch.ElapsedMilliseconds}ms");
        GD.Print($"FPS: {Engine.GetFramesPerSecond()}");
        GD.Print($"Delta: {delta * 1000:F3}ms");
    }

    private void Iterate()
    {
        for (var i = 0; i < _array.Length; i++)
        {
            _array[i] = !Array[i];
        }
    }
}
```

##### The issue

Running such scene would produce logs among the lines of:
```
Elapsed time: 19ms
FPS: 7
Delta: 16.667ms
```

Uncommenting the `_array = new bool[1_000_000];` line and running such scene produces logs among the lines of:
```
Elapsed time: 11ms
FPS: 100
Delta: 16.667ms
```

It can be seen that iterating over the span with 100% more elements tanks the FPS from ~100 to <10. I would not expect such a huge FPS drop. Even more, it tanks down to sub-10 values with a lover element count than with array.

#### Additional notes

Such a huge drop of FPS only happens while iterating/accessing array or span elements in the `_PhysicsProcess`. If it's changed to `_Process` instead FPS drop is noticeable, but it only tanks to ~50 FPS or so, for both `Array<bool>` and `ReadonlySpan<bool>`.

### Steps to reproduce

1. Open MRP
2. Run scene `RootArray.tscn` or `RootSpan.tscn`
3. Observe logs

### Minimal reproduction project (MRP)

[ArrayAccessRepro.zip](https://github.com/godotengine/godot/files/15471186/ArrayAccessRepro.zip)