Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add the capacity the update the priority of an I/O during its execution
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Fri, 29 Oct 2021 14:58:54 +0000 (16:58 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Fri, 29 Oct 2021 15:01:50 +0000 (17:01 +0200)
MANIFEST.in
examples/cpp/CMakeLists.txt
examples/cpp/io-basic/s4u-io-basic.tesh [deleted file]
examples/cpp/io-priority/s4u-io-priority.cpp [moved from examples/cpp/io-basic/s4u-io-basic.cpp with 59% similarity]
examples/cpp/io-priority/s4u-io-priority.tesh [new file with mode: 0644]
include/simgrid/s4u/Io.hpp
src/kernel/activity/IoImpl.cpp
src/kernel/activity/IoImpl.hpp
src/kernel/lmm/maxmin.cpp
src/kernel/resource/Action.cpp
src/s4u/s4u_Io.cpp

index d88dde2..db4e029 100644 (file)
@@ -260,8 +260,6 @@ include examples/cpp/exec-waitfor/s4u-exec-waitfor.cpp
 include examples/cpp/exec-waitfor/s4u-exec-waitfor.tesh
 include examples/cpp/io-async/s4u-io-async.cpp
 include examples/cpp/io-async/s4u-io-async.tesh
-include examples/cpp/io-basic/s4u-io-basic.cpp
-include examples/cpp/io-basic/s4u-io-basic.tesh
 include examples/cpp/io-degradation/s4u-io-degradation.cpp
 include examples/cpp/io-degradation/s4u-io-degradation.tesh
 include examples/cpp/io-dependent/s4u-io-dependent.cpp
@@ -273,6 +271,8 @@ include examples/cpp/io-file-remote/s4u-io-file-remote.tesh
 include examples/cpp/io-file-remote/s4u-io-file-remote_d.xml
 include examples/cpp/io-file-system/s4u-io-file-system.cpp
 include examples/cpp/io-file-system/s4u-io-file-system.tesh
+include examples/cpp/io-priority/s4u-io-priority.cpp
+include examples/cpp/io-priority/s4u-io-priority.tesh
 include examples/cpp/maestro-set/s4u-maestro-set.cpp
 include examples/cpp/maestro-set/s4u-maestro-set.tesh
 include examples/cpp/mc-bugged1-liveness/promela_bugged1_liveness
index c111550..a09d9cf 100644 (file)
@@ -74,7 +74,7 @@ foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
                  maestro-set
                  mc-bugged1 mc-bugged2 mc-electric-fence mc-failing-assert
                                 network-wifi
-                 io-async io-basic io-degradation io-file-system io-file-remote io-disk-raw io-dependent
+                 io-async io-priority io-degradation io-file-system io-file-remote io-disk-raw io-dependent
                  platform-failures platform-profile platform-properties
                  plugin-host-load plugin-link-load plugin-prodcons
                  replay-comm replay-io
diff --git a/examples/cpp/io-basic/s4u-io-basic.tesh b/examples/cpp/io-basic/s4u-io-basic.tesh
deleted file mode 100644 (file)
index 4fd0f1c..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env tesh
-
-$ ${bindir:=.}/s4u-io-basic ${platfdir}/hosts_with_disks.xml
-> [bob:privileged_writer:(2) 0.150000] [s4u_test/INFO] Done.
-> [bob:writer:(1) 0.200000] [s4u_test/INFO] Done.
similarity index 59%
rename from examples/cpp/io-basic/s4u-io-basic.cpp
rename to examples/cpp/io-priority/s4u-io-priority.cpp
index 77e1213..1c8f478 100644 (file)
@@ -13,7 +13,10 @@ static void writer()
   std::vector<simgrid::s4u::Disk*> const& disk_list = simgrid::s4u::Host::current()->get_disks();
   /* - Write 4,000,000 bytes on Disk1 */
   disk_list.front()->write(4000000);
-  XBT_INFO("Done.");
+  XBT_INFO("First write done.");
+  /* - Write 4,000,000 bytes on Disk1 again */
+  disk_list.front()->write(4000000);
+  XBT_INFO("Second write done.");
 }
 
 static void privileged_writer()
@@ -27,11 +30,33 @@ static void privileged_writer()
    *
    * So instead of a half/half sharing between the two, we get a 1/3 vs. 2/3 sharing. */
   disk_list.front()->io_init(4000000, simgrid::s4u::Io::OpType::WRITE)->set_priority(2)->wait();
-  XBT_INFO("Done.");
+  XBT_INFO("First write done.");
 
   /* Note that the timings printed when running this example are a bit misleading, because the uneven sharing only last
    * until the privileged actor ends. After this point, the unprivileged one gets 100% of the disk and finishes quite
    * quickly. */
