dart-lang / dart-lang/native

Switching from 1.2.1 to 2.x.x drastically slows my app

Open
#912 19 comments 1 reaction 0 assignees View on GitHub
package:ffi
Dominant language
Dart
Stars
275
Forks
144
Avg merge
2d 10h
Merged PRs (30d)
47

Description

In my app I allocate realtime video frames (24MB per frame * 60fps)

In my app I time the processing of a frame in milliseconds.

Using `ffi: ^1.2.1` I get 8-11ms per frame
Using `ffi: ^2.0.0` I get 70 to 200ms per frame in DEBUG mode and 20-30ms in RELEASE mode which makes my app unusable.

I suspect that it has something to do with the switch mentioned in the changelog of 2.0.0
> Switch Windows memory allocation to use CoTaskMemAlloc and CoTaskMemFree

I've also found an article that talks about a bug in windows 10 which supposedly makes this a lot slower:
https://randomascii.wordpress.com/2022/07/11/slower-memory-zeroing-through-parallelism/

For now I can't upgrade to ffi 2.x.x since I can't use my app with this version.

Is this a known thing?

EDIT: switching from ffi.calloc to ffi.malloc reduces the time immensly but of course is not always applicable

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.