Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise: getGear for large item counts #39

Merged
merged 2 commits into from
Sep 17, 2016
Merged

Optimise: getGear for large item counts #39

merged 2 commits into from
Sep 17, 2016

Conversation

Sniperhid
Copy link
Member

When merged this pull request will:

  • Improve acre_lib_fnc_getGear. Only returns ACRE radios. This improves performance for many of the frequently run gear checks. Particularly for high item counts. This should prove gains particularly when running ACE due to all the new items.
  • Local check for uninitialised radio worst case performance significantly lowered (38 to 2 milliseconds for 400 items). This was causing noticable stutter for medics carrying large amounts of medical supplies
  • Server radio ID monitor runs faster particularly when doing a full search. I created a test mission with ~10 equipment crates, ~10 vehicles and several squads of AI. With the getGear improvement it ran twice as fast (50ms v 24ms) with 150 vanilla units (running ACE). I later implemented the optimisation for ItemCargo. Further reducing runtime from 24 ms to 20ms.
  • Downside all acre radios should begin with acre*. Several other solutions were tested but this led to the best performance.

…r radios

In extreme cases 400 ace medical items performance for monitorRadios goes from 38millisecond to 2 milliseconds.
@Sniperhid Sniperhid added this to the 2.3.0 milestone Sep 16, 2016
@NouberNou NouberNou changed the title Optimise: getGear for lage itemcounts Optimise: getGear for large item counts Sep 17, 2016
@@ -240,6 +240,9 @@ FUNC(getGear) = {
if (isNull _unit) exitWith {[]};
// diag_log text format["Assigned Items: %1", (assignedItems _unit)];
private _gear = (weapons _unit) + (items _unit) + (assignedItems _unit);
_gear = _gear select {(_x select [0, 4]) == "ACRE" || _x == "ItemRadio" || _x == "ItemRadioAcreFlagged"}; // We are only interested in ACRE gear.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A substring check is faster than a config check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, even without lazy eval here. I didn't lazy eval to improve worst case performance (lazy eval adds some overhead). Though the monitorRadios function (client check for uninitalized radios and a few other things) would do 3 config lookups for each equipment return. But filtering in getGear seems to speed it up. Each in the server masterIDTracker there is a speed up and that's only 1 config look up.

Copy link
Member

@jonpas jonpas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Sniperhid Sniperhid merged commit 176a301 into master Sep 17, 2016
@Sniperhid Sniperhid deleted the itemcheck branch September 17, 2016 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants