Forums

speeding up compilation

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

speeding up compilation

Postby RIGHT_THEN » Sat Apr 23, 2011 10:02 am

Hey Charles

i was wondering if compiling in cobra could be
speeded.

here is the senario
===================
one has to compile the code upto
BindImplementationPhase at least to have comprehensive
info but as the code grows time taken to compile grows too

for instance

file one.cobra
--------------

1)def doCertainThings( num1 as int, num2 as int)
2) print 'in doCertainThings'
3) if ( num1 > 10 )
4) num1 = 10
5) if ( num2 > 20 )
6) num2 = 20
7)
8) num3 as int = num1 + num2
9)
10) return num3

----------------------------------

1)def doCertainThings( num1 as int, num2 as int)
2) print 'in doCertainThings'
3) if ( num1 > 10 )
4) num1 = 10
5) if ( num2 > 20 )
6) num2 = 20
7)
8) return num1 + num2


now in above case user has merely changed the last line
removed num3 and returned the plus result without storing
in any temp variable

but the compiler has allready produced all the info
upto line 6) why should it waste time recalculating all the stuff
if atall i could specify/supply compiler with previously created nodes
and tell it to compile or create info from line number 7) and onwards using
the previously created info just like we do Node.SetCompiler(CobraMain.Compiler/or our compiler variable) etc..;
i should have a way to supply it with previoulsy created info that i stored for future use.

now imagine this programm had 10 files and naturally even for these two line change every file
needs to be recompiled because compiler has no way of knowing what has been typed new and how is it effecting
other files what if few new lines were actually extending a class which was declared partial somewhere else
compiler has to do everything again. and that takes time. so i request something about it should be done
i think it would be great feature for cobra atleast for tooling. or is it there allready??
in nutshell i should have power over compiling howmuch and what and get that added to allready produced info.

if you think it in terms of nodes it might be more clear that if only few nodes get bad/changed than only those
need to be changed and not the whole nodes from begining unless ofcourse the new change warranted everything to
be recalculated


Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: speeding up compilation

Postby Charles » Sun Apr 24, 2011 10:11 am

Can you provide more context about the performance issues you are having? Is this interest because you have a project that is slow to build, or because of GUI work, like a syntax highlighting editor, or something else?

From a command line perspective, it would probably be easiest to implement this per file. Larger projects would benefit the most. Smaller project don't need as much benefit.

However, if the problem revolves around a text editor then a line-oriented approach is certainly required.

Let me know more.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: speeding up compilation

Postby RIGHT_THEN » Mon Apr 25, 2011 10:28 am

hey Charles

context is for the purpose of providing intellisense
in the editor. and everything else relating to editor.
the senario i have told allready. compiler will save few breaths for itself
if it need not produce the info which it produced earlier.

long back i saw a video on Go Language one thing that they Pitch about is
very small compile time. i went thinking how are they doing it. now i dont know
what they are doing but what i am proposing would certainly take us near fast compilation
times when done from within Editors. because that is what i am thinking that in the Editor
since one is gathering info for intellisense all the time also which is almost to the end of
compilation Phases then that same info can be passed on to the C# compiler.
reducing the the whole compilation time for the resultant assembly.
Only hitch is C# compiler no matter what we do
for cobra part C# will again take the full round. but atleast Cobra part is speeded.

unless you can suggest something to do with c# compiler too. any way by the time c#5 is out
with its Repl and CAS system we might be able to forward our approach to it too.

i think mono c# compiler can still be tweaked. anyway you get the point

but for the tools to work efficiently and speedily such attribute is required of a language.
otherwise everytime a user presses a dot or makes minor adjustments to the code by the
time intellisense engine provides some info user would have proceded to many further steps
leaving all the intellisense actions pending. now i understand in certain editors why sometimes
they would show info and other times not.


if you are feeling benovelent here is one more request
1) the messages which cobra compiler wants to print to the screen
should all be captured in a list so that the editor tool or other tools
dont have hard time parsing them because otherwise it is a console output
which at best can be redirected.that only increase redundancy.if it is also
stored in the list tools can decide and work on that list to see where
which message should be shown. currently i am doing this by hacking into
PrintConsoleMessages() by capturing whatever comes there in a list

i have many more but they can wait




Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: speeding up compilation

Postby Charles » Wed Apr 27, 2011 11:48 pm

Regarding the C# compiler, I did hack on the Mono C# compiler's code and turned it into a DLL which the Cobra compiler links against so it can pass C# source code through memory, rather than disk. It might also be interesting to have Cobra create the C# AST nodes so that the C# lexer and parser can be bypassed. And to pre-bind some or even all the symbols so that the C# compiler need not look them up.

But that is a big project and I don't know when I'll get around to it. Other things typically take precedence. I'm always open to $funding though. :-)


Regarding your request, the compiler already keeps the messages in a list which you can loop through:
for msg in compiler.messages
trace msg

Let me know if you have any problems or questions with that.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: speeding up compilation

Postby RIGHT_THEN » Fri Apr 29, 2011 8:44 am

Charles wrote:But that is a big project and I don't know when I'll get around to it. Other things typically take precedence. I'm always open to $funding though.


does that mean that we have to wait for line oriented compilation until funding arrives or that is just for c# part ;)

i will check on the messages part.

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: speeding up compilation

Postby Charles » Sat Apr 30, 2011 8:42 pm

Heh, the line oriented compilation is not trivial at all. I don't even have a strategy to implement it off the top of my head.

I may do another round of optimizing the compiler which would help in all situations. It's been awhile.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 51 guests