Skip to content

Add local search operators stats#659

Merged
jcoupey merged 5 commits intomasterfrom
debug/operator-stats
Jan 25, 2022
Merged

Add local search operators stats#659
jcoupey merged 5 commits intomasterfrom
debug/operator-stats

Conversation

@jcoupey
Copy link
Copy Markdown
Collaborator

@jcoupey jcoupey commented Jan 25, 2022

Issue

Fixes #658

Tasks

  • Store type/number of moves tried at LocalSearch level
  • Store type/number of moves applied at LocalSearch level
  • Update CHANGELOG.md
  • review

@jcoupey jcoupey added this to the v1.12.0 milestone Jan 25, 2022
@jcoupey jcoupey merged commit abc6c77 into master Jan 25, 2022
@jcoupey jcoupey deleted the debug/operator-stats branch January 25, 2022 15:09
@krypt-n
Copy link
Copy Markdown
Contributor

krypt-n commented Jan 30, 2022

Did you by any chance benchmark this? It seems to have quite the impact (at least 15% if not more) and to be enabled by default. I think we should recommend users of vroom to compile with -DNDEBUG

@jcoupey
Copy link
Copy Markdown
Collaborator Author

jcoupey commented Jan 31, 2022

No, I didn't. I suspect that this is related to using an unordered_map to store the counts based on operator name:

https://github.com/VROOM-Project/vroom/blob/master/src/algorithms/local_search/local_search.cpp#L548

While this is constant-time-ish, there are a lot of occurrences of those updates. Setting aside the fact that users are already advised to build against tagged versions (so with -DNDEBUG enabled), I agree we can do better. Options include:

  • store counts in plain std::arrays by assigning a rank to all operators (instead of a name), this would be a bit less straightforward to follow and maintain, especially for the count of applied moves which is the reason I went for name indexing in the first place;
  • since this is only really required for dev purposes, put this behind another flag that one has to add explicitly.

We should probably do both.

@krypt-n
Copy link
Copy Markdown
Contributor

krypt-n commented Jan 31, 2022

Setting aside the fact that users are already advised to build against tagged versions (so with -DNDEBUG enabled),

Ah I wasn't aware of that. Then it is not as much of an issue as I thought.

I suspect that this is related to using an unordered_map to store the counts based on operator name

String hashing appears to be the bottleneck according to my profiling. I think a quick fix could be to replace the string names with an enumeration

enum OperatorName {
    UnassignedExchange,
    CrossExchange,
    ...
}

and an additional array to convert the enum-values to strings for printing.

@jcoupey jcoupey mentioned this pull request Jan 31, 2022
3 tasks
@jcoupey
Copy link
Copy Markdown
Collaborator Author

jcoupey commented Jan 31, 2022

@krypt-n I've sketched some changes in #667 based on your suggestion. Feel free to review it if you can!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug info on local search operators

2 participants