Commit 9141aa4
committed
[SPARK-48744][CORE] Log entry should be constructed only once
### What changes were proposed in this pull request?
In the current implementation:
```
class LogEntry(messageWithContext: => MessageWithContext) {
def message: String = messageWithContext.message
def context: java.util.HashMap[String, String] = messageWithContext.context
}
def logInfo(entry: LogEntry): Unit = {
if (log.isInfoEnabled) {
withLogContext(entry.context) {
log.info(entry.message)
}
}
}
```
The field `messageWithContext` is constructed twice, one from `entry.context` and another one from `entry.message`.
This PR is to improve this and ensure a log entry is constructed only once.
### Why are the changes needed?
Improve the performance of logging
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
New UT
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #47135 from gengliangwang/addCache.
Authored-by: Gengliang Wang <[email protected]>
Signed-off-by: Gengliang Wang <[email protected]>1 parent 2eeebef commit 9141aa4
File tree
2 files changed
+36
-3
lines changed- common/utils/src
- main/scala/org/apache/spark/internal
- test/scala/org/apache/spark/util
2 files changed
+36
-3
lines changedLines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
105 | 107 | | |
106 | 108 | | |
107 | 109 | | |
| |||
Lines changed: 32 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
231 | 262 | | |
232 | 263 | | |
233 | 264 | | |
| |||
0 commit comments