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

[optimze] optimize some metric style #2319

Closed
fansehep opened this issue Mar 17, 2023 · 10 comments
Closed

[optimze] optimize some metric style #2319

fansehep opened this issue Mar 17, 2023 · 10 comments
Assignees
Labels
enhancement improve feature feature new feature good first issue Good for newcomers

Comments

@fansehep
Copy link
Member

In /curvefs/src/client/metric/client_metric.h:

struct FSMetric {
    const std::string prefix = "curvefs_client";

...

struct S3Metric {
    const std::string prefix = "curvefs_s3";

...
struct DiskCacheMetric {
    const std::string prefix = "curvefs_disk_cache";

struct KVClientMetric {
    const std::string prefix = "curvefs_kvclient";

...

struct KVClientMetric {
    const std::string prefix = "curvefs_kvclient";

...

Use const std::string xxx in a struct type is strange. static is right.

Optimize them in all *.h and *.cpp;

@fansehep fansehep added enhancement improve feature good first issue Good for newcomers feature new feature labels Mar 17, 2023
@Veeshavanachu
Copy link

i will take this

@ashutosh887
Copy link

@fansehep Let me work on this

@caoxianfei1
Copy link
Contributor

@ashutosh887 the work going on?

@wu-hanqing
Copy link
Contributor

struct FSMetric {
    static constexpr const char* prefix = "curvefs_client";
};

maybe this's better, if you use static const std::string, you have to define the string in cpp file.

godbolt

@fansehep
Copy link
Member Author

const char* if we have a function like void xxx(const std::string& str_name), we input a const char* here, that will construct a string.

But in fact, static variables are initialized at runtime, and char* can be compile-time constants. It may depend on the scenario.

I think here std::string is better than const char*.

@zhanghuidinah
Copy link
Member

@Xinlong-Chen
Copy link
Contributor

The issue seems more simple than other issues, can I get this task?
I agree with the const static std::string plan because it is more high-efficiency.
I will add a cpp file to initialize all the string variables.

@Xinlong-Chen
Copy link
Contributor

Xinlong-Chen commented Apr 19, 2023

Why does following classes not define const? (such as const std::string prefix;,other class in this file do it)
In /curvefs/src/client/metric/client_metric.h

struct MDSClientMetric {
    std::string prefix;
}

struct MetaServerClientMetric {
    std::string prefix;
}

struct ClientOpMetric {
    std::string prefix;
}

@wu-hanqing
Copy link
Contributor

it should be, you can fix this.

@czzmiku
Copy link

czzmiku commented Apr 20, 2023

can I do it? #2319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improve feature feature new feature good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

9 participants