-
Notifications
You must be signed in to change notification settings - Fork 103
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
Update rcutils_calculate_directory_size() to support recursion #306
Update rcutils_calculate_directory_size() to support recursion #306
Conversation
Related to #304 |
@clalancette @Karsten1987 friendly ping. i will be looking into this today. |
@@ -419,9 +419,9 @@ TEST_F(TestFilesystemFixture, calculate_directory_size) { | |||
#ifdef WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep the non-recursive test case like following.
- non-recursive test case: rcutils_calculate_directory_size(test/dummy_folder/dummy-subfolder/dummy-subfolder)
- recursive test case: rcutils_calculate_directory_size(test/dummy_folder)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This modification is to support recursion. So not support non-recursion.
If there is non-recursive test case, do you mean 2 API --- one for non-recursion and the other for recursion ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, i wasn't clear enough. what i mean is not about the function but test cases,
- test only files in a single directory. (non-recursive search
test
case) - test directories and files. (recursive search
test
case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have the overall concern about this, which is whether this change makes a difference to rosbag2. I'm still waiting to hear back from @Karsten1987 about that. Other than that, I have one more concern inline.
b7c3412
to
f517865
Compare
I updated codes to implement recursion without consuming memory from stack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got a bunch of stuff to fix in here.
One other thing; the inner loops for both the Windows and Unix sides are very similar. Do you think it is possible to use a common function for that?
Agree. So I try to change the interface to return -1 for error. |
39714fc
to
767fd78
Compare
I updated codes based on your comments.
I adopt this way to show error while calling rcutils_calculate_directory_size() or rcutils_calculate_directory_size_with_recursion(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more things to think about in here. This one is tricky to get right.
Sorry to late update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One major thing to change. We are getting closer, thanks for all of the revisions.
Updated. Please review again. |
src/filesystem.c
Outdated
size_t | ||
rcutils_calculate_directory_size(const char * directory_path, rcutils_allocator_t allocator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that it is hard to make API changes across repositories, but I do think we should do that here. In point of fact, this API has the same problems as the new rcutils_calculate_directory_size_with_recursion
had, namely:
- You can't tell if the return value is 0 because the call failed, or because there were just no files in the directory.
- On 32-bit, you can only return a size up to 4GB, which is pretty small.
So I think we should change this signature to:
rcutils_ret_t
rcutils_calculate_directory_size(const char *directory_path, uint64_t *size, rcutils_allocator_t allocator)
And also update rosbag2 to use that signature as well. It won't pass the PR job until we release both of them, but that's OK. We'll run normal CI (that's why we have it), and then I can merge both and do a release of both at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I will update rcutils_calculate_directory_size().
And update rosbag2' codes since rcutils_calculate_directory_size() is changed.
We'll run normal CI (that's why we have it)
I don't know this normal CI
. What is the difference with the current system ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know this
normal CI
. What is the difference with the current system ?
Sorry, I should have been more clear.
We actually have two separate types of CI. When you open a PR (and anytime you update it), the "Rpr" job runs on https://build.ros2.org. You can see the output of that down below in the "Checks" section of this PR. The PR job takes all of the current Rolling packages that this package depends on, installs them, checks this branch out, and then does a build-and-test. This is great as it is automatic, and gives us fairly quick feedback on small issues like compiler warnings, linter warnings, unit tests, etc. But it does have some problems:
- It won't test packages that depend on this package. So in this case, the PR job succeeded, but if we merge this and then try to build rosbag2, it would fail because of the changed API.
- If there are API changes in packages that this package depends on, it will just fail. There is no way to do a coordinated test across several repositories.
- It only tests Linux, not the other Tier-1 platforms.
For all of those reasons, we also have https://ci.ros2.org, where we can test all of the things above.
Therefore, for this PR, once we are happy with the code and it is approved, I can run a full test on ci.ros2.org to get cross-platform tests going, and with all packages that depend on this one.
Does that all make some sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your detailed explanation.
I get it.
I try to login https://ci.ros2.org and I think normal user have no permission to execute it.
So you will help to execute it. Right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you will help to execute it. Right ?
Yes, exactly. Once I approve, I'll go ahead and run the job on https://ci.ros2.org.
Codes have been updated. Please help to review. |
c8fcc29
to
7d89863
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great. I've got a few more minor things to fix up inline; once that is done, I'll go ahead and run CI. Thanks for all of the iterations here.
I did some minor cleanups in the test code just to avoid memory leaks if an assertion fails. You can see that work in 6b16702. With that, I'm happy with this code, so I'm going to approve and run CI. |
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
1. Revmoe header files for ssize_t 2. Update rcutils_calculate_directory_size() and related tests Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Chris Lalancette <[email protected]>
6b16702
to
bb4f1b1
Compare
So the Windows CMake warnings and test warnings can be ignored; those are in the nightlies (and at least some of them should be fixed for tomorrow). The MSBuild ones I believe are fixed on master. So I just rebased this whole thing onto master and force-pushed it. I'll run another Windows CI to check: |
All right, going ahead and merging along with ros2/rosbag2#567. Thanks for the contribution @Barry-Xu-2018 . |
No description provided.