Skip to content

Conversation

@Christopher-Chianelli
Copy link
Contributor

Profiling constraints is notorishing difficult, since each component of a constraint are converted to nodes, some of which are shared. As such, a JVM method profile is basically unreadable and does not represent how much time is actually spent for each constraint.

To aid in profiling, an optional constraintStreamProfilingMode configuration was added. If set to a value other than NONE, it wraps each tuple lifecycle node inside a ProfilingTupleLifecycle, which will measure how long each lifecycle executes. The ProfilingTupleLifecycle find out what constraint is responsible for creating that lifecycle by getting snapshot of the stack traces from its constraint stream's creator (when a constraint stream is shared, their stack traces are merged into the same set).

At the end of solving, a profiling summary is then produced in the INFO log. The details differ depending on the profiling mode:

  • In the BY_METHOD profiling mode, (className, methodName) is used as the key

  • In the BY_LINE profiling mode, (className, methodName, lineNumber) is used as the key.

The methods/lines are printed in descending order of time percentage spent. The sum of time percentage spent may be over 100%, since methods/lines can share time spent with other methods/lines.

timefold.solver.constraint-stream-profiling-mode was added as a property to Quarkus and Spring Boot to configure profiling (defaults to NONE).

Profiling constraints is notorishing difficult, since each
component of a constraint are converted to nodes, some of which
are shared. As such, a JVM method profile is basically unreadable and
does not represent how much time is actually spent for each constraint.

To aid in profiling, an optional constraintStreamProfilingMode
configuration was added. If set to a value other than NONE,
it wraps each tuple lifecycle node inside a ProfilingTupleLifecycle,
which will measure how long each lifecycle executes.
The ProfilingTupleLifecycle find out what constraint is responsible
for creating that lifecycle by getting snapshot of the stack traces
from its constraint stream's creator (when a constraint stream is
shared, their stack traces are merged into the same set).

At the end of solving, a profiling summary is then produced in
the INFO log. The details differ depending on the profiling mode:

- In the BY_METHOD profiling mode, (className, methodName) is used
  as the key

- In the BY_LINE profiling mode, (className, methodName, lineNumber)
  is used as the key.

The methods/lines are printed in descending order of time percentage
spent. The sum of time percentage spent may be over 100%, since
methods/lines can share time spent with other methods/lines.

timefold.solver.constraint-stream-profiling-mode was added as
a property to Quarkus and Spring Boot to configure profiling
(defaults to NONE).
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant