ceph-csi/vendor/github.com/opencontainers/selinux/pkg/pwalk/README.md
dependabot[bot] b2099eb3b1 rebase: bump k8s.io/kubernetes from 1.22.3 to 1.22.4
Bumps [k8s.io/kubernetes](https://github.com/kubernetes/kubernetes) from 1.22.3 to 1.22.4.
- [Release notes](https://github.com/kubernetes/kubernetes/releases)
- [Commits](https://github.com/kubernetes/kubernetes/compare/v1.22.3...v1.22.4)

---
updated-dependencies:
- dependency-name: k8s.io/kubernetes
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-22 13:23:58 +00:00

1.4 KiB

pwalk: parallel implementation of filepath.Walk

This is a wrapper for filepath.Walk which may speed it up by calling multiple callback functions (WalkFunc) in parallel, utilizing goroutines.

By default, it utilizes 2*runtime.NumCPU() goroutines for callbacks. This can be changed by using WalkN function which has the additional parameter, specifying the number of goroutines (concurrency).

Caveats

Please note the following limitations of this code:

  • Unlike filepath.Walk, the order of calls is non-deterministic;

  • Only primitive error handling is supported:

    • filepath.SkipDir is not supported;

    • no errors are ever passed to WalkFunc;

    • once any error is returned from any WalkFunc instance, no more new calls to WalkFunc are made, and the error is returned to the caller of Walk;

    • if more than one walkFunc instance will return an error, only one of such errors will be propagated and returned by Walk, others will be silently discarded.

Documentation

For the official documentation, see https://pkg.go.dev/github.com/opencontainers/selinux/pkg/pwalk?tab=doc

Benchmarks

For a WalkFunc that consists solely of the return statement, this implementation is about 10% slower than the standard library's filepath.Walk.

Otherwise (if a WalkFunc is doing something) this is usually faster, except when the WalkN(..., 1) is used.