-
Notifications
You must be signed in to change notification settings - Fork 4
Large binary data generates a file that takes too long to compile. #8
Comments
Do not generate data with a new string every 24 bytes, but with strings of up to 1,000,000 bytes. This is a horrible hack; a better approach needs to be found. The reason behind this change is that compiling a concatenation of many thousands of string literals is extremely slow. see also tmthrgd#8
I likely won't have a chance to look at this for the next few days. I'm almost certain this is related to golang/go#16394 which is about build failures caused by a large number of string concatenations. While that remains open, I'll try the workaround applied to x/text. Iff that doesn't work, I'll add a configuration option that will allow the disabling of string wrapping. I'd rather not add a configuration option if I can help it and it would later be removed if the compiler bug is fixed. |
I agree, golang/go#16394 does indeed look like it describes the problem. The parenthesis workaround sounds good if it works.
Yes, on reflection that would result in a backwards incompatible API change. Never a good idea if it can be avoided. |
Yes, it works a treat. Thank you. |
I have a number of truetype files that result in a generated go src file of about 150,000 lines.
Each input file generates something like this.
The large number of lines of concatenated strings results in crazy compile times. In fact I've not been able to successfully build; I end up giving up and interrupting the build.
If I change
wrapAt
to a very large number (such as 1000000) then the data is generated as a single string for each asset, and the build time is perfectly reasonable.I can't find a nice way to change, or better still disable, the wrapAt value. For now I've locally changed
{{flate . "\t\t\t" 24}}
to
{{flate . "\t\t\t" 1000000}}
at release.go#L213
to prove the problem and a solution.
(And the same for
{{read . "\t\t\t" 24 -}}
.)It would be good if this could configured in https://godoc.org/github.com/tmthrgd/go-bindata#GenerateOptions . However I've not yet been able to get my head around the code enough to work out how to approach this, and make a merge request.
Perhaps the concatenation of multiple strings should be removed completely? I'm sure that others may hit the same issue at some point. Interestingly the original jteeuwen/go-bindata does not do this, it generates a single string for an asset's data.
The text was updated successfully, but these errors were encountered: