I7 : Very long time to compile big complicated IF statements

So this is a sanitised section of my WIP :

"Oddthing" by Ade
	
The Garden is a room. It is north of house.
House is a room.	

Susan is a person in Garden.

Every turn:
	if Susan is in Garden:																
		if (the current action is NOT asking susan about something) AND (the current action is NOT telling susan about something) AND (the current action is NOT taking something) AND (the current action is NOT dropping something) AND (the current action is NOT eating something) AND  (the current action is NOT drinking something) AND (the current action is NOT opening something) AND (the current action is NOT listening) AND (the current action is NOT listening to something) AND (the current action is NOT kissing Susan) AND (the current action is not touching something) AND (the current action is NOT attacking Susan) AND (the current action is NOT pushing Susan) AND (the current action is NOT pulling Susan) AND (the current action is NOT examining something):
			say "We made it through the big IF!".

The Big IF statement there basically takes about 2/3 minutes to compile. If I add a couple more clauses, I left it trying to compile for about seven minutes and then gave up.

Transmuting the big IF into this :


		if (the current action is NOT asking susan about something):
			if (the current action is NOT telling susan about something):
				if (the current action is NOT taking something):
					if (the current action is NOT dropping something):
						if (the current action is NOT eating something):
							if (the current action is NOT drinking something):
								if (the current action is NOT opening something):
									if (the current action is NOT listening):
										if (the current action is NOT listening to something):
											if (the current action is NOT kissing Susan):
												if (the current action is not touching something):
													if (the current action is NOT attacking Susan):
														if (the current action is NOT pushing Susan):
															if (the current action is NOT pulling Susan):
																if (the current action is NOT examining something):
																	say "We made it through the ifs!".

Compiles in 2 seconds flat.

Removing the brackets from the original big IF also compiles in about 2 seconds flat.


if the current action is NOT asking susan about something AND the current action is NOT telling susan about something AND the current action is NOT taking something AND the current action is NOT dropping something AND the current action is NOT eating something AND the current action is NOT drinking something AND the current action is NOT opening something AND the current action is NOT listening AND the current action is NOT listening to something AND the current action is NOT kissing Susan AND the current action is not touching something AND the current action is NOT attacking Susan AND the current action is NOT pushing Susan AND the current action is NOT pulling Susan AND the current action is NOT examining something:

(which is ok for this simple example but not necessarily a ‘fix’ as such if I needed to ensure operator precedence. )

So it’s not an insurmountable issue by any means - but I am curious as to whether firstly there’s a reason for this, and secondly whether this is a bug/improvement I should report.

Ade

n.b. i7 version is 6M62 (I6/v6.33 lib 6/12N) SD So it may not be case in latest version…

2 Likes

It’s just as slow in 10.1.0 so I think it’s worth reporting.

This may or may not apply to the actual situation, but just as a data point grouping the actions to a kind of action compiles fast:

Asking Susan about something is acting conspicuously.
Telling Susan about something is acting conspicuously.
Taking something is acting conspicuously.
[..]

if the current action is not acting conspicuously: [..]
4 Likes

I found I had to increase MAX_EXPRESSION_NODES to compile it at all.

1 Like

Agree @Juhana However, was really just abstracting into a probably bad example!! :slight_smile:

Also, completely forgot to mention the MAX_EXPRESION_NODES change. Yeah - I had to, also.

Just for giggles, I tried to abstract it out a bit. This is still compiling as I type this message :


		if (R is TRUE) OR (B is TRUE ) OR (C is TRUE) OR (D is TRUE ) OR (X is TRUE) or (F is TRUE) OR (R is TRUE AND B is TRUE) OR (R is TRUE AND D is TRUE) OR (R is TRUE OR X is TRUE) OR (R is TRUE AND (D is TRUE OR C is TRUE)) OR (R is TRUE AND F is FALSE) OR (F is TRUE AND C is FALSE):

It’s probably worth at least reporting as a ‘thing to look at’.

…still compiling.

:slight_smile:
ade

1 Like

The slowdown is in the frontend (i7 to I6) or in the backend (I6 to glulx/Zcode) ?

Best regards from Italy,
dott. Piergiorgio.

The front end, the I7 compiler.

I can confirm it happens in v10, too. Timing diagnostics less than enlighteningly tell one:

100.0% in inform7 run
     98.5% in compilation to Inter
         97.8% in //Sequence::undertake_queued_tasks//