Reducing parsing time by introducing hash signature mechanism #72
Replies: 2 comments 2 replies
-
This is not simple doable and there are many drawbacks in doing that:
The only possible way to do that without much changes would be doing a hash of all files, that is, the system would not be per file as you suggested, but for a hash of all files. But I don't see much benefit in that, moreover you can achieve the same result using a plain Makefile to check file modification time and skip re-building.
C design allows that, Nelua design is different, the processing step is way different. Plus in C you can split source code into multiple source files, and compile multiple source files independently, and ccache makes more sense when doing that. This is not doable with Nelua, because the language design requires all files to be preprocessed and analyzed together. And changing these design choices would change the language itself a lot, we would have to kill the powerful preprocessor and compiler hack-ability, and the language would become something else. Forkmon solutionI've put thoughts into this problem a few times before, and ways I could speed up the compilation to not do redundant parsing and analysis of files while doing live development, because I'm addicted to live development and I don't like slow build times. I've come up with a generic solution that I made as a side project called forkmon. Check the project lading page, I explain with more details there how this works, I do mention how it works with Nelua in the motivation section. This system could speedup compilation of a large Nelua project by 3x factor in usual live development usage on my tests. Quick tutorial using Forkmon with NeluaQuick setup of Forkmon for quick live development in Nelua (Linux users only): wget -q https://raw.githubusercontent.com/edubart/forkmon/main/bin/linux64/forkmon.so
alias forkmon-nelua='LD_PRELOAD=`pwd`/forkmon.so FORKMON_FILTER=".nelua$" nelua'
echo "print 'hello world'" > hello.nelua
forkmon-nelua hello.nelua Now split the screen with the terminal and |
Beta Was this translation helpful? Give feedback.
-
This is an interesting output, at least to me: Do you think if all preprocessing was taking place as one step and then all parsing as one step as well, could benefit Nelua? It reminded me how C2 language is doing its code analysis in contrast to C: |
Beta Was this translation helpful? Give feedback.
-
When we execute a Nelua program for the first time, it goes through parsing, preprocessing, analyzing code, generating native code and building it, and executing it.
If we re-execute the same command, it goes through the same steps, but uses the cached result(s):
Ignore the fact that the tested code is just
print 'Hello world!'
and assume it's a massive project.Would not it make sense to have a hash signature introduced for each file compilation to compare each build with the previous one, so we could skip unnecessary recompilation cycles?
I already do that for C code with the help of
ccache
, but imagine doing that for Nelua's actual parsing and preprocessing procedure, how much time it could reduced from going over the same cycle every time you have modified a file, let alone a number of files at once.Beta Was this translation helpful? Give feedback.
All reactions