Skip to content

Vector2.clone() performance hit for x86-64 and ARM64? [MOVED] #55542

@JosefWN

Description

@JosefWN

Hello! I'm experiencing a pretty heavy performance hit with Vector2.clone() on ARM64 (M3) and x86-64 in Dart 3.3.3 on macOS/Windows. This is a continuation of google/vector_math.dart#319, which was misplaced.

Example benchmark:

class Vector2CloneBenchmark extends BenchmarkBase {
  const Vector2CloneBenchmark() : super('CloneVector2');

  @override
  void run() {
    for (double i = -500; i <= 500; i += 0.75) {
      for (double j = -500; j <= 500; j += 0.75) {
        final _ = Vector2(j, i).clone();
      }
    }
  }
}

AOT:

CloneVector2(RunTime): 135596.2 us.

For comparison, the same benchmark loop with a custom PointDouble(i, j) + PointDouble(j, i) completes in 9000 us. Only creating and cloning a Vector2 is 15-20x slower than creating two PointDouble and adding them to form a third.

It could be completely unrelated, but the other day I observed another heavy performance hit for the double implementation of i.remainder(j) which seems to occur across different platforms: #55479.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.triagedIssue has been triaged by sub teamtype-performanceIssue relates to performance or code size

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions