# gonzalorodrigo/scsfsimulator architecture

> Architecture diagram of the GitHub repository gonzalorodrigo/scsfsimulator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gonzalorodrigo/scsfsimulator
- Repository: https://github.com/gonzalorodrigo/scsfsimulator

## Overview

##### Major system components
- Controller (slurmctld): This is the heart of the Slurm system that handles job scheduling, resource allocation, node management, and overall state control.
- Node Daemons (slurmd): Running on each compute node, these components execute assigned jobs and report node state.
- Database Daemon (slurmdbd): A separate process that manages job accounting and other historical data.
- Job Step Daemon (slurmstepd): Handles the launching and tracking of sub-tasks or job steps once jobs are dispatched.
- CLI Tools and APIs: The various command-line tools (e.g., sbatch, sinfo, srun, scancel, etc.) and the API/library (e.g., the “src/api” and “slurm” include directories) provide interfaces for users or external integrations to interact with the system.
- Plugins Infrastructure: A major design element is the extensive plugins structure (organized in src/plugins). These include modules for accounting storage, authentication, scheduling (which may include specialized implementations for specific hardware such as Cray or BlueGene), MPI support, GPU/accelerator support, and others. This extensibility is key to Slurm’s design.
- Simulation and Workflow Layers: In this fork there is an added simulation component (ScSf) and the WoAS technique that work on top of the normal Slurm scheduling infrastructure. These simulate live resource behavior and user job patterns.
- Supporting and Auxiliary Components: There are directories for configuration (etc/), documentation (doc/), autotools and build configuration (auxdir/), and a testsuite (testsuite/) which aids in validating the system.

##### Relationships and interactions
- Users submit jobs using various CLI tools which interact with the central controller (slurmctld) via the Slurm API.
- The controller communicates with one or more compute nodes by sending instructions to the slurmd daemons.
- Job steps are managed by slurmstepd, often coordinated by slurmctld.
- The slurmctld also interacts with the database daemon (slurmdbd) for accounting and historical records.
- The plugin framework is used by many of these components (especially in scheduling, authentication, and accounting) to dynamically extend functionality without hardcoding vendor-specific or domain-specific logic.
- In the simulated version, the ScSf simulator overlays a simulated resource environment (with its own resource “state” and “time” adjustments) and uses WoAS to incorporate workflow aware scheduling decisions.
- Communication between these components (API calls, messaging, configuration reads via files found in etc/ and src/common/ etc.) should be clearly indicated.

##### Architectural Patterns and Design Principles
- Modularity is central – the code is broken into modules for each major functionality (controller, node daemon, plugins, CLI tools, etc.).
- Plugin-based extensibility is a clear design pattern, with clearly defined interfaces and separate directories/files for each plugin type.
- A client-server style interaction is visible between users (via CLI or scripts) and a central scheduling controller.
- The system is distributed – the separation between a central controller and multiple node daemons reflects a fault-tolerant and scalable distributed architecture.

##### Reminder
- Both the runtime system (how jobs flow through the system) and the extensibility architecture (plugin-based modules) that set Slurm apart.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation/Interface Layer
    subgraph "Presentation Layer"
        subgraph "CLI Tools"
            CLI_sbatch["sbatch"] 
            CLI_sinfo["sinfo"]
            CLI_srun["srun"]
            CLI_scancel["scancel"]
        end
        API["API Libraries"]
    end

    %% Application/Resource Management Layer
    subgraph "Resource Management Layer"
        Slurm_Controller["Slurm Controller (slurmctld)"]
        Job_Step_Daemon["Job Step Daemon (slurmstepd)"]
        Plugins_Framework["Plugins Framework"]
    end

    %% Execution/Compute Layer
    subgraph "Compute Layer"
        Node_Daemon["Node Daemons (slurmd)"]
    end

    %% Data & Accounting Layer
    subgraph "Data & Accounting Layer"
        Database_Daemon["Database Daemon (slurmdbd)"]
    end

    %% Simulation Layer
    subgraph "Simulation Layer"
        ScSf_Simulator["ScSf Simulator"]
        WoAS_Scheduler["WoAS Scheduler"]
    end

    %% Supporting Components
    subgraph "Supporting Components"
        Config["Configuration"]
        BuildSystem["Build System"]
        Documentation["Documentation"]
    end

    %% Relationships: Presentation -> Resource Management
    CLI_sbatch -->|"submit"| Slurm_Controller
    CLI_sinfo   -->|"query"| Slurm_Controller
    CLI_srun    -->|"run_job"| Slurm_Controller
    CLI_scancel -->|"cancel"| Slurm_Controller
    API         -->|"API_call"| Slurm_Controller

    %% Relationships: Resource Management internal
    Slurm_Controller -->|"dispatch_step"| Job_Step_Daemon
    Slurm_Controller -->|"invoke_plugins"| Plugins_Framework
    Slurm_Controller -->|"send_instruction"| Node_Daemon
    Slurm_Controller -->|"account_update"| Database_Daemon

    %% Relationships: Simulation Layer interactions
    ScSf_Simulator -->|"simulate"| Slurm_Controller
    WoAS_Scheduler -->|"workflow_update"| Slurm_Controller
    Slurm_Controller -->|"update_state"| ScSf_Simulator
    Slurm_Controller -->|"adjust_schedule"| WoAS_Scheduler

    %% Supporting Components influence configuration and build
    Config -->|"config_read"| Slurm_Controller
    BuildSystem -->|"build_script"| Slurm_Controller

    %% Styling of Layers
    class CLI_sbatch,CLI_sinfo,CLI_srun,CLI_scancel,API presentation;
    class Slurm_Controller,Job_Step_Daemon,Plugins_Framework resource;
    class Node_Daemon compute;
    class Database_Daemon accounting;
    class ScSf_Simulator,WoAS_Scheduler simulation;
    class Config,BuildSystem,Documentation support;

    %% Class Definitions
    classDef presentation fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef resource fill:#98FB98,stroke:#2E8B57,stroke-width:2px;
    classDef compute fill:#87CEFA,stroke:#4682B4,stroke-width:2px;
    classDef accounting fill:#FFB6C1,stroke:#CD5C5C,stroke-width:2px;
    classDef simulation fill:#FFA07A,stroke:#FF4500,stroke-width:2px;
    classDef support fill:#D3D3D3,stroke:#696969,stroke-width:2px;

    %% Click Events for Component Mapping
    click Slurm_Controller "https://github.com/gonzalorodrigo/scsfsimulator/blob/woasslurmsim/src/slurmctld/slurmctld.c"
    click Node_Daemon "https://github.com/gonzalorodrigo/scsfsimulator/blob/woasslurmsim/src/slurmd/slurmd/slurmd.c"
    click Database_Daemon "https://github.com/gonzalorodrigo/scsfsimulator/blob/woasslurmsim/src/slurmdbd/slurmdbd.c"
    click Job_Step_Daemon "https://github.com/gonzalorodrigo/scsfsimulator/blob/woasslurmsim/src/slurmd/slurmstepd/slurmstepd.c"
    click CLI_sbatch "https://github.com/gonzalorodrigo/scsfsimulator/tree/woasslurmsim/src/sbatch"
    click CLI_sinfo "https://github.com/gonzalorodrigo/scsfsimulator/tree/woasslurmsim/src/sinfo"
    click CLI_srun "https://github.com/gonzalorodrigo/scsfsimulator/tree/woasslurmsim/src/srun"
    click CLI_scancel "https://github.com/gonzalorodrigo/scsfsimulator/tree/woasslurmsim/src/scancel"
    click API "https://github.com/gonzalorodrigo/scsfsimulator/tree/woasslurmsim/src/api"
    click Plugins_Framework "https://github.com/gonzalorodrigo/scsfsimulator/tree/woasslurmsim/src/plugins"
    click Config "https://github.com/gonzalorodrigo/scsfsimulator/blob/woasslurmsim/etc/slurm.conf.example"
    click BuildSystem "https://github.com/gonzalorodrigo/scsfsimulator/tree/woasslurmsim/auxdir"
    click Documentation "https://github.com/gonzalorodrigo/scsfsimulator/tree/woasslurmsim/doc"
```