+
+  /* Resynchronize actors before second write */
+  simgrid::s4u::this_actor::sleep_for(0.05);
+
+  /* - Write 4,000,000 bytes on Disk1 again and this time :
+   *    - Start the I/O operation asynchronously to get an IoPtr
+   *    - Let the actor sleep while half of the data is written
+   *    - Double its priority
+   *    - Wait for the end of the I/O operation
+   *
+   *   Writing the second half of the data with a higher priority, and thus 2/3 of the bandwidth takes 0.075s.
+   *   In the meantime, the regular writer has only 1/3 of the bandwidth and thus only writes 1MB. After the completion
+   *   of the I/O initiated by the privileged writer, the regular writer has the full bandwidth available and only needs
+   *   0.025s to write the last MB.
+   */
+
+  simgrid::s4u::IoPtr io = disk_list.front()->write_async(4000000);
+  simgrid::s4u::this_actor::sleep_for(0.1);
+  XBT_INFO("Increase priority for the priviledged writer (%.0f bytes remaining to write)", io->get_remaining());
+  io->update_priority(2);
+  io->wait();
+  XBT_INFO("Second write done.");
 }
 
 int main(int argc, char* argv[])
diff --git a/examples/cpp/io-priority/s4u-io-priority.tesh b/examples/cpp/io-priority/s4u-io-priority.tesh
new file mode 100644 (file)
index 0000000..3a9b3e6
--- /dev/null
@@ -0,0 +1,8 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-io-priority ${platfdir}/hosts_with_disks.xml
+> [bob:privileged_writer:(2) 0.150000] [s4u_test/INFO] First write done.
+> [bob:writer:(1) 0.200000] [s4u_test/INFO] First write done.
+> [bob:privileged_writer:(2) 0.300000] [s4u_test/INFO] Increase priority for the priviledged writer (2000000 bytes remaining to write)
+> [bob:privileged_writer:(2) 0.375000] [s4u_test/INFO] Second write done.
+> [bob:writer:(1) 0.400000] [s4u_test/INFO] Second write done.
index 14abc92..2f59686 100644 (file)
@@ -50,6 +50,8 @@ public:
   IoPtr set_size(sg_size_t size);
   IoPtr set_op_type(OpType type);
 
+  IoPtr update_priority(double priority);
+
   bool is_assigned() const override;
 };
 
index a714e97..4038c62 100644 (file)
@@ -34,6 +34,13 @@ IoImpl& IoImpl::set_sharing_penalty(double sharing_penalty)
   return *this;
 }
 
+IoImpl& IoImpl::update_sharing_penalty(double sharing_penalty)
+{
+  sharing_penalty_ = sharing_penalty;
+  surf_action_->set_sharing_penalty(sharing_penalty);
+  return *this;
+}
+
 IoImpl& IoImpl::set_timeout(double timeout)
 {
   const s4u::Host* host = get_disk()->get_host();
index 2c2ab5b..d3b84fd 100644 (file)
@@ -32,6 +32,8 @@ public:
   IoImpl& set_type(s4u::Io::OpType type);
   IoImpl& set_disk(resource::DiskImpl* disk);
 
+  IoImpl& update_sharing_penalty(double sharing_penalty);
+
   sg_size_t get_performed_ioops() const { return performed_ioops_; }
   resource::DiskImpl* get_disk() const { return disk_; }
 
index fba53b3..a7514de 100644 (file)
@@ -823,7 +823,7 @@ void System::update_variable_penalty(Variable* var, double penalty)
   bool enabling_var  = (penalty > 0 && var->sharing_penalty_ <= 0);
   bool disabling_var = (penalty <= 0 && var->sharing_penalty_ > 0);
 
-  XBT_IN("(sys=%p, var=%p, penalty=%f)", this, var, penalty);
+  XBT_IN("(sys=%p, var=%p, var->sharing_penalty = %f, penalty=%f)", this, var, var->sharing_penalty_, penalty);
 
   modified_ = true;
 
@@ -843,6 +843,8 @@ void System::update_variable_penalty(Variable* var, double penalty)
     disable_var(var);
   } else {
     var->sharing_penalty_ = penalty;
+    if (not var->cnsts_.empty())
+      update_modified_set(var->cnsts_[0].constraint);
   }
 
   check_concurrency();
index 825578b..06ef145 100644 (file)
@@ -129,7 +129,6 @@ void Action::set_sharing_penalty(double sharing_penalty)
   XBT_IN("(%p,%g)", this, sharing_penalty);
   sharing_penalty_ = sharing_penalty;
   model_->get_maxmin_system()->update_variable_penalty(get_variable(), sharing_penalty);
-
   if (model_->is_update_lazy())
     model_->get_action_heap().remove(this);
   XBT_OUT();
index 4906e79..ea8960b 100644 (file)
@@ -105,6 +105,14 @@ IoPtr Io::set_op_type(OpType type)
   return this;
 }
 
+IoPtr Io::update_priority(double priority)
+{
+  kernel::actor::simcall([this, priority] {
+    boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->update_sharing_penalty(1. / priority);
+  });
+  return this;
+}
+
 /** @brief Returns the amount of flops that remain to be done */
 double Io::get_remaining() const
 {