digitalmars.D.ldc - Object size?
- Andy Valencia (7/7) Mar 01 I'm early days on dlang, and found a small HTTP server
- Andy Valencia (12/15) Mar 13 I've played with this some more; this code:
- kinke (15/30) Mar 13 This isn't LDC-specific and regularly comes up as beginner's
- Andy Valencia (6/20) Mar 14 Thank you! A wealth of avenues. It's particularly encouraging
- Charlie Brekke (2/10) Nov 21 I really admire their creativity. Make sure there is a customer!
I'm early days on dlang, and found a small HTTP server "serverino". I have it built, linked with a test program, and running. But the executable size is enormous. For 405 statements, it has a text size of 712k bytes. Whoof. Is this normal? I'm using ldc2 version 1.30.0. Thanks! Andy Valencia
Mar 01
On Saturday, 2 March 2024 at 04:33:02 UTC, Andy Valencia wrote:...But the executable size is enormous. For 405 statements, it has a text size of 712k bytes. Whoof. Is this normal? I'm using ldc2 version 1.30.0.I've played with this some more; this code: import std.stdio : writefln; void main(in string[] argv) { writefln("%s: %d thingies\n", argv[0], 123); } results in 252k of text size in the executable. It seems like there's some sort of combinatoric explosion going on behind the scenes? Andy
Mar 13
On Wednesday, 13 March 2024 at 17:40:52 UTC, Andy Valencia wrote:On Saturday, 2 March 2024 at 04:33:02 UTC, Andy Valencia wrote:This isn't LDC-specific and regularly comes up as beginner's topic (in general forums, try a search). One thing is that druntime and Phobos are linked statically by default (with official LDC packages at least; distro versions might not); with LDC, use `-link-defaultlib-shared` to link the shared variants. That's a pretty constant offset though, so for tiny hello-world programs, it might seem huge, but rest assured, it doesn't go on like this when the program becomes fleshier. The 2nd thing is that templates can easily lead to an explosion of code. Phobos' std.format is a prime and well-known example of that, sadly. If you use `-vcg-ast` for compiling your little .d, the compiler will generate a `*.d.cg` file with the instantiated templates. You'll see that it's almost 20k lines (~430 KB of source code)....But the executable size is enormous. For 405 statements, it has a text size of 712k bytes. Whoof. Is this normal? I'm using ldc2 version 1.30.0.I've played with this some more; this code: import std.stdio : writefln; void main(in string[] argv) { writefln("%s: %d thingies\n", argv[0], 123); } results in 252k of text size in the executable. It seems like there's some sort of combinatoric explosion going on behind the scenes? Andy
Mar 13
On Wednesday, 13 March 2024 at 18:25:25 UTC, kinke wrote:This isn't LDC-specific and regularly comes up as beginner's topic (in general forums, try a search). One thing is that druntime and Phobos are linked statically by default (with official LDC packages at least; distro versions might not); with LDC, use `-link-defaultlib-shared` to link the shared variants. That's a pretty constant offset though, so for tiny hello-world programs, it might seem huge, but rest assured, it doesn't go on like this when the program becomes fleshier. The 2nd thing is that templates can easily lead to an explosion of code. Phobos' std.format is a prime and well-known example of that, sadly. If you use `-vcg-ast` for compiling your little .d, the compiler will generate a `*.d.cg` file with the instantiated templates. You'll see that it's almost 20k lines (~430 KB of source code).Thank you! A wealth of avenues. It's particularly encouraging that this executable growth doesn't scale with LOC--that would be a little intimidating. I will head off and research the areas you've listed. Andy
Mar 14
On Saturday, 2 March 2024 at 04:33:02 UTC, Andy Valencia wrote:I'm early days on dlang, and found a small HTTP server [Slice Master](https://slice-masters.io) "serverino". I have it built, linked with a test program, and running. But the executable size is enormous. For 405 statements, it has a text size of 712k bytes. Whoof. Is this normal? I'm using ldc2 version 1.30.0. Thanks! Andy ValenciaI really admire their creativity. Make sure there is a customer!
Nov 21