thomasmoelhave / tpie

Templated Portable I/O Environment
Other
112 stars 24 forks source link

Manage file descriptors like we do with memory #207

Closed tyilo closed 8 years ago

tyilo commented 8 years ago

Adds a new file_manager, which manages the amount of open files, which can be used like the memory manager (get_file_manager().register_increased_usage(...)). Both of the manager has been made a subclass of the new resource_manager and similarly the memory_runtime and the new file_runtime are also subclasses of the new resource_runtime.

In pipelining we now also assign files to nodes before assigning memory. Both serialization_sorter and the pipeline merge_sorter has been updated to accommodate this.

All the getters and setters for min/max/fraction/available memory now use the new interface where you give the type of the resource (FILES / MEMORY) as the first parameter and files can only be managed through these new functions. set_available_memory was used as both a callback to notify the node the amount of available memory has changed, but also internally when assigning memory. I have split the function in the new interface into resource_available_changed and _internal_set_available_of_resource, where only resource_available_changed is virtual and does nothing by default.

antialize commented 8 years ago

In general it looks good. I have added some comments with changes I would like to see. I will test it out with once i find some time.

tyilo commented 8 years ago

I have applied the changes you wanted. I have (tried) to fix the lines with only whitespace fixes and I have pushed this to another branch whitespace-fix-manage-fds as I don't think the GitHub comments will stay if I force push it.

I used the following script to do most of the work for me:

#!/bin/bash
r1=fa2c242cc1dcaa6479f4a10c0e5ce11f96fac0ec
r2=manage-fds
dir=/tmp/fix-whitespace

rm -rf "$dir"
mkdir -p "$dir"

git checkout "$r2"
git format-patch -U0 -w --no-color -o "$dir" "$r1"
git branch -D whitespace-fix-manage-fds
git checkout "$r1" -b whitespace-fix-manage-fds

for f in "$dir"/*.patch; do
    rev=$(head -1 < "$f" | cut -f2 -d' ')
    git apply --cached --ignore-whitespace --unidiff-zero "$f"
    #git add :/
    git commit -C "$rev"
    git clean -fd :/
done

Besides whitespace changes the head of the two branches are almost identical:

$ git diff -w manage-fds whitespace-fix-manage-fds
diff --git a/tpie/resource_manager.cpp b/tpie/resource_manager.cpp
index b65e6c4..8081bd3 100644
--- a/tpie/resource_manager.cpp
+++ b/tpie/resource_manager.cpp
@@ -41,10 +41,6 @@ size_t resource_manager::available() const throw() {
        return 0;
 }

-} // namespace tpie
-
-namespace tpie {
-
 void resource_manager::print_resource_complaint(std::ostream & os, size_t amount, size_t usage) {
        size_t diff = usage - m_limit;
antialize commented 8 years ago

Thanks, it is not that I do not want you to fix up whitespace, however it does add quite some noise, so i think it is best done only on files where you anyways change the a segnificant fraction of the content.

antialize commented 8 years ago

I rebased the whitespace-fix-manage-fds, and fixed a few issues causing terrastream to not compile/function. For my part we are ready to merge.

tyilo commented 8 years ago

Merged in #209.