register class/function and code-bloat

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

register class/function and code-bloat

yang solid
I register a class like this:
module(L)[
class_<Vector3i>("Vector3i")
.def(constructor<>())
.def(constructor<int,int,int>())
.def(constructor<const Vector3i&>())
.def("get", &Vector3i::get)
.def("set", &Vector3i::set)
.def("Set", &Vector3i::Set)
.def("Zero", &zero<Vector3i>)
.def("Assign", &copy<Vector3i>)
.property("x", &Vector3i::getX, &Vector3i::setX)
.property("y", &Vector3i::getY, &Vector3i::setY)
.property("z", &Vector3i::getZ, &Vector3i::setZ)
];
The app's size compiled by Xcode, increased nearly 160k (release version). 
But registered with tolua++, the size increased nearly 10k only. Code bloat 16 times! (code bloat nearly 4 times by MSVC).

Any idea to reduce code bloat?

Thanks!



------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: register class/function and code-bloat

Ryan Pavlik-4
Is this all that you've registered?  I know at least Luabind has some one-time overhead to provide capabilities you're not using in that post (inheritance, lua derived classes, etc), and I'm sure tolua++ does to.

I'd probably model the code size roughly as
s = kx + c

where c is some constant overhead size required by the binding system, x is the "amount of usage" (how many functions, etc that you register), and k is how much code size increases when usage increases.  It would be interesting to get some data points for different amounts of registered code and compare the slope with tolua++.

Also, are you compiling with debug symbols? what about optimization - what level? There's a chunk of luabind that should "disappear" with an optimizer (template metaprogramming), so if these are unoptimized debug builds that could also explain the size you're seeing.

My hunch, that has no basis in data, is that probably much of what you're seeing is either from a disabled optimizer or from "c", which I would expect to dwarf the actual registration code for an example as small as you have there.

Which branch are you using? My github master has some changes and improvements to streamline it a bit and minimize includes, which might help. Without the output of a tool like "nm" to show compiled size of each symbol, it's hard to guess - it's like optimizing without profiler data. That would be one idea - use nm to look at some compiled code and see what actually is using up the code space to target optimization.

(and I know this isn't really pertinent, since where the code size is coming from is a good question, but particularly if this size difference turns out to be "c" - constant not proportional to amount of code registered - are you on a platform where the sub-1MB difference would matter? Some might be, though, and if overhead can be reduced without impacting usability or maintainability, it sounds good to me)

Ryan


On Wed, Jan 23, 2013 at 9:48 PM, yang solid <[hidden email]> wrote:
I register a class like this:
module(L)[
class_<Vector3i>("Vector3i")
.def(constructor<>())
.def(constructor<int,int,int>())
.def(constructor<const Vector3i&>())
.def("get", &Vector3i::get)
.def("set", &Vector3i::set)
.def("Set", &Vector3i::Set)
.def("Zero", &zero<Vector3i>)
.def("Assign", &copy<Vector3i>)
.property("x", &Vector3i::getX, &Vector3i::setX)
.property("y", &Vector3i::getY, &Vector3i::setY)
.property("z", &Vector3i::getZ, &Vector3i::setZ)
];
The app's size compiled by Xcode, increased nearly 160k (release version). 
But registered with tolua++, the size increased nearly 10k only. Code bloat 16 times! (code bloat nearly 4 times by MSVC).

Any idea to reduce code bloat?

Thanks!



------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user




--
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

[hidden email]
http://academic.cleardefinition.com

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user