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

Convert test to benchmark (radius search) #5851

Merged
merged 19 commits into from
Nov 25, 2023

Conversation

Zekrom-7780
Copy link
Contributor

feature: Added benchmark for OrganizedNeighborSearch

Converted the existing test code for OrganizedNeighborSearch into a proper benchmark.
#4718 (comment) This benchmark measures the time needed for setInputCloud and radiusSearch operations with an organized point cloud. The brute force search part has been removed as it is not needed.

Should solve Issue 4718

Soo Sorry that I wasn't able to rebase the multiple commits into a single one

@mvieth
Copy link
Member

mvieth commented Oct 21, 2023

  • Please remove the file .vscode/c_cpp_properties.json from this pull request
  • To fix the formatting problems, you can either click on the failing check to reach the log on Azure Pipelines (see "Show diff"), or use this script, or run make format on Linux (not sure whether this works on Windows too?)
  • Please remove the test in test_organized_index.cpp then
  • Please add it to benchmarks/CMakeLists.txt so that the benchmark is actually built
  • I would suggest to use benchmarks/search/radius_search.cpp instead of benchmarks/organized_index/organized_index.cpp

@Zekrom-7780
Copy link
Contributor Author

@mvieth, I've made the changes you suggested in the previous comments:

  1. I removed the test in test_organized_index.cpp.
  2. I changed the name of the benchmark to benchmark/search/radius_search.cpp.
  3. I ran make format after navigating to the .dev directory (cd .dev).
  4. I made the changes in the benchmarks/CMakeLists.txt

The strange thing is that build formatting ran successfully for c16fd5c, but the regular build failed because I hadn't pushed the change in the benchmark's name (benchmarks/organized_index/organized_index.cpp instead of benchmarks/search/radius_search.cpp). I understand the issue from looking at Azure Pipelines, as you suggested me to do.

However, in the subsequent commit (8834f04) and the latest one, the build formatting failed again.

I tried running different shell commands mentioned in the comments of this script like
sh ./.dev/format.sh /usr/bin/clang-format ./, but none of them resolved the issue.

I apologize for any inconvenience related to the multiple commits. I also apologize asking so many doubts in a
good-first-issue . Can you please provide some guidance or suggestions on how to resolve the formatting issue in the latest commits?

Thank you for your assistance.

@mvieth
Copy link
Member

mvieth commented Oct 24, 2023

I am not sure why make format or running the formatting script does not work. Are there any error messages?
If nothing else works, you can always click on the failing Formatting Check code formatting, navigate to Azure Pipelines, and finally select the Show diff stage under Check code formatting. This is what it currently shows.
You also added .dev/format? I don't know whether you copied or renamed that locally, but you need to remove .dev/format again from this pull request. I strongly suggest to not add all local changes to git before you do a commit, but instead to add file by file so you can choose what you commit.

@Zekrom-7780
Copy link
Contributor Author

@mvieth , I RAN the make_format code PROPERLY NOW, ./format.sh /usr/bin/clang-format /home/user/pcl, in the /pcl/.dev directory, and the code ran for an infinite loop saying :-

Error reading /home/user/pcl/.clang-format: Invalid argument
YAML:47:22: error: unknown key 'CaseSensitive'
    CaseSensitive:   true
                     ^~~~

So, I commented this line, and ran this code, it modified multiple files EXCEPT THE CHANGED .LANG_FORMAT, and I pushed the modified files, but still, the formatting code did not run.

Could you suggest on how to fix this error, as by commenting it, the build_formatting didn't run

@mvieth
Copy link
Member

mvieth commented Oct 26, 2023

Which version of clang-format are you using? You need at least version 12, because older versions do not understand CaseSensitive. In fact, I would recommend to use version 14 because that is what the formatting check is using, and older versions have made some formatting mistakes that are fixed in version 14.
If you look at the log of the failing formatting check, you will see that it complains about changes in some other files that you pushed (e.g. apps/in_hand_scanner/src/integration.cpp), but has no complains about benchmarks/search/radius_search.cpp.
Let me recommend again to check what you add/stage (and thus which changes you include in the commit). Adding all changes in all files is pretty much never a good idea. This article might be interesting for you: https://github.com/git-guides/git-add

@mvieth
Copy link
Member

mvieth commented Nov 18, 2023

@Zekrom-7780 Hi, I just wanted to ask whether you are still working on this pull request? Was my last comment helpful?

@Zekrom-7780
Copy link
Contributor Author

@mvieth , I'm working on this issue, my college became pretty hectic for the last month
Installing clang-format-14 , and making the changes
Sorry for the delay.

@Zekrom-7780
Copy link
Contributor Author

@mvieth , the changes are made, updated clang-format, and right now the formatting check code has passed!

So Sorry for all the trouble!
Can I take another issue up as well?
Since I've understood how to do this?

Copy link
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

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

Can I take another issue up as well?
Since I've understood how to do this?

Sure, go ahead. If you would like my opinion on which issues are high priority, I am happy to suggest some 🙂

@@ -25,3 +25,8 @@ PCL_ADD_BENCHMARK(filters_voxel_grid FILES filters/voxel_grid.cpp
ARGUMENTS "${PCL_SOURCE_DIR}/test/table_scene_mug_stereo_textured.pcd"
"${PCL_SOURCE_DIR}/test/milk_cartoon_all_small_clorox.pcd")

PCL_ADD_BENCHMARK(search_radius_search FILES search/radius_search.cpp
LINK_WITH pcl_io pcl_search pcl_features
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
LINK_WITH pcl_io pcl_search pcl_features
LINK_WITH pcl_io pcl_search

Linking the features lib should not be necessary here?

std::vector<int> k_indices;
std::vector<float> k_sqr_distances;

auto check_time = benchmark::Now();
Copy link
Member

Choose a reason for hiding this comment

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

The compiler doesn't know benchmark::Now(). Unless you have a better idea, I would suggest to simply use the default/automatic way and measure the duration of all functions in the for loop.

for (auto _ : state) {
organizedNeighborSearch.setInputCloud(cloudIn);

int randomIdx = rand() % cloudIn->size();
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it make sense to use a set of fixed indexes and radiies?
Not sure if these rands can make it difficult to compare etc?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that is a good point. Random indices would at least add more noise in the time measurements, so that more iterations are necessary to reach a stable result. Alternatively, we could simply use every point from the input cloud once as the search point, and a fixed radius for all searches, e.g. 0.1 or 0.05?

@Zekrom-7780
Copy link
Contributor Author

Thanks a lot for the suggestions @mvieth @larshg !
Will do the implementations and send the changes in 3-4 hours

Also @mvieth , could you direct me to the issues with high priority ??

@mvieth
Copy link
Member

mvieth commented Nov 22, 2023

@Zekrom-7780
Copy link
Contributor Author

@mvieth @larshg , what should I do in this PR?
All the checks have passed here

Copy link
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

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

I am fine with the proposed changes. Thanks!

what should I do in this PR?
All the checks have passed here

If Lars has any additional suggestions or requests, please address them, otherwise you are done here 😄 We will merge this pull request when we both approved

@larshg larshg merged commit 50c4064 into PointCloudLibrary:master Nov 25, 2023
13 checks passed
@mvieth mvieth changed the title Issue 4718 Convert test to benchmark (radius search) Nov 25, 2023
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.

3 participants