kekyo / IL2C

IL2C - A translator for ECMA-335 CIL/MSIL to C language.
Apache License 2.0
401 stars 36 forks source link

Improvement for building library on parallelism #122

Open kekyo opened 2 years ago

kekyo commented 2 years ago

The current runtime library build method (#79) follows a simple conflict avoidance method similar to the ConcurrentDictionary<K,V>.GetOrAdd(key, func) we are all familiar with, where the generator (in this case the runtime library compilation) is run and finally It follows a simple conflict avoidance method, leaving only one task to save the result and discarding all the rest.

The disadvantage of this approach is that it incurs a very large computational cost the first time you do a build from git clean -xfd. We believe that for the majority of users, this has almost no impact, except that it takes longer the first time, but the CI process pays this cost every time.

I have adopted a series of conflict avoidance techniques because of the simplicity of this method (another thing is that MSBuild does not have such flexible control over parallel execution), but we may be able to tighten it up a bit more:

A series of methods may require writing a few C# inline custom tasks.

We don't see much need to make this improvement just for runtime libraries, but as we showed in #121, it is likely to have an impact on build time if libcache is made available for any nuget library or reference assembly.