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

Take a look to see if we should use Syscalls instead of CGO for Windows #271

Open
BrentFarris opened this issue Mar 19, 2024 · 5 comments
Open
Assignees
Labels
task New feature or request

Comments

@BrentFarris
Copy link
Contributor

Currently CGO is nice because it can have some consistency between platforms. Otherwise, syscall can be used to construct and interact with windows.

@BrentFarris BrentFarris added the task New feature or request label Mar 19, 2024
@BrentFarris BrentFarris self-assigned this Mar 19, 2024
@MatejMagat305
Copy link

If I can, I would like to notice, there is purego from ebiten, which call dlopen, pass cgo funcs without compile cgo...

@BrentFarris
Copy link
Contributor Author

If I can, I would like to notice, there is purego from ebiten, which call dlopen, pass cgo funcs without compile cgo...

Thanks! I'll have to take a look at how they've got it setup.

BrentFarris added a commit that referenced this issue Jun 10, 2024
@BrentFarris
Copy link
Contributor Author

BrentFarris commented Jun 10, 2024

In relation to syscall.SyscallN, I found it to be roughly 10% slower than CGO on small functions.

@MatejMagat305
Copy link

MatejMagat305 commented Jun 11, 2024

In relation to syscall.SyscallN, I found it to be roughly 10% slower than CGO on small functions.

it is true, however golang is loved for simply compilation, cgo is therefore problem that it need gcc and C dependency and hard cross-platform ..., beginer have problem on windows, so yes it is slow, but for beginer and easy cross is more suitable syscall ...., even purego is 5-10x slower than cgo, but it is able achieve 1396 fps (at basic example: gen2brain/raylib-go#361), so at this case I as programer prefer easy cross, because usualy we need 60,120 fps

@BrentFarris
Copy link
Contributor Author

Yeah, I'm leaving the branch with the changes up for further investigation; specifically for the initial compile time and the cross-compile benefits. I've not abandoned the idea, but do want to make sure I get all the measurements.

Something that would be pretty nice would be to have a compile tag to select which option you'd prefer, cgo for speed, or purego for ease of use.

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

No branches or pull requests

2 participants