X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ea74f5d95928a521a588737e81f1de94eef25d19..bfffef69e1b0554d13eec920f1a32f75b49ceac6:/examples/python/io-degradation/io-degradation.py diff --git a/examples/python/io-degradation/io-degradation.py b/examples/python/io-degradation/io-degradation.py index 1b955b57b7..ae5ff1e5c1 100644 --- a/examples/python/io-degradation/io-degradation.py +++ b/examples/python/io-degradation/io-degradation.py @@ -1,41 +1,43 @@ -# Copyright (c) 2006-2022. The SimGrid Team. All rights reserved. +# Copyright (c) 2006-2023. The SimGrid Team. All rights reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. -# This example shows how to simulate a non-linear resource sharing for disk -# operations. -# -# It is inspired on the paper -# "Adding Storage Simulation Capacities to the SimGridToolkit: Concepts, Models, and API" -# Available at : https://hal.inria.fr/hal-01197128/document -# -# It shows how to simulate concurrent operations degrading overall performance of IO -# operations (specifically the effects presented in Fig. 8 of the paper). +""" +This example shows how to simulate a non-linear resource sharing for disk +operations. + +It is inspired on the paper +"Adding Storage Simulation Capacities to the SimGridToolkit: Concepts, Models, and API" +Available at : https://hal.inria.fr/hal-01197128/document + +It shows how to simulate concurrent operations degrading overall performance of IO +operations (specifically the effects presented in Fig. 8 of the paper). +""" -from simgrid import Actor, Engine, NetZone, Host, Disk, this_actor -import sys import functools +import sys +from simgrid import Actor, Engine, NetZone, Host, Disk, this_actor def estimate_bw(disk: Disk, n_flows: int, read: bool): """ Calculates the bandwidth for disk doing async operations """ size = 100000 - cur_time = Engine.get_clock() + cur_time = Engine.clock activities = [disk.read_async(size) if read else disk.write_async( size) for _ in range(n_flows)] for act in activities: act.wait() - elapsed_time = Engine.get_clock() - cur_time + elapsed_time = Engine.clock - cur_time estimated_bw = float(size * n_flows) / elapsed_time this_actor.info("Disk: %s, concurrent %s: %d, estimated bandwidth: %f" % ( disk.name, "read" if read else "write", n_flows, estimated_bw)) -def host(): +def host_runner(): # Estimating bw for each disk and considering concurrent flows for n in range(1, 15, 2): for disk in Host.current().get_disks(): @@ -57,11 +59,12 @@ def ssd_dynamic_sharing(disk: Disk, op: str, capacity: float, n: int) -> float: # measurements for SSD disks speed = { "write": {1: 131.}, - "read": {1: 152., 2: 161., 3: 184., 4: 197., 5: 207., 6: 215., 7: 220., 8: 224., 9: 227., 10: 231., 11: 233., 12: 235., 13: 237., 14: 238., 15: 239.} + "read": {1: 152., 2: 161., 3: 184., 4: 197., 5: 207., 6: 215., 7: 220., 8: 224., 9: 227., 10: 231., 11: 233., + 12: 235., 13: 237., 14: 238., 15: 239.} } # no special bandwidth for this disk sharing N flows, just returns maximal capacity - if (n in speed[op]): + if n in speed[op]: capacity = speed[op][n] return capacity @@ -112,13 +115,13 @@ if __name__ == '__main__': create_sata_disk(bob, "Griffon (SATA II)") zone.seal() - Actor.create("runner", bob, host) + Actor.create("runner", bob, host_runner) e.run() - this_actor.info("Simulated time: %g" % Engine.get_clock()) + this_actor.info("Simulated time: %g" % e.clock) # explicitly deleting Engine object to avoid segfault during cleanup phase. # During Engine destruction, the cleanup of std::function linked to non_linear callback is called. # If we let the cleanup by itself, it fails trying on its destruction because the python main program # has already freed its variables - del(e) + del e