digitalmars.D.bugs - [Issue 10779] New: cartesianProduct leads to heavy code bloat
- d-bugmail puremagic.com (19/19) Aug 08 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10779
- d-bugmail puremagic.com (54/58) Aug 08 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10779
- d-bugmail puremagic.com (9/9) Aug 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10779
- d-bugmail puremagic.com (6/6) Aug 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10779
- d-bugmail puremagic.com (6/6) Aug 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10779
http://d.puremagic.com/issues/show_bug.cgi?id=10779 Summary: cartesianProduct leads to heavy code bloat Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: tobias pankrath.net PDT --- http://dpaste.dzfl.pl/45240ef6 The program compiled with DMD64 D Compiler v2.063.2 has a size of 37MiB. It drops to 1,5MiB if you delete the usage of cartesianProduct. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 08 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10779 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cchttp://dpaste.dzfl.pl/45240ef6 The program compiled with DMD64 D Compiler v2.063.2 has a size of 37MiB. It drops to 1,5MiB if you delete the usage of cartesianProduct.The code on dpaste: import std.conv, std.algorithm, std.range, std.stdio, std.string, std.file, std.csv; import std.getopt, std.path, std.bitmanip, std.exception; Parameter[] macParameter; Parameter[] registerParameter; Parameter[] immediateParameter; struct AsmTemplate { string template_; string result; string arguments; } struct Parameter { enum Type { Register, Immediate, Mac, None}; Type type; uint val; } struct Test { string template_; Parameter[] params; } void generateTests(OR)(AsmTemplate ins, ref OR sink) { // params is a list of argument ranges with varying length, originally // optained through a functioncall. We pad it, // with some empty elements so we can use it in cartProd auto params = [immediateParameter, registerParameter, macParameter, [], []]; foreach(tup; cartesianProduct(params[0], params[1], params[2], params[3], params[4])) { auto t = Test(ins.template_, [tup[0], tup[1], tup[2], tup[3], tup[4]]); } } void main() { auto app = appender!(Test[]); AsmTemplate asm_; asm_.generateTests(app); } Probably cartesianProduct should be rewritten from scratch, in a lower level way. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 08 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10779 You are right, cartesianProduct uses a lot of templates internally. It's worse with cartesianProduct of >2 arguments, it uses an exponential number of templates. I'll have to rewrite it from scratch to not use existing range templates. :-( So much for dogfooding... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10779 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10779 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 10 2013