Skip to content

Commit 6a4f4f9

Browse files
authored
perf: decrease the overhead of constraint profiling (#2544)
1 parent 2e72362 commit 6a4f4f9

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

core/src/main/java/ai/timefold/solver/core/impl/bavet/common/ConstraintNodeProfileId.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
* @param locationSet the set of locations where this constraint node is defined
1414
*/
1515
@NullMarked
16-
public record ConstraintNodeProfileId(long key, StreamKind streamKind, Qualifier qualifier,
16+
public record ConstraintNodeProfileId(int key, StreamKind streamKind, Qualifier qualifier,
1717
SortedSet<ConstraintNodeLocation> locationSet)
1818
implements
1919
Comparable<ConstraintNodeProfileId> {
2020

21-
public ConstraintNodeProfileId(long key, StreamKind streamKind, SortedSet<ConstraintNodeLocation> locationSet) {
21+
public ConstraintNodeProfileId(int key, StreamKind streamKind, SortedSet<ConstraintNodeLocation> locationSet) {
2222
this(key, streamKind, Qualifier.NONE, locationSet);
2323
}
2424

@@ -31,12 +31,12 @@ public boolean equals(Object object) {
3131

3232
@Override
3333
public int hashCode() {
34-
return Long.hashCode(key);
34+
return Integer.hashCode(key);
3535
}
3636

3737
@Override
3838
public int compareTo(ConstraintNodeProfileId other) {
39-
return Long.compare(key, other.key);
39+
return Integer.compare(key, other.key);
4040
}
4141

4242
@Override
@@ -64,7 +64,7 @@ public String toString() {
6464
public String toVerboseString() {
6565
var toString = toString();
6666
if (locationSet.size() == 1) {
67-
var location = locationSet.iterator().next();
67+
var location = locationSet.getFirst();
6868
return "%s defined at location %s".formatted(toString, location);
6969
}
7070
return "%s shared at locations %s".formatted(toString, locationSet);

core/src/main/java/ai/timefold/solver/core/impl/bavet/common/tuple/TupleLifecycle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static <Tuple_ extends Tuple> TupleLifecycle<Tuple_> recording() {
6666
}
6767

6868
static <Stream_ extends BavetStream, Tuple_ extends Tuple> TupleLifecycle<Tuple_> profiling(
69-
InnerConstraintProfiler constraintProfiler, long lifecycleId, Stream_ stream,
69+
InnerConstraintProfiler constraintProfiler, int lifecycleId, Stream_ stream,
7070
TupleLifecycle<Tuple_> delegate) {
7171
if (delegate instanceof AggregatedTupleLifecycle) {
7272
// Do not profile aggregated tuple lifecycles; that will double

core/src/main/java/ai/timefold/solver/core/impl/score/stream/bavet/common/ConstraintNodeBuildHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public final class ConstraintNodeBuildHelper<Solution_, Score_ extends Score<Sco
4545
private final Map<BavetAbstractConstraintStream<Solution_>, List<Set<ConstraintNodeProfileId>>> streamToProfileIdSets;
4646
private final Map<BavetScoringConstraintStream<Solution_>, Scorer<?>> streamToScorers = new HashMap<>();
4747

48-
private long nextLifecycleProfilingId = 0;
48+
private int nextLifecycleProfilingId = 0;
4949

5050
public ConstraintNodeBuildHelper(ConsistencyTracker<Solution_> consistencyTracker,
5151
Set<BavetAbstractConstraintStream<Solution_>> activeStreamSet, AbstractScoreInliner<Score_> scoreInliner,

0 commit comments

Comments
 (0)