Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookup tables and binary size difference #1

Closed
matu3ba opened this issue May 1, 2022 · 4 comments
Closed

lookup tables and binary size difference #1

matu3ba opened this issue May 1, 2022 · 4 comments

Comments

@matu3ba
Copy link

matu3ba commented May 1, 2022

  1. How big are the lookup tables for this? Is there a size difference to the other approaches? I see // Eisel-Lemire tables ~10Kb, so I am curious how much space float parsing for embedded would require in contrast to that.
  2. Related, how big is the binary size in comparison?
@tiehuis
Copy link
Owner

tiehuis commented May 1, 2022

  1. We cache 128 bits of precision for pre-computed powers of five from exponents -342 to 308 which is 650 * 16 = 10400 bytes required. You can reduce this if you only need f32 to ~2Kb worth of tables, but I'm not yet sold on this. See also optimized (smaller) lookup table for float (binary32 only) fastfloat/fast_float#99.

Note that the other fairly large user of memory here is the Decimal type. This uses 768 bytes for the digits storage. This space seems reasonable too me, but note that f128 parsing requires a lot more. Specifically the Decimal requires 11563 bytes for storage if parsing to an f128 with full precision. I have yet to fully explore actually using eisel-lemire for f128 parsing but my first revision will likely use the slow-path algorithm only initially.

  1. I haven't done any in-depth checks yet but running bloaty on this file with the different parseFloat implementations gives the following:
# build command
zig build-exe test_all_fxx_data.zig -O ReleaseFast && strip test_all_fxx_data
$ bloaty test_all_fxx_data.std
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  67.8%  15.6Ki  44.6%  15.5Ki    .text
   0.0%       0  35.4%  12.3Ki    .bss
  29.0%  6.67Ki  19.0%  6.61Ki    .rodata
   1.5%     344   1.0%     344    [LOAD #1 [R]]
   0.7%     163   0.0%       0    .comment
   0.5%     128   0.0%       0    [ELF Headers]
   0.4%     103   0.0%       0    .shstrtab
   0.1%      15   0.0%       0    [Unmapped]
 100.0%  23.0Ki 100.0%  34.8Ki    TOTAL
bloaty test_all_fxx_data.new
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  58.2%  26.9Ki  46.3%  26.8Ki    .text
  40.2%  18.6Ki  31.9%  18.5Ki    .rodata
   0.0%       0  21.3%  12.3Ki    .bss
   0.7%     352   0.6%     352    [LOAD #1 [R]]
   0.3%     163   0.0%       0    .comment
   0.3%     128   0.0%       0    [ELF Headers]
   0.2%     103   0.0%       0    .shstrtab
   0.0%       6   0.0%       0    [Unmapped]
 100.0%  46.2Ki 100.0%  58.0Ki    TOTAL

So, a bit larger.

@tiehuis
Copy link
Owner

tiehuis commented May 1, 2022

There is also this table I forgot about:

const table = [_]u16{

@andrewrk
Copy link

andrewrk commented May 1, 2022

btw we have the --strip flag fully working now:

zig build-exe test_all_fxx_data.zig -O ReleaseFast --strip

@tiehuis
Copy link
Owner

tiehuis commented May 2, 2022

@tiehuis tiehuis closed this as completed May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants