Author Topic: LABEL slowdown  (Read 1504 times)

Offline DavidW

  • Planewalker
  • *****
  • Posts: 316
LABEL slowdown
« on: September 05, 2018, 04:13:05 PM »
A note about LABEL: in some circumstances it significantly slows down WEIDU.

I just rewrote SCS's tp2 file (which is structurally very minimal: no content in any component except REQUIREs, FORBIDs, DESIGNATED, a marker file, and a function call) to use LABEL. So every component got a label, and I did internal checks via REQUIRE_PREDICATE MOD_IS_INSTALLED blah ID_OF_LABEL blahblah. Weidu hung for about 10 seconds whenever I ran it. After a couple days I found that so annoying that I went back to using DESIGNATED or marker files.


Now: SCS has 120-odd components and 150-odd checks for components, so I appreciate it's an extreme case. But I thought it was worth flagging, since I think LABEL has hardly ever been used in the wild and the code / method of implementation might not be optimized. That's especially relevant if Alien's GUID gets installed and it uses the LABEL method as a code base. (Don't bother speeding up LABEL just for my sake, though - I'm actually perfectly content with my current implementation.)
« Last Edit: September 05, 2018, 04:17:57 PM by DavidW »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: LABEL slowdown
« Reply #1 on: September 08, 2018, 06:18:41 AM »
I don't suppose you still retain your LABEL implementation? If so, could I have a copy of it? Or a debug file from one of these slow installs?

