Add Processor Cache Information#2198
Conversation
|
|
| private static Triplet<List<LogicalProcessor>, Map<Integer, Integer>, Map<Integer, String>> readTopologyFromUdev() { | ||
| private static Quartet<List<LogicalProcessor>, List<ProcessorCache>, Map<Integer, Integer>, Map<Integer, String>> readTopologyFromUdev() { | ||
| List<LogicalProcessor> logProcs = new ArrayList<>(); | ||
| List<Pair<Triplet<List<Integer>, Integer, Type>, Triplet<Integer, Integer, Long>>> caches = new ArrayList<>(); |
There was a problem hiding this comment.
BadImport: Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer. Here we recommend using qualified class: ProcessorCache.
| List<Pair<Triplet<List<Integer>, Integer, Type>, Triplet<Integer, Integer, Long>>> caches = new ArrayList<>(); | |
| List<Pair<Triplet<List<Integer>, Integer, ProcessorCache.Type>, Triplet<Integer, Integer, Long>>> caches = new ArrayList<>(); |
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| List<ProcessorCache> caches = new ArrayList<>(); | ||
| int cacheSizeL2 = ParseUtil.parseIntOrDefault(ExecutingCommand.getAnswerAt("lsattr -l L2cache0 -E -O", 2), 0); | ||
| for (int i = 0; i < physProcs; i++) { | ||
| caches.add(new ProcessorCache(i, 2, 0, 64, cacheSizeL2, Type.UNIFIED)); |
There was a problem hiding this comment.
BadImport: Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer. Here we recommend using qualified class: ProcessorCache.
| caches.add(new ProcessorCache(i, 2, 0, 64, cacheSizeL2, Type.UNIFIED)); | |
| caches.add(new ProcessorCache(i, 2, 0, 64, cacheSizeL2, ProcessorCache.Type.UNIFIED)); |
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| } | ||
| int lpPerPp = lcpus / physProcs; | ||
| // Get L2 caches, one per physical processor | ||
| List<ProcessorCache> caches = new ArrayList<>(); |
There was a problem hiding this comment.
ModifiedButNotUsed: A collection or proto builder was created, but its values were never accessed.
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
|
This pull request introduces 1 alert when merging d0b04e8 into 9e1bf98 - view on LGTM.com new alerts:
|
| int cacheSizeL2 = ParseUtil.parseIntOrDefault(ExecutingCommand.getAnswerAt("lsattr -l L2cache0 -E -O", 2), 0); | ||
| if (cacheSizeL2 > 0) { | ||
| for (int i = 0; i < physProcs; i++) { | ||
| caches.add(new ProcessorCache(i, 2, 0, 64, cacheSizeL2, Type.UNIFIED)); |
There was a problem hiding this comment.
BadImport: Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer. Here we recommend using qualified class: ProcessorCache.
| caches.add(new ProcessorCache(i, 2, 0, 64, cacheSizeL2, Type.UNIFIED)); | |
| caches.add(new ProcessorCache(i, 2, 0, 64, cacheSizeL2, ProcessorCache.Type.UNIFIED)); |
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| } | ||
| break; | ||
| case 1: | ||
| if (cache.getType() == Type.DATA && level1d == null) { |
There was a problem hiding this comment.
BadImport: Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer. Here we recommend using qualified class: ProcessorCache.
| if (cache.getType() == Type.DATA && level1d == null) { | |
| if (cache.getType() == ProcessorCache.Type.DATA && level1d == null) { |
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| int powerVersion = ParseUtil.getFirstIntValue(ExecutingCommand.getFirstAnswer("uname -n")); | ||
| switch (powerVersion) { | ||
| case 7: | ||
| caches.add(new ProcessorCache(3, 8, 128, (2 * 32) << 20, Type.UNIFIED)); |
There was a problem hiding this comment.
BadImport: Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer. Here we recommend using qualified class: ProcessorCache.
| caches.add(new ProcessorCache(3, 8, 128, (2 * 32) << 20, Type.UNIFIED)); | |
| caches.add(new ProcessorCache(3, 8, 128, (2 * 32) << 20, ProcessorCache.Type.UNIFIED)); |
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| try (Stream<Path> path = Files.list(Paths.get(cachePath))) { | ||
| path.filter(p -> p.toString().startsWith(indexPrefix)).forEach(c -> { | ||
| int level = FileUtil.getIntFromFile(c + "/level"); // 1 | ||
| Type type = parseCacheType(FileUtil.getStringFromFile(c + "/type")); // Data |
There was a problem hiding this comment.
BadImport: Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer. Here we recommend using qualified class: ProcessorCache.
| Type type = parseCacheType(FileUtil.getStringFromFile(c + "/type")); // Data | |
| ProcessorCache.Type type = parseCacheType(FileUtil.getStringFromFile(c + "/type")); |
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| Map<Integer, String> processorIdMap = new HashMap<>(); | ||
| WmiResult<ProcessorIdProperty> processorId = Win32Processor.queryProcessorId(); | ||
| // One entry for each package/socket | ||
| WmiResult<ProcessorIdProperty> processorId = Win32Processor.queryProcessorId();// One entry for each |
There was a problem hiding this comment.
INTERFACE_NOT_THREAD_SAFE: Unprotected call to method Ole32.CoInitializeEx(...) of un-annotated interface com.sun.jna.platform.win32.Ole32. Consider annotating the interface with @ThreadSafe or adding a lock.
Reporting because the current class is annotated @ThreadSafe.
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| switch (split[split.length - 1]) { | ||
| case "I-cache": | ||
| return new ProcessorCache(1, ParseUtil.getFirstIntValue(split[2]), ParseUtil.getFirstIntValue(split[1]), | ||
| ParseUtil.parseDecimalMemorySizeToBinary(split[0]), Type.INSTRUCTION); |
There was a problem hiding this comment.
BadImport: Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer. Here we recommend using qualified class: ProcessorCache.
| ParseUtil.parseDecimalMemorySizeToBinary(split[0]), Type.INSTRUCTION); | |
| ParseUtil.parseDecimalMemorySizeToBinary(split[0]), ProcessorCache.Type.INSTRUCTION); |
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| } | ||
|
|
||
| private ProcessorCache parseCacheStr(String cacheStr) { | ||
| String[] split = ParseUtil.whitespaces.split(cacheStr); |
There was a problem hiding this comment.
StringSplitter: String.split(String) has surprising behavior
| String[] split = ParseUtil.whitespaces.split(cacheStr); | |
| List<String> split = Splitter.on(ParseUtil.whitespaces).splitToList(cacheStr); |
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| } else { | ||
| Matcher n = q.matcher(s); | ||
| if (n.matches()) { | ||
| for (String cacheStr : n.group(1).split(",")) { |
There was a problem hiding this comment.
StringSplitter: String.split(String) has surprising behavior
| for (String cacheStr : n.group(1).split(",")) { | |
| for (String cacheStr : Splitter.on(',').split(n.group(1))) { |
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
|
This pull request introduces 1 alert when merging 853a697 into 4a46741 - view on LGTM.com new alerts:
|
| for (String checkLine : ExecutingCommand.runNative("lscpu")) { | ||
| if (checkLine.contains("L1d cache:")) { | ||
| caches.add(new ProcessorCache(1, 0, 0, | ||
| ParseUtil.parseDecimalMemorySizeToBinary(checkLine.split(":")[1].trim()), Type.DATA)); |
There was a problem hiding this comment.
BadImport: Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer. Here we recommend using qualified class: ProcessorCache.
| ParseUtil.parseDecimalMemorySizeToBinary(checkLine.split(":")[1].trim()), Type.DATA)); | |
| ParseUtil.parseDecimalMemorySizeToBinary(checkLine.split(":")[1].trim()), ProcessorCache.Type.DATA)); |
ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
|
This pull request introduces 1 alert when merging c9e272a into 4a46741 - view on LGTM.com new alerts:
|
Co-authored-by: sonatype-lift[bot] <37194012+sonatype-lift[bot]@users.noreply.github.com>
| if (lcpus < 1) { | ||
| lcpus = 1; | ||
| } | ||
| int lpPerPp = lcpus / physProcs; |
There was a problem hiding this comment.
it seems that lpPerPp can become 0... eg. 1/2, 1/3... and then cause a divide by zero on line 132.
see #2228
explainer https://stackoverflow.com/questions/4685450/int-division-why-is-the-result-of-1-3-0
There was a problem hiding this comment.
explainer https://stackoverflow.com/questions/4685450/int-division-why-is-the-result-of-1-3-0
Better explainer: https://xkcd.com/2295/
Fixes #2190