October 12, 2021
On Tuesday, 12 October 2021 at 19:50:51 UTC, H. S. Teoh wrote:
> On Tue, Oct 12, 2021 at 07:08:44PM +0000, IGotD- via Digitalmars-d wrote:
>> On Tuesday, 12 October 2021 at 18:06:53 UTC, Hipreme wrote:
>> > 
>> > Lot of people has implemented float to string conversion without requiring 500KB.
>> 
>> Floats to string is of course more complicated that integers but 500KB is ridiculous. It should rather be something like 10-20 KB.
>> 
>> It's likely it is a combination of that the optimizer/linker is unable to remove unused functions. Also that imports usually imports more stuff, even if it is just a tiny function from another import.
>> 
>> It's like a box of cables, you just want one cable but when you pull out one cable you get the entire ball of cables.
>
> It'd be nice to untangle that ball of cables so that less cables get pulled out when you tug at one (so to speak). :-D  We talked about pay-as-you-go modularization of Phobos at least a few times, but so far, that ball of cables persist.
>
>
> T

I do hope that this gets noted by the decision people, having to reimplement stdlib is the last thing I wanted right now, but 500KB for string to float conversion per module, (without debug symbols ) is pretty unacceptable.


October 12, 2021
On Tue, Oct 12, 2021 at 10:15:10PM +0000, Hipreme via Digitalmars-d wrote:
[...]
[...]
> I do hope that this gets noted by the decision people, having to reimplement stdlib is the last thing I wanted right now, but 500KB for string to float conversion per module, (without debug symbols ) is pretty unacceptable.
[...]

*Per module*?? That shouldn't be the case.  You must be doing something wrong...  Are you using dmd or ldc?  You might want to look into various options for eliminating duplicate template instantiations, like -linkonce-templates, or LTO, or some such.  No matter how bad the string-to-float bloat is (and I agree it's bad), it should not be adding bloat *per module*.

Possibly one thing to watch out for is using compile-time format strings, i.e., `writeln!"abc %s def"(...)` instead of runtime format strings `writeln("abc %s def", ...)`.  The former has its uses, such as catching bad format strings at compile-time; but it may potentially be the cause of a lot of template bloat if you have a lot of different format strings.


T

-- 
Being able to learn is a great learning; being able to unlearn is a greater learning.
October 14, 2021
On Tuesday, 12 October 2021 at 22:58:51 UTC, H. S. Teoh wrote:
> On Tue, Oct 12, 2021 at 10:15:10PM +0000, Hipreme via Digitalmars-d wrote:
> [...]
> [...]
>> I do hope that this gets noted by the decision people, having to reimplement stdlib is the last thing I wanted right now, but 500KB for string to float conversion per module, (without debug symbols ) is pretty unacceptable.
> [...]
>
> *Per module*?? That shouldn't be the case.  You must be doing something wrong...  Are you using dmd or ldc?  You might want to look into various options for eliminating duplicate template instantiations, like -linkonce-templates, or LTO, or some such.  No matter how bad the string-to-float bloat is (and I agree it's bad), it should not be adding bloat *per module*.
>
> Possibly one thing to watch out for is using compile-time format strings, i.e., `writeln!"abc %s def"(...)` instead of runtime format strings `writeln("abc %s def", ...)`.  The former has its uses, such as catching bad format strings at compile-time; but it may potentially be the cause of a lot of template bloat if you have a lot of different format strings.
>
>
> T


Humm I say module for representing libs, I have splitted my project in various libs, whose I call modules, so, it needs to link to each lib I'm using. Although I have implemented most I need right now, the current problem is std.array.

std.array increases 500Kb by only including it, so, for keeping my build times okay I have been basically ditching phobos...


October 13, 2021
On Thu, Oct 14, 2021 at 12:04:52AM +0000, Hipreme via Digitalmars-d wrote: [...]
> Humm I say module for representing libs, I have splitted my project in various libs, whose I call modules, so, it needs to link to each lib I'm using.

Hmm, I'd have thought LTO or -linkonce-templates ought to drop the redundant templates once you link the libs.  Is there any reason why it isn't?


> Although I have implemented most I need right now, the current problem is std.array.
> 
> std.array increases 500Kb by only including it, so, for keeping my build times okay I have been basically ditching phobos...

If I were you I'd report a bug.  The mere act of importing std.array shouldn't pull in a whole bunch of dead weight if you don't even use anything.  There used to be more Phobos modules with this problem, but a while back there was some effort to fix this.  If std.array still has this problem it should get looked into.


T

-- 
Once the bikeshed is up for painting, the rainbow won't suffice. -- Andrei Alexandrescu
October 14, 2021

On Tuesday, 12 October 2021 at 17:35:31 UTC, russhy wrote:

>

i'd personally suggest using snprintf, but depending on your usecase that might not be perfect

char[32] tmp = 0;
snprintf(tmp.ptr, tmp.length, "Hello World %f", value);

Be aware of the bug with snprintf when compiling for Windows.

1 2
Next ›   Last »