An unsophisticated test with 150 LABELled components and 149 REQUIRE_PREDICATE MOD_IS_INSTALLED ... ID_OF_LABEL takes about 1.5 seconds to install for me, with about half that time being spent on processing ID_OF_LABEL (mostly in parsing). The implementation of LABEL is a little work, since every time a LABEL is processed, it's resolved in order to check for duplicates and such. ID_OF_LABEL is a bit worse, since it loads and parses the target TP2 file every time it resolves a label. That's perhaps something that could be optimised, but I'd have to look into it in greater detail.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: LABEL slowdown
« Reply #2 on: September 09, 2018, 03:10:32 PM »
Having WeiDU cache the parsed TP2 for ID_OF_LABEL reduces the time to marginally slower than using the plain component number (which can't really be helped since resolving something into a number is always going to be slower than starting with already having the number), but solves the troublesome parsing times. If further optimisations are necessary, I'm going to need a problematic case to profile.

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 391
  • Gender: Male
Re: LABEL slowdown
« Reply #3 on: September 10, 2018, 04:17:04 AM »
@wisp I think that you need to provide new weidu (BETA?) if you wana get DavidW to try it again.
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

Offline DavidW

  • Planewalker
  • *****
  • Posts: 316
Re: LABEL slowdown
« Reply #4 on: September 10, 2018, 06:58:17 PM »
No, I’ve just been away. I’ll dig out a copy when I get home.

Offline DavidW

  • Planewalker
  • *****
  • Posts: 316
Re: LABEL slowdown
« Reply #5 on: September 11, 2018, 12:01:35 AM »
Hopefully this is a link to the relevant version of the tp2:

https://www.dropbox.com/s/emw8kxsznpyzti2/setup-stratagems%20for%20wisp.zip?dl=0

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 391
  • Gender: Male
Re: LABEL slowdown
« Reply #6 on: March 19, 2024, 06:29:54 AM »
I know the improvements like this one, but Labels need more love.

The recent test reveals that the "slowdowns at the very start of running the mod, and subsequent slowdowns at the start of every component" still prevent modders from adding labels: post

I've done an additional test, it seems that adding labels to the components with LAF doesn't increase the install time much. Maybe the problem is not entirely labels but also LAF? Or some other thing?

In case you would like to try various weidu code changes, you could just put them in a new branch, I can compile weidu, run tests and report back.

Testing Suite, you can point to the different weidu.exe: https://github.com/ALIENQuake/LabelsTest

Tests:
# tp2 with 1000 random empty components, attempt 1
Quote
Labels Disabled, No LAF
17:03:42 : ID: LabelsTest | FileName: LabelsTest-Clean
17:03:42 : Weidu Path: WeiDU.exe
17:03:42 : WeiDU Version: 24900


17:03:42 :TotalMinutes: 0,10
17:03:42 :TotalSeconds: 6
17:03:42 :TotalMilliseconds: 5 905


Labels Enabled, No LAF
17:03:23 : ID: LabelsTest | FileName: LabelsTest-Labels
17:03:23 : Weidu Path: WeiDU.exe
17:03:23 : WeiDU Version: 24900


17:03:23 :TotalMinutes: 0,11
17:03:23 :TotalSeconds: 7
17:03:23 :TotalMilliseconds: 6 829


Labels Disabled, LAF
17:03:04 : ID: LabelsTest | FileName: LabelsTest-LAF
17:03:04 : Weidu Path: WeiDU.exe
17:03:04 : WeiDU Version: 24900


17:03:04 :TotalMinutes: 0,12
17:03:04 :TotalSeconds: 7
17:03:04 :TotalMilliseconds: 7 241


Labels Enabled, LAF
17:03:03 : ID: LabelsTest | FileName: LabelsTest-LAFLabels
17:03:03 : Weidu Path: WeiDU.exe
17:03:03 : WeiDU Version: 24900


17:03:03 :TotalMinutes: 0,11
17:03:03 :TotalSeconds: 7
17:03:03 :TotalMilliseconds: 6 767


# tp2 with 1000 random empty components, attempt 2

Quote
Labels Disabled, No LAF
07:03:58 : ID: LabelsTest | FileName: LabelsTest-Clean
07:03:58 : Weidu Path: WeiDU.exe
07:03:58 : WeiDU Version: 24900


07:03:58 :TotalMinutes: 0,10
07:03:58 :TotalSeconds: 6
07:03:58 :TotalMilliseconds: 6 178


Labels Enabled, No LAF
07:03:20 : ID: LabelsTest | FileName: LabelsTest-Labels
07:03:20 : Weidu Path: WeiDU.exe
07:03:20 : WeiDU Version: 24900


07:03:20 :TotalMinutes: 0,12
07:03:20 :TotalSeconds: 7
07:03:20 :TotalMilliseconds: 7 415


Labels Enabled, LAF
07:03:45 : ID: LabelsTest | FileName: LabelsTest-LAF
07:03:45 : Weidu Path: WeiDU.exe
07:03:45 : WeiDU Version: 24900


07:03:45 :TotalMinutes: 0,12
07:03:45 :TotalSeconds: 7
07:03:45 :TotalMilliseconds: 7 466


Labels Enabled, LAF
07:03:12 : ID: LabelsTest | FileName: LabelsTest-LAFLabels
07:03:12 : Weidu Path: WeiDU.exe
07:03:12 : WeiDU Version: 24900


07:03:12 :TotalMinutes: 0,12
07:03:12 :TotalSeconds: 7
07:03:12 :TotalMilliseconds: 7 225


Stratagems 35.10,

Quote
# Labels Enabled
10:03:32 : ID: stratagems | Tp2 BaseName: setup-stratagems-LAFLabels
10:03:32 : Weidu Path: WeiDU.exe
10:03:32 : WeiDU Version: 24900
List: 1500 1510 1520 1600 1610 2000 2010 2020 2030 2040 2050 2060 2070 2080 2500 2510 2520 2900 3010 3015 3017 3020 3021 3022 3040 3041 3500 3501 3505 3510 3540 3541 3550 3551 3552 3580 4000 4020 4030 4050 4051 4052 4093 4099 4100 4115 4130 4135 4140 4145 4146 4150 4160 4161 4162 4163 4164 4170 4171 4172 4173 4174 4190 4210 4215 4216 4217 4218 4230 4240 4250 5000 5070 5080 5900 6000 6010 6020 6030 6040 6100 6200 6300 6310 6320 6500 6510 6520 6540 6550 6560 6570 6580 6590 6700 6800 6810 6820 6830 6840 6850 7000 7010 7020 7030 7040 7050 7060 7070 7080 7090 7100 7110 7130 7140 7150 7200 7210 7220 7230 7250 7900 8000 8010 8020 8040 8050 8060 8070 8080 8085 8090 8100 8110 8120 8130 8140 8150 8160 8170 8180 8190

10:03:32 :TotalMinutes: 42,63
10:03:32 :TotalSeconds: 2 558
10:03:32 :TotalMilliseconds: 2 557 881


# Labels Disabled
11:03:28 : ID: stratagems | Tp2 BaseName: setup-stratagems-LAF
11:03:28 : Weidu Path: WeiDU.exe
11:03:28 : WeiDU Version: 24900
List: 1500 1510 1520 1600 1610 2000 2010 2020 2030 2040 2050 2060 2070 2080 2500 2510 2520 2900 3010 3015 3017 3020 3021 3022 3040 3041 3500 3501 3505 3510 3540 3541 3550 3551 3552 3580 4000 4020 4030 4050 4051 4052 4093 4099 4100 4115 4130 4135 4140 4145 4146 4150 4160 4161 4162 4163 4164 4170 4171 4172 4173 4174 4190 4210 4215 4216 4217 4218 4230 4240 4250 5000 5070 5080 5900 6000 6010 6020 6030 6040 6100 6200 6300 6310 6320 6500 6510 6520 6540 6550 6560 6570 6580 6590 6700 6800 6810 6820 6830 6840 6850 7000 7010 7020 7030 7040 7050 7060 7070 7080 7090 7100 7110 7130 7140 7150 7200 7210 7220 7230 7250 7900 8000 8010 8020 8040 8050 8060 8070 8080 8085 8090 8100 8110 8120 8130 8140 8150 8160 8170 8180 8190

11:03:28 :TotalMinutes: 45,99
11:03:28 :TotalSeconds: 2 759
11:03:28 :TotalMilliseconds: 2 759 324
« Last Edit: March 19, 2024, 07:52:53 AM by AL|EN »
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: