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

counters #287

Merged
merged 1 commit into from
Jun 7, 2018
Merged

counters #287

merged 1 commit into from
Jun 7, 2018

Conversation

aeyakovenko
Copy link
Member

No description provided.

@aeyakovenko aeyakovenko changed the title Counters [wip] counters May 31, 2018
@garious garious mentioned this pull request Jun 4, 2018
Copy link
Contributor

@garious garious left a comment

Choose a reason for hiding this comment

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

@aeyakovenko, can you finish this PR up or close it?

src/counter.rs Outdated
pub lograte: usize,
}

macro_rules! STATIC_COUNTER {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make lowercase? And is there a reason for it to include the word static?

Copy link
Member Author

Choose a reason for hiding this comment

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

because its for static initialization of the counter. its kind of a special thing, we are instrumenting the code with a global

src/counter.rs Outdated
use std::time::{Duration, UNIX_EPOCH, SystemTime};

pub struct Counter {
pub name: &'static str,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could that be String?

Copy link
Member Author

Choose a reason for hiding this comment

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

we are using a static, I think str is more appropriate.

src/counter.rs Outdated

macro_rules! STATIC_COUNTER_INC {
($name:expr, $count:expr, $start:expr) => {
unsafe { $name.inc($count, $start.elapsed()) };
Copy link
Contributor

Choose a reason for hiding this comment

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

Why unsafe?

Copy link
Member Author

Choose a reason for hiding this comment

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

because its a mutable global, rust treats these as unsafe

let nanos = self.nanos.fetch_add(total as usize, Ordering::Relaxed);
let times = self.times.fetch_add(1, Ordering::Relaxed);
if times % self.lograte == 0 && times > 0 {
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use Instant here, so that it's consistent with other uses of now() within the codebase?

Copy link
Member Author

Choose a reason for hiding this comment

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

what would the instant be referencing as epoch? each counter needs to print its value against a global point of reference of time.

Copy link
Member

Choose a reason for hiding this comment

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

can you use timing::timestamp() does what this does

@codecov
Copy link

codecov bot commented Jun 7, 2018

Codecov Report

Merging #287 into master will increase coverage by 0.14%.
The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #287      +/-   ##
==========================================
+ Coverage   90.92%   91.07%   +0.14%     
==========================================
  Files          32       33       +1     
  Lines        3284     3315      +31     
==========================================
+ Hits         2986     3019      +33     
+ Misses        298      296       -2
Impacted Files Coverage Δ
src/lib.rs 100% <ø> (ø) ⬆️
src/sigverify.rs 98.57% <100%> (+6.14%) ⬆️
src/packet.rs 92.23% <100%> (+0.07%) ⬆️
src/banking_stage.rs 92.06% <100%> (+0.26%) ⬆️
src/counter.rs 90.9% <90.9%> (ø)
src/server.rs 94.66% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 586279b...5fedf65. Read the comment docs.

@aeyakovenko aeyakovenko changed the title [wip] counters counters Jun 7, 2018
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
let now_ms = now.as_secs() * 1_000 + now.subsec_nanos() as u64 / 1_000_000;
info!(
"COUNTER:{{\"name:\":\"{}\", \"counts\": {}, \"nanos\": {}, \"samples\": {} \"rate\": {}, \"now\": {}}}",
Copy link
Member Author

Choose a reason for hiding this comment

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

@sakridge should print out to a json formated blob

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I have a change that does that.

src/counter.rs Outdated
@@ -9,7 +9,7 @@ pub struct Counter {
pub lograte: usize,
}

macro_rules! STATIC_COUNTER {
macro_rules! counter_ctor {
Copy link
Contributor

@garious garious Jun 7, 2018

Choose a reason for hiding this comment

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

How about create_counter and inc_counter? <verb>_<subject>

@garious
Copy link
Contributor

garious commented Jun 7, 2018

Needs a rebase

let nanos = self.nanos.fetch_add(total as usize, Ordering::Relaxed);
let times = self.times.fetch_add(1, Ordering::Relaxed);
if times % self.lograte == 0 && times > 0 {
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

can you use timing::timestamp() does what this does

let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
let now_ms = now.as_secs() * 1_000 + now.subsec_nanos() as u64 / 1_000_000;
info!(
"COUNTER:{{\"name:\":\"{}\", \"counts\": {}, \"nanos\": {}, \"samples\": {} \"rate\": {}, \"now\": {}}}",
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I have a change that does that.

@garious garious added the automerge Merge this Pull Request automatically once CI passes label Jun 7, 2018
@solana-grimes solana-grimes merged commit c2a9395 into solana-labs:master Jun 7, 2018
vkomenda pushed a commit to vkomenda/solana that referenced this pull request Aug 29, 2021
Bumps [eslint](https://github.com/eslint/eslint) from 7.6.0 to 7.7.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.6.0...v7.7.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
lijunwangs pushed a commit to lijunwangs/solana that referenced this pull request Mar 21, 2024
…(backport of solana-labs#245) (solana-labs#287)

[anza migration] fix: use the correct log filter for non-unix (solana-labs#245)

fix: use the correct log filter for non-unix
(cherry picked from commit 2537e3e)

Co-authored-by: Yihau Chen <a122092487@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants