-
Notifications
You must be signed in to change notification settings - Fork 165
feat: add constraint stream profiling #1901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Christopher-Chianelli
wants to merge
1
commit into
TimefoldAI:main
Choose a base branch
from
Christopher-Chianelli:feat/constraint-profile
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
.../src/main/java/ai/timefold/solver/core/config/score/director/ConstraintProfilingMode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package ai.timefold.solver.core.config.score.director; | ||
|
|
||
| /** | ||
| * Controls how constraints are profiled. | ||
| * Enabling profiling have a minor performance impact. | ||
| */ | ||
| public enum ConstraintProfilingMode { | ||
| /** | ||
| * Disables profiling. | ||
| */ | ||
| NONE, | ||
|
|
||
| /** | ||
| * Profile by the method an operation was defined in. | ||
| */ | ||
| BY_METHOD, | ||
|
|
||
| /** | ||
| * Profile by the line an operation was defined on. | ||
| */ | ||
| BY_LINE | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/BavetStream.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| package ai.timefold.solver.core.impl.bavet.common; | ||
|
|
||
| import java.util.Set; | ||
|
|
||
| public interface BavetStream { | ||
|
|
||
| <Stream_> Stream_ getParent(); | ||
|
|
||
| default Set<ConstraintNodeLocation> getLocationSet() { | ||
| return Set.of(ConstraintNodeLocation.unknown()); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this is needless complexity. Do not profile by method or line - profile by constraint. That is what people actually want to see; the list of constraints and how much time they take to run.
Also, the names of constraints typically do not change, while method names and lines do as code is refactored over time. People who use bytecode obfuscation would get absolutely no information out of this, and I wonder what happens with automatic node sharing etc., where we mutate code heavily without giving access to that new source code.
All in all, this information is too unreliable to present it to the user. The only reliable source is the constraint name; the rest, if it needs to exist, should remain hidden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look at lambdas, it looks at the
.filter`.join`/etc. code, which is not modified by node sharing (i.e. it looks at the filter call, not what within the filter call).Arguably, having method name + line number is useful; it tells you what part of a constraint is taking the most runtime (i.e. is it a filter, join, or groupBy).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line number still changes with automatic node sharing - new fields are added at the top of the class, moving others down. (Although how does it even work with bytecode generation, when there is no source code? It seems that this metadata has to be fundamentally unreliable.)
Even with the changes that the Java compiler does when it produces bytecode, line numbers are still unreliable. Code can be added here and there. The idea of trying to do this per building block is IMO noble, but falls apart too easily. I don't think it's necessary for this concept to succeed - when the users see the expensive constraint, that'll already be plenty information to proceed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line numbers are recorded in bytecode; so they line numbers in stack traces do not change if that bytecode is modified (provided you don't delete/change the metadata instruction that records the line number).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for how line numbers look in bytecode:
In this example, line 10 correspond to
NOP, INVOKE_INTERFACE, FADD.