Skip to content
Snippets Groups Projects
Commit dd2de60a authored by Hiro's avatar Hiro :surfer:
Browse files

Optimize function that is causing OOM errors

Update .gitignore
parent 341c03ba
No related branches found
No related tags found
1 merge request!9Optimize function that is causing OOM errors
Pipeline #211372 failed
......@@ -14,6 +14,7 @@ cobertura.ser
*~
build.properties
/index/
/indexed/
collector-02.torproject.org
/.idea/
.iml
Subproject commit 467f5e132c71b9dbbcdc2513927a742f6b1e43a1
Subproject commit e11525332d5d2f0b50f17815ba06de7afaec5db8
......@@ -249,12 +249,6 @@ public class BridgePoolAssignmentsProcessor extends CollecTorMain {
LocalDateTime bridgePoolAssignmentTime = LocalDateTime.parse(
line.substring("bridge-pool-assignment ".length()),
this.assignmentFormat);
if (readBridgePoolAssignments.containsKey(
bridgePoolAssignmentTime)) {
logger.warn("Input file {} contains duplicate line: {}. "
+ "Discarding previously read line and subsequent assignment "
+ "lines.", assignmentFile, line);
}
currentAssignments = new TreeMap<>();
readBridgePoolAssignments.put(bridgePoolAssignmentTime,
currentAssignments);
......@@ -275,10 +269,6 @@ public class BridgePoolAssignmentsProcessor extends CollecTorMain {
logger.warn("Unrecognized line '{}'. Aborting.", line);
break;
}
if (currentAssignments.containsKey(parts[0])) {
logger.warn("Input file {} contains duplicate line: {}. "
+ "Discarding previously read line.", assignmentFile, line);
}
currentAssignments.put(parts[0], parts[1]);
}
}
......
......@@ -290,29 +290,32 @@ public class ReferenceChecker {
private void checkReferences() {
Set<String> knownDescriptors = new HashSet<>();
double totalMissingDescriptorsWeight = 0.0;
// First pass: collect known descriptors
for (Reference reference : this.references) {
knownDescriptors.add(reference.referencing);
}
double totalMissingDescriptorsWeight = 0.0;
Set<String> missingDescriptors = new TreeSet<>();
StringBuilder sb = new StringBuilder("Missing referenced "
+ "descriptors:");
// StringBuilder to accumulate the log message
StringBuilder sb = new StringBuilder("Missing referenced descriptors:");
// Second pass: check for missing descriptors
for (Reference reference : this.references) {
if (reference.referenced.length() > 0
&& !knownDescriptors.contains(reference.referenced)) {
if (!missingDescriptors.contains(reference.referenced)) {
totalMissingDescriptorsWeight += reference.weight;
}
missingDescriptors.add(reference.referenced);
if (reference.referenced.length() > 0 && !knownDescriptors.contains(reference.referenced)) {
totalMissingDescriptorsWeight += reference.weight;
sb.append(String.format("%n%s -> %s (%.4f -> %.4f)",
reference.referencing, reference.referenced, reference.weight,
totalMissingDescriptorsWeight));
reference.referencing, reference.referenced, reference.weight,
totalMissingDescriptorsWeight));
}
}
// Log the accumulated string
logger.info(sb.toString());
// Warn if the total missing descriptors weight exceeds the threshold
if (totalMissingDescriptorsWeight > 0.999) {
logger.warn("Missing too many referenced descriptors ({}).",
totalMissingDescriptorsWeight);
logger.warn("Missing too many referenced descriptors ({}).", totalMissingDescriptorsWeight);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment