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

slim down glow #23

Open
bryanturley opened this issue Aug 3, 2014 · 1 comment
Open

slim down glow #23

bryanturley opened this issue Aug 3, 2014 · 1 comment

Comments

@bryanturley
Copy link

My original cgo bindings took 4 minutes to compile with go (WITH GO).
That was on tip between 1.1 and 1.2.
4 minutes! go compile times really spoiled me so I had to fix this ;)
I did a bunch of things to make the source smaller that should also help glow.
Especially since the core 4.4 package compiles into a 13MB .a file.

https://github.com/bryanturley/old_gl/blob/master/core/funcs.go#L1178
Scroll to the very end of that line. You will see // 14
That means those 14 opengl functions share that function signature.
Which in turn means you can turn 14 bridges into 1.
The only downside to that is you get semi-ugly looking unnamed bridge functions.
In this example the type bgl003_t is only used with the function bgl003 (3 hex digits)
https://github.com/bryanturley/old_gl/blob/master/core/funcs.go#L326
The go side of those 14 functions all call bgl003 with their own function pointer (of type bgl003_t), since they all share the same function signature.
https://github.com/bryanturley/old_gl/blob/master/core/funcs.go#L4860 <-- one of the bgl003

I think this shrunk my source files 40-60% and should make a significant impact on your library size.

@bryanturley
Copy link
Author

Beyond that in my newest binding generator I dropped the entire idea of having individual pointers.
Going from individually named function pointers to a sized array (not slice) of functions pointers shaved 2MB off my library.

https://github.com/bryanturley/gl/blob/master/gl_linux_amd64.go#L32
https://github.com/bryanturley/gl/blob/master/gl_linux_amd64.go#L180

You have way more (non-core) functions in your "core" package than I do so this will probably have a bigger impact on library size for you.

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