MQSim Simulator

repository·master·Indexed 18 days ago

https://github.com/cmu-safari/mqsim

A high-fidelity simulator for modern NVMe and SATA SSDs. MQSim models multi-queue protocols, steady-state behavior, and end-to-end I/O latency. It supports configuration via XML files for Host, SSD Device, and NAND Flash parameters, and can be run on Linux or Windows. The repository includes resources to replicate experiments from the FAST 2018 paper, focusing on write cache contention, SSD back end contention, and the QueueFetchSize parameter.

Tokens
12K
Snippets
19
Records
54
Agent score
62%

What's inside MQSim

  1. Overview of MQSim

    master

    MQSim is a simulator designed to capture the behavior of both modern multi-queue NVMe SSDs and conventional SATA-based SSDs. It models several critical features including:

    • Modern multi-queue-based host–interface protocols (e.g., NVMe).
    • Steady-state SSD behavior.
    • End-to-end latency of I/O requests.

    MQSim can be operated as a standalone tool or integrated into a full-system simulator.

  2. Define MQSim workloads using XML

    master

    MQSim workloads are defined in an XML file. If the specified file does not exist, MQSim will automatically create a sample file named workload.xml.

    Workloads are organized into a hierarchy:

    1. <MQSim_IO_Scenarios>: The root container for all workload definitions.
    2. <IO_Scenario>: A set of workloads executed together. MQSim simulates each scenario separately by rebuilding the Host and SSD models and generating a unique output file (e.g., workload_scenario_1.xml).
    3. Workloads: Within an <IO_Scenario>, you can define up to 8 individual workloads. These can be either trace-based (using real system data) or synthetic (generated by MQSim).

    Example structure:

    <MQSim_IO_Scenarios>
    	<IO_Scenario>
    		<!-- Up to 8 workloads here -->
    	</IO_Scenario>
    	<IO_Scenario>
    		<!-- Up to 8 workloads here -->
    	</IO_Scenario>
    </MQSim_IO_Scenarios>
  3. Run MQSim on Linux

    master

    To use MQSim on a Linux environment, compile the project using make and then execute the binary by providing the SSD configuration file and the workload definition file using the -i and -w flags respectively.

    $ make
    $ ./MQSim -i <SSD Configuration File> -w <Workload Definition File>
  4. Analyze MQSim XML output files

    master

    MQSim produces XML output files containing simulation statistics. You can analyze these using an XML processor like MS Excel.

    Using MS Excel for Analysis:

    1. Open the XML file in Excel.
    2. Choose the "Use the XML Source task pane" option.
    3. Drag and drop desired parameters from the task source pane onto the sheet.
    4. To update values, right-click the cell and select XML > Refresh XML Data.

    Output Categories:

    Host Statistics (per IO_Flow)

    • Name: The name of the IO flow.
    • Request_Count, Read_Request_Count, Write_Request_Count: Total request counts.
    • IOPS, IOPS_Read, IOPS_Write: Operations per second.
    • Bytes_Transferred, Bytes_Transferred_Read, Bytes_Transferred_write: Total data transferred.
    • Bandwidth, Bandwidth_Read, Bandwidth_Write: Throughput in bytes per second.
    • Device_Response_Time: Average SSD response time (nanoseconds).
    • Min_Device_Response_Time, Max_Device_Response_Time: Response time bounds.
    • End_to_End_Request_Delay: Average delay from request generation to completion.
    • Min_End_to_End_Request_Delay, Max_End_to_End_Request_Delay: Delay bounds.

    SSDDevice Statistics

    • Lower Abstraction Levels: Average transaction times (SSDDevice.IO_Stream).
    • FTL: Statistics for the Flash Translation Layer.
    • TSU (Transaction Scheduling Unit): Statistics for internal queues (e.g., User_Read_TR_Queue, GC_Erase_TR_Queue) for each channel/package combination.
    • Package Statistics: Time fractions spent in exclusive memory command execution, exclusive data transfer, overlapped modes, and idle mode.
  5. Configure MQSim using XML files

    master

    MQSim uses XML files to define the simulation environment, including the Host, SSD Device, and NAND Flash configurations.

    Tip: If you provide a path to an XML file via the command line that does not exist, MQSim will automatically generate a sample XML file at that path for you to use as a template.

    # Example command line usage (implied)
    # mqsim <path_to_config.xml> ...
  6. Replicate the effect of the QueueFetchSize parameter

    master

    To study how the QueueFetchSize parameter affects performance, you must test two different SSD configurations across three workload scenarios each.

    Configurations:

    • For QueueFetchSize = 16: Use ssdconfig-queue-fetch-size=16.xml.
    • For QueueFetchSize = 1024: Use ssdconfig-queue-fetch-size=1024.xml.

    Workload Scenarios (run for each configuration):

    1. Flow-1 alone: Use workload-queue-fetch-size-flow-1.xml.
    2. Flow-2 alone: Use workload-queue-fetch-size-flow-2.xml.
    3. Concurrent execution: Use workload-queue-fetch-size-flow-1-flow-2.xml.

    Calculating Slowdown: Divide the response time from the concurrent execution by the respective baseline response time:

    • Slowdown(flow-1) = ResponseTime(concurrent_flow-1) / ResponseTime(flow-1_alone)
    • Slowdown(flow-2) = ResponseTime(concurrent_flow-2) / ResponseTime(flow-2_alone)
  7. Run MQSim on Windows

    master

    To use MQSim on Windows, follow these steps:

    1. Open MQSim.sln in MS Visual Studio 2017 or a later version.
    2. Change the Solution Configuration from Debug to Release.
    3. Compile the solution.
    4. Execute the resulting MQSim.exe via the command line or the Visual Studio run button. When running via command line, you must specify the paths to the SSD configuration file and the workload definition file using the -i and -w flags.
    $ MQSim.exe -i <SSD Configuration File> -w <Workload Definition File>
  8. Replicate Contention Effect in the SSD Back END

    master

    To study the contention effect in the SSD back end, use the configuration file ssdconfig-backend-contention.xml. You must run three separate experiments using the following workload files:

    1. Flow-1 alone: Use workload-backend-contention-flow-1.xml to get the baseline response time for flow-1.
    2. Flow-2 alone: Use workload-backend-contention-flow-2.xml to get the baseline response time for flow-2.
    3. Concurrent execution: Use workload-backend-contention-flow-1-flow-2.xml to get the response times for both flows running simultaneously.

    Calculating Slowdown: Divide the response time from the concurrent execution by the respective baseline response time:

    • Slowdown(flow-1) = ResponseTime(concurrent_flow-1) / ResponseTime(flow-1_alone)
    • Slowdown(flow-2) = ResponseTime(concurrent_flow-2) / ResponseTime(flow-2_alone)
  9. Replicate Contention Effect on the write cache

    master

    To study the contention effect on the write cache, use the configuration file ssdconfig-datacache-contention.xml. You must run three separate experiments using the following workload files:

    1. Flow-1 alone: Use workload-datacache-contention-flow-1.xml to get the baseline response time for flow-1.
    2. Flow-2 alone: Use workload-datacache-contention-flow-2.xml to get the baseline response time for flow-2.
    3. Concurrent execution: Use workload-datacache-contention-flow-1-flow-2.xml to get the response times for both flows running simultaneously.

    Calculating Slowdown: Divide the response time from the concurrent execution by the respective baseline response time:

    • Slowdown(flow-1) = ResponseTime(concurrent_flow-1) / ResponseTime(flow-1_alone)
    • Slowdown(flow-2) = ResponseTime(concurrent_flow-2) / ResponseTime(flow-2_alone)
  10. Repeat the FAST 2018 Paper experiments

    master

    The fast18 folder contains input files required to replicate the experiments presented in the FAST 2018 paper. The experiments are categorized into three main studies: Contention Effect on the write cache, Contention Effect in the SSD Back END, and the effect of the QueueFetchSize parameter.

    To perform these experiments, you must run MQSim multiple times using specific combinations of SSD configuration files (.xml) and workload definition files (.xml).

  11. Configure a trace-based workload

    master

    Use the <IO_Flow_Parameter_Set_Trace_Based> XML tag to define a workload from an existing ASCII disk trace.

    Trace File Format: Each line in the trace file must follow this order: 1.Request_Arrival_Time 2.Device_Number 3.Starting_Logical_Sector_Address 4.Request_Size_In_Sectors 5.Type_of_Requests (where 0 is write and 1 is read).

    XML Parameters:

    • Priority_Class: {URGENT, HIGH, MEDIUM, LOW}.
    • Device_Level_Data_Caching_Mode: {WRITE_CACHE, READ_CACHE, WRITE_READ_CACHE, TURNED_OFF}. (Note: If caching is set to SIMPLE, only WRITE_CACHE and TURNED_OFF are valid).
    • Channel_IDs, Chip_IDs, Die_IDs, Plane_IDs: Comma-separated lists used for resource partitioning. Use the full range (e.g., 0 to C-1 for channels) to avoid partitioning.
    • Initial_Occupancy_Percentage: Integer (1-100) representing logical pages filled during preconditioning.
    • File_Path: Path to the input trace file.
    • Percentage_To_Be_Executed: Integer (1-100) of the trace to run.
    • Relay_Count: Positive integer for how many times to repeat the trace.
    • Time_Unit: {PICOSECOND, NANOSECOND, MICROSECOND}.
  12. Manage block metadata with Block_Pool_Slot_Type

    master

    The Block_Pool_Slot_Type class represents the metadata for a single physical block. Key fields include:

    • BlockID: The unique identifier for the flash block.
    • Current_page_write_index: The index of the next page to be written.
    • Current_status: The current Block_Service_Status.
    • Invalid_page_count: Number of invalid pages in the block.
    • Erase_count: Number of times the block has been erased.
    • Invalid_page_bitmap: A bit sequence where 0 is valid and 1 is invalid.
    • Hot_block: Boolean flag used for hot/cold data separation to reduce write amplification.
    • Ongoing_user_read_count / Ongoing_user_program_count: Counters for active user operations on the block.