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: go-openapi/validate
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.22.6
Choose a base ref
...
head repository: go-openapi/validate
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.23.0
Choose a head ref
  • 6 commits
  • 34 files changed
  • 2 contributors

Commits on Jan 27, 2024

  1. refact(validators) (#169)

    * refact(validators)
    
    Readability improvements:
    * Introduced private constructors for all validators
    * All private constructors can use a *SchemaValidatorOptions (generalize
      options passing pattern)
    * All exported methods use private constructors (hide the implementation
      of options)
    * Readability: reduced the level of indentation with early exit
      conditions than nested conditions
    * Object validator: refactored Validate in smaller functions
    * Removed dead code/commented out code
    
    Minor efficiency improvements
    
    * In Applies method: reflect replaced by type switch whenever possible
    * Removed (mostly unusable) debugLog
    * In object validator:
      * pattern properties now use the regexp cache readily available
      * split path may be performed only once
    * In schema props: keep arrays of pointers []*SchemaValidator and avoid
      copying a new schema
    * In default & example validators:
      * map[string]bool -> map[string]struct{}
      * clear, don't reallocate the visited map
    * []validator slice -> [n]validator array
    
    * introduced a benchmark follow-up document, based on the existing Kubernetes API
      fixture
    
    Signed-off-by: Frederic BIDON <[email protected]>
    
    * fixed typo
    
    Signed-off-by: Frederic BIDON <[email protected]>
    
    ---------
    
    Signed-off-by: Frederic BIDON <[email protected]>
    fredbi authored Jan 27, 2024
    Configuration menu
    Copy the full SHA
    7c3e606 View commit details
    Browse the repository at this point in the history

Commits on Feb 1, 2024

  1. perf(validators): reduced GC pressure

    This PR is a follow-up on #169, which cames with innocuous changes, but already
    reduced the total number of allocations when validating a swagger spec.
    
    We reduce further the pressure on go's GC by pooling temporarily
    allocated objects: validators and results.
    
    When recursively allocating validators, calls to "Validate()" redeem to the pool the allocated
    validator. This means that a validator is usable only once.
    
    A similar approach is taken for `Result`s: upon merge, the merged result
    is redeemed to the pool.
    
    Eventually, temporarily allocated `spec.Schema`s are also pooled.
    
    In order not to break existing interfaces, this is enabled by default
    only when validating a spec (`Spec()`) or when using
    `AgainstSchema()`.
    
    Another option at the spec level allows for skipping the gathering of schemas
    into the result ("schemata"): these schemas must be cloned to remain
    valid after their parent is redeemed to the pool.
    
    Comment on the benchmark:
    
    CPU profiling shows that about 30% of the CPU time is spent managing
    garbage.
    
    Memory profiling shows that our benchmark (validating the k8s API spec) goes
    down from 25M allocated objects down to ~ 17M (#169 went down from 60M to 25M).
    
    The `Validate` method generates only ~ 5M of those, out of which
    ~ 4M are caused by the schema unmarshaling & expansion and 1M by string
    allocations for the validator "path".
    Unfortunately, classic string interning methods don't work well with this dynamic "path",
    so I leave it there.
    
    Integration tests (go-swagger/go-swagger#3064)
    show a significant improvement when running go-swagger validate in codegen.
    
    * contributes: go-swagger/go-swagger#2649
    
    Further improvements would most likely come from optimizing the
    validation of defaults and examples (which amount for 2M allocs).
    
    Signed-off-by: Frederic BIDON <[email protected]>
    fredbi committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    8c60715 View commit details
    Browse the repository at this point in the history
  2. ci(dependencies): automate dependencies updates

    Signed-off-by: Frédéric BIDON <[email protected]>
    fredbi committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    906adc1 View commit details
    Browse the repository at this point in the history
  3. Bump the development-dependencies group with 3 updates

    Bumps the development-dependencies group with 3 updates: [actions/checkout](https://github.com/actions/checkout), [actions/setup-go](https://github.com/actions/setup-go) and [codecov/codecov-action](https://github.com/codecov/codecov-action).
    
    
    Updates `actions/checkout` from 3 to 4
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@v3...v4)
    
    Updates `actions/setup-go` from 4 to 5
    - [Release notes](https://github.com/actions/setup-go/releases)
    - [Commits](actions/setup-go@v4...v5)
    
    Updates `codecov/codecov-action` from 3 to 4
    - [Release notes](https://github.com/codecov/codecov-action/releases)
    - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
    - [Commits](codecov/codecov-action@v3...v4)
    
    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-major
      dependency-group: development-dependencies
    - dependency-name: actions/setup-go
      dependency-type: direct:production
      update-type: version-update:semver-major
      dependency-group: development-dependencies
    - dependency-name: codecov/codecov-action
      dependency-type: direct:production
      update-type: version-update:semver-major
      dependency-group: development-dependencies
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    dependabot[bot] authored and github-actions[bot] committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    8c2a862 View commit details
    Browse the repository at this point in the history
  4. Bump the go-openapi-dependencies group with 2 updates

    Bumps the go-openapi-dependencies group with 2 updates: [github.com/go-openapi/analysis](https://github.com/go-openapi/analysis) and [github.com/go-openapi/swag](https://github.com/go-openapi/swag).
    
    
    Updates `github.com/go-openapi/analysis` from 0.22.0 to 0.22.2
    - [Commits](go-openapi/analysis@v0.22.0...v0.22.2)
    
    Updates `github.com/go-openapi/swag` from 0.22.8 to 0.22.9
    - [Commits](go-openapi/swag@v0.22.8...v0.22.9)
    
    ---
    updated-dependencies:
    - dependency-name: github.com/go-openapi/analysis
      dependency-type: direct:production
      update-type: version-update:semver-patch
      dependency-group: go-openapi-dependencies
    - dependency-name: github.com/go-openapi/swag
      dependency-type: direct:production
      update-type: version-update:semver-patch
      dependency-group: go-openapi-dependencies
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    dependabot[bot] authored and github-actions[bot] committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    7135206 View commit details
    Browse the repository at this point in the history
  5. chore(ci): prevents duplicate workflow runs

    Signed-off-by: Frédéric BIDON <[email protected]>
    fredbi committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    fb01d6d View commit details
    Browse the repository at this point in the history
Loading