Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/graphicscommand: optimize prependPreservedUniforms #3144

Open
11 tasks
hajimehoshi opened this issue Oct 25, 2024 · 2 comments
Open
11 tasks

internal/graphicscommand: optimize prependPreservedUniforms #3144

hajimehoshi opened this issue Oct 25, 2024 · 2 comments
Milestone

Comments

@hajimehoshi
Copy link
Owner

hajimehoshi commented Oct 25, 2024

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

What feature would you like to be added?

prependPreservedUniforms tends to be a hot spot for performance, especially when rendering a lot of sprites. Here is the profiling result of examples/sprites with 10000 sprites:

image

atlas.Image.drawTriangles is the heaviest process, but this does a little complicated things. Let's focus on prependPreservedUniforms.

There are some ideas to optimize this.

Why is this needed?

No response

@hajimehoshi hajimehoshi added this to the v2.9.0 milestone Oct 25, 2024
@hajimehoshi
Copy link
Owner Author

BCE result:

% go build -gcflags=-d=ssa/check_bce ./internal/graphicscommand
# github.com/hajimehoshi/ebiten/v2/internal/graphicscommand
internal/graphicscommand/command.go:51:17: Found IsSliceInBounds
internal/graphicscommand/command.go:228:16: Found IsInBounds
internal/graphicscommand/command.go:229:16: Found IsInBounds
internal/graphicscommand/image.go:179:28: Found IsInBounds
internal/graphicscommand/image.go:183:28: Found IsInBounds
internal/graphicscommand/image.go:185:62: Found IsSliceInBounds
internal/graphicscommand/image.go:217:7: Found IsInBounds
internal/graphicscommand/image.go:234:16: Found IsInBounds
internal/graphicscommand/image.go:234:31: Found IsInBounds
internal/graphicscommand/commandqueue.go:139:23: Found IsInBounds
internal/graphicscommand/commandqueue.go:180:19: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:264:14: Found IsInBounds
internal/graphicscommand/commandqueue.go:275:17: Found IsInBounds
internal/graphicscommand/commandqueue.go:297:43: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:297:52: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:300:11: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:301:11: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:304:23: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:326:10: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:351:15: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:367:11: Found IsInBounds
internal/graphicscommand/commandqueue.go:368:11: Found IsInBounds
internal/graphicscommand/commandqueue.go:409:11: Found IsInBounds
internal/graphicscommand/commandqueue.go:410:11: Found IsInBounds
internal/graphicscommand/commandqueue.go:416:11: Found IsInBounds
internal/graphicscommand/commandqueue.go:417:11: Found IsInBounds
internal/graphicscommand/commandqueue.go:461:14: Found IsInBounds
internal/graphicscommand/commandqueue.go:463:19: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:536:10: Found IsSliceInBounds
internal/graphicscommand/image_notjs.go:100:14: Found IsSliceInBounds
internal/graphicscommand/command.go:247:53: Found IsInBounds
internal/graphicscommand/command.go:248:53: Found IsInBounds
internal/graphicscommand/commandqueue.go:138:36: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:152:37: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:155:29: Found IsSliceInBounds
internal/graphicscommand/commandqueue.go:350:34: Found IsSliceInBounds

hajimehoshi added a commit that referenced this issue Oct 26, 2024
…orms

```
% benchstat old.txt new.txt
goos: darwin
goarch: arm64
pkg: github.com/hajimehoshi/ebiten/v2/internal/graphicscommand
cpu: Apple M3 Pro
                            │   old.txt   │               new.txt               │
                            │   sec/op    │   sec/op     vs base                │
PrependPreservedUniforms-12   23.07n ± 2%   19.96n ± 0%  -13.48% (p=0.000 n=10)
```

Updates #3144
hajimehoshi added a commit that referenced this issue Oct 26, 2024
old.txt: 1fe988e
new.txt: this commit

```
benchstat old.txt new.txt
goos: darwin
goarch: arm64
pkg: github.com/hajimehoshi/ebiten/v2/internal/graphicscommand
cpu: Apple M3 Pro
                            │   old.txt   │              new.txt               │
                            │   sec/op    │   sec/op     vs base               │
PrependPreservedUniforms-12   19.79n ± 4%   18.84n ± 2%  -4.80% (p=0.001 n=10)
```

Updates #3144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@hajimehoshi and others