Project too complex ? lazarus / 62-General ---------------------------------------------------------------------- jack616 · 2016-06-14 23:34 I've just had an issue that generated an error message that I'd like more info on if possible. I'm using standard Laz V1.6 on win7-64 The error message was: files.pas(226,2) Fatal: Project Too Complex, it Requires Too Many Registers I caused the issue by using a very large string list. I can get around that (I was just curious about the speed and was trying it out) but I'm curious to know why that causes a register issue and "too complex?" I could make a stab at working it out but it would be nice to know for sure. cheers. ---------------------------------------------------------------------- marcov · 2016-06-15 07:42 9 times out of ten this happens with machine generated code where you duplicate a long list of statements. IOW you have procedures or main program that is simply too long, split it up in multiple procedures. It is strange though that it says "project" is too complex, I would expect "procedure". ---------------------------------------------------------------------- Thaddy · 2016-06-15 08:57 @Marco: You are right: it is (also case corrected to what is in msgtxt.inc) :""Procedure too complex, it requires too many registers". As a 'grep -r -i "Too Complex, it Requires Too Many Registers" *' over the whole trunk says, that is. @Jack616: You should indeed break up the procedure or method into more reasonably sized portions. A human will also choke on a whole steak at once. ---------------------------------------------------------------------- jack616 · 2016-06-15 11:48 Thanks for the replies. Yes I typed project instead of procedure for some reason - sorry. I realise it makes it too long - I was running some speed tests and don't intend to try to use it like that. I was hoping someone could explain what it was exactly that choked the compiler and why it was reporting "registers" as part of that. I was looking for insight into the compilers function in this respect rather than attempting to do anything. (academic interest) ---------------------------------------------------------------------- marcov · 2016-06-15 12:07 It is very simple, register colouring algorithm works per procedure and is faster if you set a limit to the maximum number of virtual registers (Delphi does it too). Maybe it also allows preallocation. And whatever limit you set, sooner or later sb will let his for loop generate that many iterations, and wil hit that limit.  There is simply no mechanism correcting them. So increasing the limit doesn't really solve anything, because when autogenerating it is easy to make a mistake and hit the new limit, while the normal operation is slowed by it. typically it is set to a midhigh power of two (16k-32k-64k) ---------------------------------------------------------------------- jack616 · 2016-06-16 10:50 Hi marcov - thanks So this is an issue with register graphing. I'm not quite sure how that affects the quantity of data. The issue occured when I added a single very long string list. Does this mean that a string list is using quantities of processor registers based on it's length and these registers are not "spilled"? ---------------------------------------------------------------------- marcov · 2016-06-16 11:06 Quote from: jack616 on June 16, 2016, 12:50:40 pmThe issue occured when I added a single very long string list. Does this mean that a string list is using quantities of processor registers based on it's length and these registers are not "spilled"? /virtual/ registers. Any (registerable) intermediate result in a subroutine occupies a virtual register. Register allocation condenses it to real registers by narrowing their ranges of liveliness and spilling, if needed. ---------------------------------------------------------------------- jack616 · 2016-06-17 11:19 Interesting... If I understand correctly would I be right in thinking that the issue really arises out of the days of limited memory models (virtual registering limits) ? ---------------------------------------------------------------------- marcov · 2016-06-20 19:45 Quote from: jack616 on June 17, 2016, 01:19:43 pmInteresting... If I understand correctly would I be right in thinking that the issue really arises out of the days of limited memory models (virtual registering limits) ? No. Simply that you can optimize the algorithm by setting a fixed limit and preallocating. The information density is higher, and cache functions better then. The current register allocator is 2.0+, and by then 256 or 512MB+ was already standard.