Skip to content

Improve performance of fork/join by one order of magnitude as measured by ForkJoinBenchmark #8611

@jdegoes

Description

@jdegoes

Fork/join has a relatively high cost when the life of the fiber is short-lived, as shown by ForkJoinBenchmark.

This ticket is to optimize fork/join so that the benchmark shows roughly a 1 order of magnitude performance, without breaking any tests or altering backward compatibility.

The overall steps involved in solving this problem:

  1. Profile using Visual VM, YourKit, or JProfiler. Free licenses are available for the latter due to ZIO's status as an open source project.
  2. Identity leading sources for optimization.
  3. Optimize, measure, and repeat, starting from step (1).

I have already analyzed this and found there is not a single source of overhead that could improve performance by about 10x. Rather, there are a lot of small things that have to be optimized independently, including:

  • The performance of FiberRefs, as well as core operations on FiberRefs involved in fork/join.
  • The performance of WeakConcurrentBag, which is used for tracking root fibers.
  • The overhead of forking, which involves a message to the mailbox that has its own overhead, and tracking the fiber.
  • The overhead of joining, which involves FiberRefs-related machinery and success/error propagation.
  • Scheduling overhead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions