Skip to content

Fix benchmarks failing and adjust compilation flags#118

Merged
miclegr merged 5 commits intospotify:mainfrom
miclegr:fix-benchmarks-failing-1
Mar 5, 2025
Merged

Fix benchmarks failing and adjust compilation flags#118
miclegr merged 5 commits intospotify:mainfrom
miclegr:fix-benchmarks-failing-1

Conversation

@miclegr
Copy link
Copy Markdown
Contributor

@miclegr miclegr commented Mar 3, 2025

Description

Three contributions in this PR:

  • Now that we have moved to nanobind and do not depend to numpy anymore, we need to install numpy when running the benchmarks.
  • when building python package compile native code using -O3 and some math optimization
  • Enable same math optimization in the native code build for the java package

@miclegr miclegr changed the title Fix benchmarks failing Fix benchmarks failing and adjust compilation flags Mar 4, 2025
Copy link
Copy Markdown
Member

@psobot psobot left a comment

Choose a reason for hiding this comment

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

Looks great, thank you @miclegr! Just one note (really a TODO) about applying these same optimizations on Windows, although only ~4% of our daily installs are on Windows so we may be able to do that separately.

Comment on lines +53 to +62
# Allow for some math optimization on unix but not -ffast-math
# See: https://simonbyrne.github.io/notes/fastmath/#flushing_subnormals_to_zero
if (IS_UNIX)
add_compile_options(-fassociative-math -fno-signaling-nans -fno-trapping-math -fno-signed-zeros -freciprocal-math -fno-math-errno)
endif()

# Relase build on unix with all optimizations
if (CMAKE_BUILD_TYPE STREQUAL "Release" AND IS_UNIX)
add_compile_options(-O3)
endif()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A TODO for later - we should probably specify /Ox here when building for MSVC/Windows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since it's trivial to add, I added it to this PR :)

@miclegr miclegr merged commit b8a6f7e into spotify:main Mar 5, 2025
62 checks passed
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.

2 participants