Code check for large model much slower with NL 6.1.1. than with NL 5.3.1

141 views
Skip to first unread message

Volker Grimm

unread,
Nov 12, 2020, 7:10:45 AM11/12/20
to netlogo-users
Dear NetLogo users and developers,

The honeybee model BEEHAVE, developed by Matthias Becher in 2014/2016, includes about 6500 lines of code plus a complex interface including additional code in its elements (www.beehave-model.net).

With NL 5.3.1, a code check takes about 2-3 seconds (for testing, I just outcommented the first line of the code).

With NL 6.1.1, the same code check takes 15-20 seconds (the same test).

Runtime is. according to the profiler, about 50% faster with 5.3.1.

I would be keen to know
- if others using large models have observed similar long code check times
- if there would be a way that the code check(or code) is re-optimized?

My laptop: Toshiba, Tecra Z50-C, Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz, 2601 MHz, 2 Kern(e), 4 logische(r) Prozessor(en), BIOS-Version/-Datum    TOSHIBA Version 7.60, 02.11.2016, 16 GByte RAM

Attached the two program versions compared and one input file. For testing, just run "setup" and then "go" from the Command Center. The 2016 version requires using NL 5.3.x

Volker
Beehave_BeeMapp2016updateversion61.nlogo
Beehave_BeeMapp2016.nlogo
Input_2-1_FoodFlowJF_MP.txt

Miguel Pais

unread,
Nov 12, 2020, 8:31:32 AM11/12/20
to netlogo-users
Hi Volker!

I tried both models. Old version in 5.3.1 and new version on 6.1.1.
First run with the profiler on I noticed procedures were being called a different number of times, so I went and checked the settings for both versions:
Old version: ReadInFile FALSE, Weather Rothamsted 2009, FeedBees FALSE, AddPolen FALSE
New version: ReadInFile TRUE, Weather Berlin 2000-2006, FeedBees TRUE, AddPolen TRUE

At least that's what I caught.

So I set both models to: ReadInFile FALSE, Weather: Rothamsted 2009, FeedBees TRUE, AddPolen TRUE and both runs seem to call the procedures the same number of times now:

This is the profiler results, 6.1.1 version on the right:


Miguel Pais

unread,
Nov 12, 2020, 8:33:45 AM11/12/20
to netlogo-users
Screenshot 2020-11-12 133250.png

Jeremy Baker

unread,
Nov 12, 2020, 9:42:57 AM11/12/20
to Volker Grimm, netlogo-users
Hey Volker,

Thank you for bringing this issue up.  I was able to confirm the problem.  I took a look through the code and nothing looked off to me.  I did some JVM profiling and discovered the issue is related to how NetLogo is looking for any `__includes` files in the model - it's running very slowly, and especially so when there is not an `__includes` statement there.

I'll see about a proper fix, but in the meantime a workaround is to add an `__includes []` declaration to your model.  It is fine that it is empty, it's just there to get the compiler to stop looking for it.  That should get code check times back to a manageable level.

Thanks again.

-Jeremy


From: netlog...@googlegroups.com <netlog...@googlegroups.com> on behalf of Volker Grimm <volker...@ufz.de>
Sent: Thursday, November 12, 2020 6:10 AM
To: netlogo-users <netlog...@googlegroups.com>
Subject: [netlogo-users] Code check for large model much slower with NL 6.1.1. than with NL 5.3.1
 
--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/534a9252-a1a9-45d8-88c7-52126c93d85cn%40googlegroups.com.

Jeremy Baker

unread,
Nov 12, 2020, 9:44:27 AM11/12/20
to Volker Grimm, netlogo-users
I meant to link the `__includes` docs as well, for anyone curious who is not familiar with the feature:  http://ccl.northwestern.edu/netlogo/docs/programming.html#multiple-source-files


From: netlog...@googlegroups.com <netlog...@googlegroups.com> on behalf of Jeremy Baker <jeremy...@northwestern.edu>
Sent: Thursday, November 12, 2020 8:42 AM
To: Volker Grimm <volker...@ufz.de>; netlogo-users <netlog...@googlegroups.com>
Subject: Re: [netlogo-users] Code check for large model much slower with NL 6.1.1. than with NL 5.3.1
 

Miguel Pais

unread,
Nov 12, 2020, 10:06:21 AM11/12/20
to netlogo-users
Oh the __includes[] is a great tip! It still takes longer to check in 6.1.1, but it gets better. Maybe it also has something to do with code conversion (AKA anonymous procedures?)

As for the run time, I did a side by side code comparison to check different settings on both versions and differences in code, and this is what I found:

                               old                                          new
ReadInFile           FALSE                                    TRUE
Weather             Rothamsted2009                  Berlin2000-2006
FeedBees            FALSE                                    TRUE
AddPolen            FALSE                                    TRUE
stopDead            TRUE                                      FALSE
X_Days                161                                         250
GenPlot2            colony struct                        # completed forag trips
GenPlot3            broodcare%                          colony struct
Foraging map   nec and polen                       all patches

In the start_IBM_foragingProc procedure, there are 2 print commands in the new version that are not in the old version:

print word "foragin round " ForagingRounds
print count foragersquadrons

In the DrawForagingMapProc, if set to "all patches", the code is different in both versions. The old version repeats a loop 1000 times and the new only 100, and the radius is multiplied by 0.1 in the new version only.

And I think that's it. The rest are code conversions to 6.1.1, which are mostly additions of  "x ->"

Jeremy Baker

unread,
Nov 12, 2020, 10:47:12 AM11/12/20
to Miguel Pais, netlogo-users
Hey Miguel,

Thanks for troubleshooting the runtime performance.

I don't think the code converter should come into play here.  It only runs when the model version in the file is old - so if you open a model with `NetLogo 5.3.1` in the version section, then it will run, but if you open a model with `NetLogo 6.1.1` in the version section, it should just skip over it assuming it's already updated.

I didn't look too much at the rest of the compile time in the profiler, but I think a lot of the rest of it for this model was on the widgets, and it does contain a lot of widgets.

-Jeremy


From: netlog...@googlegroups.com <netlog...@googlegroups.com> on behalf of Miguel Pais <migu...@gmail.com>
Sent: Thursday, November 12, 2020 9:06 AM
To: netlogo-users <netlog...@googlegroups.com>

Volker Grimm

unread,
Nov 12, 2020, 11:56:02 AM11/12/20
to netlogo-users
Great, thank you so much, Miguel and Jeremy! Using the  __includes[] trick  it became possible again to work much more effectively with the program (code check takes now about 4-5 seconds). And thanks for checking for code differences, Miguel! I did not look into that so far, your hints are very helpful!

Best regards,
Volker
Reply all
Reply to author
Forward
0 new messages