You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It takes a lot of time to instantiate a parsed struct with very large char arrays.
Minimal example
# example.jl
using CBinding;
c`
-Wall
-Werror
`
c"""
/* Default size on my system according to my <stdio.h>. */
# define BUFSIZ 8192
struct example_t {
char dummy[BUFSIZ];
};
"""
example = c"struct example_t"r(dummy = "example");
0; # supress large output in the REPL
It takes nearly 3 Minutes and a lots of RAM (it seems):
julia> @time include("example.jl") # first call
165.834280 seconds (39.78 M allocations: 8.739 GiB, 1.16% gc time, 99.91% compilation time)
julia> @time include("example.jl") # second call
127.044148 seconds (2.04 M allocations: 136.764 MiB, 0.46% gc time, 99.47% compilation time)
The text was updated successfully, but these errors were encountered:
This is probably a result of the code emitted by CBinding being rather redundant and relying on the Julia compiler optimizations to remove the redundancies. As the example below illustrates, the first time construction is 99.9% compilation time, but successive calls are much better.
julia>module LargeArray
using CBinding
c``c""" typedef char LA[1024];"""jend
Main.LargeArray
julia>@time LargeArray.LA("example"...);
3.977991 seconds (2.29 M allocations:211.621 MiB, 0.65% gc time, 99.92% compilation time)
julia>@time LargeArray.LA("example"...);
0.000050 seconds (109 allocations:20.781 KiB)
I will see about emitting more to-the-point code which doesn't use the compiler as a crutch. 😉
krrutkow
changed the title
Very long evaluation time for instantiating structs with large char arrays
Long compilation time for large Carrays
May 6, 2022
It takes a lot of time to instantiate a parsed struct with very large char arrays.
Minimal example
It takes nearly 3 Minutes and a lots of RAM (it seems):
The text was updated successfully, but these errors were encountered: