Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: apple/swift-system-metrics
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.3.1
Choose a base ref
...
head repository: apple/swift-system-metrics
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.3.2
Choose a head ref
  • 12 commits
  • 45 files changed
  • 7 contributors

Commits on Jun 6, 2023

  1. update code of conduct (#30)

    motivation: align CoC across the swift project
    
    changes: change CoC to link to the swift.org version
    tomerd authored Jun 6, 2023
    Configuration menu
    Copy the full SHA
    e395a8e View commit details
    Browse the repository at this point in the history

Commits on Jul 26, 2023

  1. Configuration menu
    Copy the full SHA
    34227a9 View commit details
    Browse the repository at this point in the history

Commits on Nov 7, 2024

  1. Migrate to GitHub Actions

    Migrate CI to use GitHub Actions.
    
    Motivation:
    
    To migrate to GitHub actions and centralised infrastructure.
    
    Modifications:
    
    Changes of note:
    * Increase minimum Swift version to 5.9
    * Adopt swift-format using rules from SwiftNIO
    * Remove scripts and docker files which are no longer needed
    
    Result:
    
    Feature parity with old CI.
    rnro authored and ktoso committed Nov 7, 2024
    Configuration menu
    Copy the full SHA
    7888e86 View commit details
    Browse the repository at this point in the history

Commits on Nov 15, 2024

  1. Configuration menu
    Copy the full SHA
    ffe75e7 View commit details
    Browse the repository at this point in the history

Commits on Nov 28, 2024

  1. Configuration menu
    Copy the full SHA
    0da9d86 View commit details
    Browse the repository at this point in the history

Commits on Dec 3, 2024

  1. Enable strict concurrency (#39)

    ### Motivation:
    
    Catch potential data races at build time.
    
    ### Modifications:
    
    - Enabled strict concurrency complete checking.
    - Created a thread-safe wrapper `SystemMetricsProviderContainer` around
    `SystemMetricsProvider` to synchronize access to the current provider.
    - Changed `CPUUsageCalculator` to be a class, again the previous
    implementation used a global variable that held a struct, and called a
    mutating function on it.
    
    ### Result:
    
    Fewer potential data races can sneak in.
    
    ### Test Plan
    
    Ran tests locally, did not see any more warnings or errors.
    czechboy0 authored Dec 3, 2024
    Configuration menu
    Copy the full SHA
    1ca5cde View commit details
    Browse the repository at this point in the history

Commits on Dec 16, 2024

  1. Enable MemberImportVisibility check on all targets (#41)

    Enable MemberImportVisibility check on all targets. Use a standard
    string header and footer to bracket the new block for ease of updating
    in the future with scripts.
    rnro authored Dec 16, 2024
    Configuration menu
    Copy the full SHA
    a771ba9 View commit details
    Browse the repository at this point in the history

Commits on Dec 18, 2024

  1. Update release.yml (#42)

    Update the release.yml file with the latest label changes
    FranzBusch authored Dec 18, 2024
    Configuration menu
    Copy the full SHA
    10c0607 View commit details
    Browse the repository at this point in the history

Commits on Jan 31, 2025

  1. CI use 6.1 nightlies (#43)

    CI use 6.1 nightlies now that Swift development is happening in the 6.1
    branch
    rnro authored Jan 31, 2025
    Configuration menu
    Copy the full SHA
    e151a02 View commit details
    Browse the repository at this point in the history

Commits on Mar 3, 2025

  1. Rename nightly_6_1 params to nightly_next (#44)

    Rename nightly_6_1 params to nightly_next; see
    apple/swift-nio#3122
    rnro authored Mar 3, 2025
    Configuration menu
    Copy the full SHA
    f48faf0 View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2025

  1. Only apply standard swift settings on valid targets (#45)

    Only apply standard swift settings on valid targets. The current check
    ignores plugins but that is not comprehensive enough.
    rnro authored Mar 7, 2025
    Configuration menu
    Copy the full SHA
    d269598 View commit details
    Browse the repository at this point in the history

Commits on Mar 12, 2025

  1. Fix Linux memory and CPU metrics derived from procfs (#46)

    ### Motivation
    
    This package provides some system metrics on Linux derived from procfs.
    These include CPU and memory metrics. The values returned from
    `/proc/self/stat` need to be combined with system values. For example,
    some values are returned in clock ticks or memory pages, so need to be
    divided appropriately according to the system configuration for clock
    ticks per second or page size, respectively.
    
    Looking at the code, some attempt was made to do this: `_SC_CLK_TCK` and
    `_SC_PAGESIZE` were used as divisors.
    
    However, these values are the values of the _option_ parameter used in
    the call to `sysconf(3)`, not the results themselves.
    
    To illustrate this, here's a Swift program that prints the option name,
    option value, and the result of `sysconf(optionValue)`:
    
    ```swift
    #if !os(Linux)
    import Foundation
    print("error: This tool is only supported on Linux")
    exit(1)
    #else
    import Glibc
    
    for (optionName, optionValue) in [
        ("_SC_ARG_MAX", _SC_ARG_MAX),
        ("_SC_CHILD_MAX", _SC_CHILD_MAX),
        ("_SC_CLK_TCK", _SC_CLK_TCK),
        ("_SC_NGROUPS_MAX", _SC_NGROUPS_MAX),
        ("_SC_OPEN_MAX", _SC_OPEN_MAX),
        ("_SC_STREAM_MAX", _SC_STREAM_MAX),
        ("_SC_TZNAME_MAX", _SC_TZNAME_MAX),
        ("_SC_JOB_CONTROL", _SC_JOB_CONTROL),
        ("_SC_SAVED_IDS", _SC_SAVED_IDS),
        ("_SC_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS),
        ("_SC_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING),
        ("_SC_TIMERS", _SC_TIMERS),
        ("_SC_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO),
        ("_SC_PRIORITIZED_IO", _SC_PRIORITIZED_IO),
        ("_SC_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO),
        ("_SC_FSYNC", _SC_FSYNC),
        ("_SC_MAPPED_FILES", _SC_MAPPED_FILES),
        ("_SC_MEMLOCK", _SC_MEMLOCK),
        ("_SC_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE),
        ("_SC_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION),
        ("_SC_MESSAGE_PASSING", _SC_MESSAGE_PASSING),
        ("_SC_SEMAPHORES", _SC_SEMAPHORES),
        ("_SC_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS),
        ("_SC_AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX),
        ("_SC_AIO_MAX", _SC_AIO_MAX),
        ("_SC_AIO_PRIO_DELTA_MAX", _SC_AIO_PRIO_DELTA_MAX),
        ("_SC_DELAYTIMER_MAX", _SC_DELAYTIMER_MAX),
        ("_SC_MQ_OPEN_MAX", _SC_MQ_OPEN_MAX),
        ("_SC_MQ_PRIO_MAX", _SC_MQ_PRIO_MAX),
        ("_SC_VERSION", _SC_VERSION),
        ("_SC_PAGESIZE", _SC_PAGESIZE),
        ("_SC_RTSIG_MAX", _SC_RTSIG_MAX),
    ] {
        let actualValue = sysconf(Int32(optionValue))
        print("Option name: \(optionName), Option value: \(optionValue), Actual value: \(actualValue)")
    }
    #endif
    ```
    
    
    ```console
    % swift sysconf-test/sysconf-test.swift 
    Option name: _SC_ARG_MAX, Option value: 0, Actual value: 2097152
    Option name: _SC_CHILD_MAX, Option value: 1, Actual value: 63907
    Option name: _SC_CLK_TCK, Option value: 2, Actual value: 100
    Option name: _SC_NGROUPS_MAX, Option value: 3, Actual value: 65536
    Option name: _SC_OPEN_MAX, Option value: 4, Actual value: 65536
    Option name: _SC_STREAM_MAX, Option value: 5, Actual value: 16
    Option name: _SC_TZNAME_MAX, Option value: 6, Actual value: -1
    Option name: _SC_JOB_CONTROL, Option value: 7, Actual value: 1
    Option name: _SC_SAVED_IDS, Option value: 8, Actual value: 1
    Option name: _SC_REALTIME_SIGNALS, Option value: 9, Actual value: 200809
    Option name: _SC_PRIORITY_SCHEDULING, Option value: 10, Actual value: 200809
    Option name: _SC_TIMERS, Option value: 11, Actual value: 200809
    Option name: _SC_ASYNCHRONOUS_IO, Option value: 12, Actual value: 200809
    Option name: _SC_PRIORITIZED_IO, Option value: 13, Actual value: 200809
    Option name: _SC_SYNCHRONIZED_IO, Option value: 14, Actual value: 200809
    Option name: _SC_FSYNC, Option value: 15, Actual value: 200809
    Option name: _SC_MAPPED_FILES, Option value: 16, Actual value: 200809
    Option name: _SC_MEMLOCK, Option value: 17, Actual value: 200809
    Option name: _SC_MEMLOCK_RANGE, Option value: 18, Actual value: 200809
    Option name: _SC_MEMORY_PROTECTION, Option value: 19, Actual value: 200809
    Option name: _SC_MESSAGE_PASSING, Option value: 20, Actual value: 200809
    Option name: _SC_SEMAPHORES, Option value: 21, Actual value: 200809
    Option name: _SC_SHARED_MEMORY_OBJECTS, Option value: 22, Actual value: 200809
    Option name: _SC_AIO_LISTIO_MAX, Option value: 23, Actual value: -1
    Option name: _SC_AIO_MAX, Option value: 24, Actual value: -1
    Option name: _SC_AIO_PRIO_DELTA_MAX, Option value: 25, Actual value: 20
    Option name: _SC_DELAYTIMER_MAX, Option value: 26, Actual value: 2147483647
    Option name: _SC_MQ_OPEN_MAX, Option value: 27, Actual value: -1
    Option name: _SC_MQ_PRIO_MAX, Option value: 28, Actual value: 32768
    Option name: _SC_VERSION, Option value: 29, Actual value: 200809
    Option name: _SC_PAGESIZE, Option value: 30, Actual value: 4096
    Option name: _SC_RTSIG_MAX, Option value: 31, Actual value: 32
    ```
    
    The results for our metrics were off because we were always using 30 for
    page size and 2 for clock ticks.
    
    ### Modifications
    
    - Remove the LinuxMain.swift: test discovery is supported on Linux for
    all currently supported Swift versions.
    - Update the internal documentation regarding the use of
    `proc_pid_stat(5)`.
    - Use correct value for CPU metrics, obtained from
    `sysconf(_SC_CLK_TCK)`, not just `_SC_CLK_TCK`.
    - Use correct value for memory metrics, obtained from
    `sysconf(_SC_PAGESIZE)`, not just `_SC_PAGESIZE`.
    - Write tests for both CPU seconds and RSS memory.
    
    ### Result
    
    Fixes #40.
    simonjbeaumont authored Mar 12, 2025
    Configuration menu
    Copy the full SHA
    4d63509 View commit details
    Browse the repository at this point in the history
Loading