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

Optimize C ABI boundaries #9

Open
2 tasks
mappu opened this issue Aug 25, 2024 · 1 comment
Open
2 tasks

Optimize C ABI boundaries #9

mappu opened this issue Aug 25, 2024 · 1 comment
Labels

Comments

@mappu
Copy link
Owner

mappu commented Aug 25, 2024

The Go binding calls a C ABI binding, which calls the Qt C++ functions. Overall, it's somewhat efficient.

But to comply with the common C ABI, there are some places where data types must be converted, or moved onto the heap. This could be optimized in some cases.

Ideas:

  • Bypass malloc/free for zero-length strings and arrays
  • When returning a QString, have C++ fill in a Go-provided buffer, instead of copying the data twice
    • Current: C malloc - C strcpy - Cgo boundary - Go malloc - Go memcpy - Cgo boundary - C free - Cgo boundary - Go epilogue
    • Proposal: C calls go_malloc - Cgo boundary - Go malloc - Cgo boundary - C strcpy - Cgo boundary - Go epilogue
    • Same 3x boundaries
@mappu
Copy link
Owner Author

mappu commented Sep 19, 2024

  • Pass struct miqt_array by value instead of pointer (saves 1x malloc)
  • Pass struct miqt_string by value instead of pointer (still one malloc, but simpler)

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

No branches or pull requests

1 participant