-
Notifications
You must be signed in to change notification settings - Fork 59
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
use CTFE functions in mixin(), and not templates #406
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #406 +/- ##
==========================================
- Coverage 78.58% 78.52% -0.06%
==========================================
Files 9 9
Lines 7382 7387 +5
==========================================
Hits 5801 5801
- Misses 1581 1586 +5
Continue to review full report at Codecov.
|
If you want more conceptual explanations. let's say you have a template The problem we are faced to here is that the cost of creating instances and making lookups in the template each time it's used again is not worth. It saves a very little, to the point that generating the code again does not make compiling slower. So instead, only CTFE is used which has the side effect to polute less the symbol tables and reduce the memory used. |
ok I did some small benchmarks how this affects compile time and memory usage with a simple Before: dub build time = 7.36s, peak memory = 831 MB I don't know if that tiny improvement is really worth this change. Time in both cases was fairly stable with worst time just being exactly +0.05s in both cases (excluding first warmup run), memory was very stable in the MB range |
Yes, i also see those 6 Megs in less using for i in $(seq 1 5); do
git checkout mixin-using-ctfe
echo "LDC2 PR pass $i"
/usr/bin/time -v dub build --build=release --compiler=ldc2 --force
git checkout master
echo "LDC2 MASTER pass $i"
/usr/bin/time -v dub build --build=release --compiler=ldc2 --force
done
for i in $(seq 1 5); do
git checkout mixin-using-ctfe
echo "DMD PR pass $i"
/usr/bin/time -v dub build --build=release --compiler=dmd --force
git checkout master
echo "DMD MASTER pass $i"
/usr/bin/time -v dub build --build=release --compiler=dmd --force
done As explained this is due to the fact that templates were not useful. They are used as a kind of cache, with the hope to reduce the cat ( |
The duration spent to compile dparse as a static library is the same but this reduces memory usage when compiling. This change will also begin being interesting when the new CTFE implementation will come.
The duration spent to compile dparse as a static library is the same but this reduces memory usage.
This change will also begin being interesting when the new CTFE implementation will come.