Skip to content

Possible 50% performance improvement for NSGA-II on MSVC #616

Open
jonas-s-s-s wants to merge 11 commits intoesa:masterfrom
jonas-s-s-s:master
Open

Possible 50% performance improvement for NSGA-II on MSVC #616
jonas-s-s-s wants to merge 11 commits intoesa:masterfrom
jonas-s-s-s:master

Conversation

@jonas-s-s-s
Copy link

Hello everyone,
as part of my Master's Thesis (Faculty of Applied Sciences, University of West Bohemia), I have been investigating the poor performance of pagmo2's implementation of NSGA2 when compiled with MSVC. The changes that I've made decrease the execution time by about 50% (MSVC 19.44.35217). This improvement was possible due to the inefficiency of std::isnan in the MSVC Runtime Library.
Other compilers such as (Clang and GCC) benefit mainly from the memory optimizations, decreasing the execution time by about 15%.

The main changes in this PR include:

  • Reimplemented less_than_f, greater_than_f, equal_to_f using C++20 starship operator
    • 30% performance improvement on MSVC
  • Inlined pareto_dominance()
    • Eliminated high function call overhead in hot path loops
  • Added fast_non_dominated_sorting_buffered() and select_best_N_mo_buffered()
    • Prevents repeated destruction an re-allocation of std::vectors that are used as a return value
    • Obviously this "duplicates" the logic of these functions, however making a new function which has the pre-allocated struct passed to it as parameter was the only option since these functions aren't part of any class we can't use class members for this

Detailed explanation together with the code that was used for profiling can be found here: https://github.com/jonas-s-s-s/Pagmo-NSGA2-Improve-Test

Version of a hot-path function with pre-allocated vectors, reduced CPU time spent on vector allocation approximately from 7% to 1%.
Minor 0.1% / 0.2% performance increase

Switch to passing struct via function params instead of static

Static is not thread-safe

Add another fnds_buffer inside of nsga2.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant