glow icon indicating copy to clipboard operation
glow copied to clipboard

slim down glow

Open bryanturley opened this issue 10 years ago • 1 comments

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 avatar Aug 03 '14 16:08 bryanturley

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.

bryanturley avatar Aug 03 '14 16:08 bryanturley