Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Gaudi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaudi
Gaudi
Commits
8bb23fbf
Commit
8bb23fbf
authored
2 years ago
by
Christopher Rob Jones
Browse files
Options
Downloads
Patches
Plain Diff
ProcStats: remove data members that do not need caching
parent
287799ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1410
ProcStats : Use mutex lock to make fetch() thread safe.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GaudiAud/src/ProcStats.cpp
+8
-9
8 additions, 9 deletions
GaudiAud/src/ProcStats.cpp
GaudiAud/src/ProcStats.h
+6
-7
6 additions, 7 deletions
GaudiAud/src/ProcStats.h
with
14 additions
and
16 deletions
GaudiAud/src/ProcStats.cpp
+
8
−
9
View file @
8bb23fbf
...
...
@@ -249,13 +249,11 @@ ProcStats* ProcStats::instance() {
ProcStats
::
ProcStats
()
{
#if defined( __linux__ ) or defined( __APPLE__ )
m_pg_size
=
sysconf
(
_SC_PAGESIZE
);
// getpagesize();
m_fname
=
"/proc/"
+
std
::
to_string
(
getpid
()
)
+
"/stat"
;
m_ufd
.
open
(
m_fname
.
c_str
(),
O_RDONLY
);
m_pg_size
=
sysconf
(
_SC_PAGESIZE
);
// getpagesize();
const
auto
fname
=
"/proc/"
+
std
::
to_string
(
getpid
()
)
+
"/stat"
;
m_ufd
.
open
(
fname
.
c_str
(),
O_RDONLY
);
if
(
!
m_ufd
)
{
cerr
<<
"Failed to open "
<<
m_
fname
<<
endl
;
cerr
<<
"Failed to open "
<<
fname
<<
endl
;
return
;
}
#endif // __linux__ or __APPLE__
...
...
@@ -272,18 +270,19 @@ bool ProcStats::fetch( procInfo& f ) {
double
pr_size
{
0
},
pr_rssize
{
0
};
linux_proc
pinfo
;
int
cnt
{
0
};
char
buf
[
500
];
m_ufd
.
lseek
(
0
,
SEEK_SET
);
if
(
(
cnt
=
m_ufd
.
read
(
m_
buf
,
sizeof
(
m_
buf
)
)
)
<
0
)
{
if
(
(
cnt
=
m_ufd
.
read
(
buf
,
sizeof
(
buf
)
)
)
<
0
)
{
cout
<<
"LINUX Read of Proc file failed:"
<<
endl
;
return
false
;
}
if
(
cnt
>
0
)
{
m_
buf
[
std
::
min
(
static_cast
<
std
::
size_t
>
(
cnt
),
sizeof
(
m_
buf
)
-
1
)]
=
'\0'
;
buf
[
std
::
min
(
static_cast
<
std
::
size_t
>
(
cnt
),
sizeof
(
buf
)
-
1
)]
=
'\0'
;
sscanf
(
m_
buf
,
sscanf
(
buf
,
// 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 20 1 2 3 4 5 6 7 8 9
// 30 1 2 3 4 5
"%d %s %c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %llu %lu %ld %lu %lu %lu %lu "
...
...
This diff is collapsed.
Click to expand it.
GaudiAud/src/ProcStats.h
+
6
−
7
View file @
8bb23fbf
...
...
@@ -107,11 +107,10 @@ private:
#undef unique_fd_forward
};
unique_fd
m_ufd
;
double
m_pg_size
{
0
};
procInfo
m_curr
;
std
::
string
m_fname
;
char
m_buf
[
500
];
bool
m_valid
{
false
};
std
::
mutex
m_mutex
;
private
:
unique_fd
m_ufd
;
double
m_pg_size
{
0
};
procInfo
m_curr
;
bool
m_valid
{
false
};
std
::
mutex
m_mutex
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment