[
https://issues.apache.org/jira/browse/HADOOP-17461?focusedWorklogId=789476&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-789476
]
ASF GitHub Bot logged work on HADOOP-17461:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 11/Jul/22 11:26
Start Date: 11/Jul/22 11:26
Worklog Time Spent: 10m
Work Description: steveloughran commented on code in PR #4352:
URL: https://github.com/apache/hadoop/pull/4352#discussion_r917816203
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsContext.java:
##########
@@ -51,21 +51,21 @@ public class IOStatisticsContext {
private static final boolean IS_THREAD_IOSTATS_ENABLED;
private static final WeakReferenceThreadMap<IOStatisticsContext>
Review Comment:
let's add a brief comment here as it is a key part of the design
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsContext.java:
##########
@@ -164,13 +165,25 @@ public void setThreadIOStatistics(
*
* @return IOStatisticsSnapshot of the current thread.
*/
- public IOStatisticsSnapshot getThreadIOStatisticsSnapshot() {
+ public IOStatisticsSnapshot snapshotCurrentThreadIOStatistics() {
if (IS_THREAD_IOSTATS_ENABLED) {
return (IOStatisticsSnapshot) getThreadIOStatistics();
}
return new IOStatisticsSnapshot();
}
+ /**
+ * Reset the thread IOStatistics for current thread.
+ */
+ public void resetThreadIOStatisticsForCurrentThread() {
+ if (IS_THREAD_IOSTATS_ENABLED) {
+ IOStatisticsSnapshot currentThreadIOStatsSnapshot =
+ (IOStatisticsSnapshot) getThreadIOStatistics();
+ currentThreadIOStatsSnapshot.clear();
+ setThreadIOStatistics(currentThreadIOStatsSnapshot);
Review Comment:
don't think this is needed
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsContext.java:
##########
@@ -51,21 +51,21 @@ public class IOStatisticsContext {
private static final boolean IS_THREAD_IOSTATS_ENABLED;
private static final WeakReferenceThreadMap<IOStatisticsContext>
- ACTIVE_IOSTATS_CONTEXT = new WeakReferenceThreadMap<>(
- IOStatisticsContext::createNewInstance,
- IOStatisticsContext::referenceLostContext
+ ACTIVE_IOSTATS_CONTEXT =
+ new WeakReferenceThreadMap<>(IOStatisticsContext::createNewInstance,
+ IOStatisticsContext::referenceLostContext
);
/**
* Collecting IOStatistics per thread.
*/
private final WeakReferenceThreadMap<IOStatisticsAggregator>
Review Comment:
now we are casting to a snapshot, why not make this of type
`IOStatisticsSnapshot`
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsContext.java:
##########
@@ -164,13 +165,25 @@ public void setThreadIOStatistics(
*
* @return IOStatisticsSnapshot of the current thread.
*/
- public IOStatisticsSnapshot getThreadIOStatisticsSnapshot() {
+ public IOStatisticsSnapshot snapshotCurrentThreadIOStatistics() {
if (IS_THREAD_IOSTATS_ENABLED) {
return (IOStatisticsSnapshot) getThreadIOStatistics();
}
return new IOStatisticsSnapshot();
}
+ /**
+ * Reset the thread IOStatistics for current thread.
+ */
+ public void resetThreadIOStatisticsForCurrentThread() {
+ if (IS_THREAD_IOSTATS_ENABLED) {
+ IOStatisticsSnapshot currentThreadIOStatsSnapshot =
+ (IOStatisticsSnapshot) getThreadIOStatistics();
Review Comment:
This is going to demand create a snapshot context even if there wasn't one
needing resetting. How about you just look in the reference map (via
lookup(currentThreadId())); and only if a ref is returned do the resetting?
Issue Time Tracking
-------------------
Worklog Id: (was: 789476)
Time Spent: 2h 50m (was: 2h 40m)
> Add thread-level IOStatistics Context
> -------------------------------------
>
> Key: HADOOP-17461
> URL: https://issues.apache.org/jira/browse/HADOOP-17461
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: fs, fs/azure, fs/s3
> Affects Versions: 3.3.1
> Reporter: Steve Loughran
> Assignee: Mehakmeet Singh
> Priority: Major
> Labels: pull-request-available
> Time Spent: 2h 50m
> Remaining Estimate: 0h
>
> For effective reporting of the iostatistics of individual worker threads, we
> need a thread-level context which IO components update.
> * this contact needs to be passed in two background thread forming work on
> behalf of a task.
> * IO Components (streams, iterators, filesystems) need to update this context
> statistics as they perform work
> * Without double counting anything.
> I imagine a ThreadLocal IOStatisticContext which will be updated in the
> FileSystem API Calls. This context MUST be passed into the background threads
> used by a task, so that IO is correctly aggregated.
> I don't want streams, listIterators &c to do the updating as there is more
> risk of double counting. However, we need to see their statistics if we want
> to know things like "bytes discarded in backwards seeks". And I don't want to
> be updating a shared context object on every read() call.
> If all we want is store IO (HEAD, GET, DELETE, list performance etc) then the
> FS is sufficient.
> If we do want the stream-specific detail, then I propose
> * caching the context in the constructor
> * updating it only in close() or unbuffer() (as we do from S3AInputStream to
> S3AInstrumenation)
> * excluding those we know the FS already collects.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]