Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fs iotime in Nodes Stats API #67861

Merged
merged 13 commits into from
May 5, 2021
Merged

Conversation

easyice
Copy link
Contributor

@easyice easyice commented Jan 22, 2021

Related to #67805

This PR add io_time_in_millis in Nodes stats API, In the benchmark, it works almost as well as the iostat command

step 1,Perform random reads and writes on disk

fio -filename=/data00/tmp/1Gb.file -direct=1 -iodepth 1 -thread -rw=randrw -ioengine=libaio -bs=4k -size=10G -numjobs=2 -runtime=1000 -group_reporting -name=mytest

step 2, Compare the results of the io_time and iostat commands,use this script

while true
do
 ts1=`echo $(($(date +%s%N)/1000000))`
 iotime1=`curl -s "127.0.0.1:9200/_nodes/stats/fs?pretty" |grep io_time_in_millis | head -n 1 | awk '{print $3}'`
 sleep 5
 iotime2=`curl -s "127.0.0.1:9200/_nodes/stats/fs?pretty" |grep io_time_in_millis | head -n 1 | awk '{print $3}'`
 ts2=`echo $(($(date +%s%N)/1000000))`

 echo "scale=2;($iotime2-$iotime1)/($ts2-$ts1)*100" | bc
done

the result:

image

@jtibshirani jtibshirani added the :Data Management/Stats Statistics tracking and retrieval APIs label Jan 26, 2021
@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Jan 26, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (Team:Core/Features)

@danhermann danhermann self-requested a review January 28, 2021 16:31
@mark-vieira
Copy link
Contributor

@elasticmachine update branch

@martijnvg martijnvg removed the request for review from danhermann March 11, 2021 15:31
@andreidan andreidan self-requested a review March 11, 2021 16:40
Copy link
Contributor

@andreidan andreidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @easyice. LGTM

@andreidan
Copy link
Contributor

@elasticmachine ok to test

@andreidan
Copy link
Contributor

@elasticmachine update branch

Copy link
Contributor

@andreidan andreidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@easyice I've just left a comment regarding adding backwards compatibility checks for this change. Thanks!

Comment on lines 256 to 257
out.writeLong(currentIOTime);
out.writeLong(previousIOTime);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to read/write the new fields in a backwards compatible way (similar to how we do it here for eg. https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/AggProvider.java#L137 - there are probably other areas in the code). Let me know if you need any help with these version checks to ensure these fields are added in a BWC way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed instructions, i added the compatibility checks ,use Version.V_7_13_0

Comment on lines 239 to 240
currentIOTime = in.readLong();
previousIOTime = in.readLong();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version checks for bwc are needed here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review, Version checks is added

@easyice easyice requested a review from andreidan March 20, 2021 07:39
Copy link
Contributor

@andreidan andreidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for iterating on this @easyice

Apologies, I should've mentioned, at the time of merge we need the version checks to be against V8_0_0 (and I'll subsequently change them to 7_13_0 after the change is backported to that release line). Can you please modify the version checks?

Also, there are some checkstyles issues. We have more information on how to configure and run the checkstyle locally here - alternatively, running something along the lines of ./gradlew checkStyleMain checkStyleTest checkstyleInternalClusterTest checkstyleIntegTest checkstyleTestFixtures should help spot the issues

@easyice
Copy link
Contributor Author

easyice commented Mar 22, 2021

Thanks for @andreidan , I will pay more attention next time

Copy link
Contributor

@andreidan andreidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the version and the checkstyle

Added just a few more minor comments, this is close to complete.

Besides the comments there's also a test failure in org.elasticsearch.xpack.monitoring.collector.node.NodeStatsMonitoringDocTests.testToXContent


final DeviceStats[] devicesStats;
final long totalOperations;
final long totalReadOperations;
final long totalWriteOperations;
final long totalReadKilobytes;
final long totalWriteKilobytes;
long totalIOTimeInMillis;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this final please? (explicitly initialising it to 0 on the else branch after the constructor version check here )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks you @andreidan, i will make it as final

Comment on lines 170 to 171
long currentIOTime;
long previousIOTime;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also mark these as final?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've changed it to final, thank you for check!

@easyice
Copy link
Contributor Author

easyice commented Mar 22, 2021

Thanks for @andreidan
The test failure for NodeStatsMonitoringDocTests.testToXContent is fixed, but the io_stats field is not add in testToXContent function:

+ " \"read_operations\": 4,"
+ " \"write_operations\": 4,"
+ " \"read_kilobytes\": 2,"
+ " \"write_kilobytes\": 2"
+ " }"
+ " }"
+ " }"

and NodeStatsMonitoringDoc#XCONTENT_FILTERS

"node_stats.fs.io_stats.total.write_operations",
"node_stats.fs.io_stats.total.read_kilobytes",
"node_stats.fs.io_stats.total.write_kilobytes",
"node_stats.fs.total.total_in_bytes",
"node_stats.fs.total.free_in_bytes",
"node_stats.fs.total.available_in_bytes",

Do these also need to be add the io_time_in_millis field?

@cla-checker-service
Copy link

cla-checker-service bot commented Mar 22, 2021

💚 CLA has been signed

@easyice
Copy link
Contributor Author

easyice commented Mar 23, 2021

I'm sorry i use another computer push some code, which git config is not match this user and email, cause the cla check error, when I change to the correct configuration, the cla check still returns an error, can you please help me how to fix this issue? @andreidan

@easyice easyice requested a review from andreidan March 28, 2021 08:14
@easyice
Copy link
Contributor Author

easyice commented Mar 29, 2021

@andreidan the CLA check failed issue is fixed, Can you please take review again? Thanks!

Copy link
Contributor

@andreidan andreidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply @easyice (I was on holiday). Thanks for addressing the previous comments and for iterating on this! I think this is close to complete, I've left just a couple of super minor formatting comments after which this is complete

Comment on lines 375 to 377
}
else{
this.totalIOTimeInMillis = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super minor: there's a formatting issue here

if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
currentIOTime = in.readLong();
previousIOTime = in.readLong();
}else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super minor: there's a formatting issue here

@andreidan
Copy link
Contributor

@elasticmachine update branch

@easyice
Copy link
Contributor Author

easyice commented Apr 12, 2021

Thanks for @andreidan , happy holiday! the formatting issue is fixed

@andreidan
Copy link
Contributor

@elasticmachine update branch

@andreidan andreidan mentioned this pull request May 5, 2021
andreidan added a commit that referenced this pull request May 5, 2021
Disable bwc in preparation for merging #67861
Copy link
Contributor

@andreidan andreidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution and for iterating on this @easyice

LGTM

@andreidan andreidan merged commit 71a9cfe into elastic:master May 5, 2021
andreidan pushed a commit to andreidan/elasticsearch that referenced this pull request May 5, 2021
This adds io_time_in_millis to Nodes stats API

(cherry picked from commit 71a9cfe)
Signed-off-by: Andrei Dan <[email protected]>
andreidan added a commit that referenced this pull request May 5, 2021
This adds io_time_in_millis to Nodes stats API

(cherry picked from commit 71a9cfe)
Signed-off-by: Andrei Dan <[email protected]>

Co-authored-by: zhangchao <[email protected]>
@easyice
Copy link
Contributor Author

easyice commented May 6, 2021

Thanks for your help @andreidan

mindw added a commit to mindw/elasticsearch that referenced this pull request Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Stats Statistics tracking and retrieval APIs >enhancement Team:Data Management Meta label for data/management team v7.14.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants