Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
batmen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
sepia-pub
mael
batmen
Merge requests
!9
Several active sessions
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Several active sessions
several-active-sessions
into
master
Overview
0
Commits
4
Pipelines
1
Changes
5
Merged
Ghost User
requested to merge
several-active-sessions
into
master
2 years ago
Overview
0
Commits
4
Pipelines
1
Changes
5
Expand
Closes
#8 (closed)
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
12de3de9
4 commits,
2 years ago
5 files
+
176
−
63
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
src/users/user_feedback.cpp
+
83
−
60
Options
@@ -2,6 +2,7 @@
#include
"../pempek_assert.hpp"
#include
"json_workload.hpp"
#include
"rapidjson/document.h"
#include
<limits>
#include
<string>
/* FeedbackUser */
@@ -42,78 +43,108 @@ FeedbackUser::~FeedbackUser()
{
}
void
FeedbackUser
::
update_date_next_sub
()
{
/* Calculate the date of next submission.
* next_submit_time = DATE_UNKNOWN || DATE_NEVER ||
min(free_session->next, active_session->next) */
if
(
active_sessions
.
empty
()){
if
(
!
free_sessions
.
empty
())
date_of_next_submission
=
free_sessions
.
top
()
->
start_time
;
else
if
(
ongoing_job_counter
>
0
)
date_of_next_submission
=
DATE_UNKNOWN
;
else
date_of_next_submission
=
DATE_NEVER
;
return
;
}
/* Case active_sessions not empty: the next submit time is known.
* Calculate the min. */
date_of_next_submission
=
std
::
numeric_limits
<
double
>::
max
();
for
(
Session
*
active_sess
:
active_sessions
)
{
PPK_ASSERT_ERROR
(
!
active_sess
->
jobs
.
empty
(),
"Active session %d has no job to submit"
,
active_sess
->
id
);
double
next_call
=
active_sess
->
start_time
+
active_sess
->
jobs
.
front
()
->
submission_time
;
date_of_next_submission
=
std
::
min
(
date_of_next_submission
,
next_call
);
}
if
(
!
free_sessions
.
empty
())
date_of_next_submission
=
std
::
min
(
date_of_next_submission
,
free_sessions
.
top
()
->
start_time
);
return
;
}
void
FeedbackUser
::
jobs_to_submit
(
double
date
,
std
::
list
<
Job
*>
&
jobs
,
std
::
list
<
Profile
*>
&
profiles
)
{
jobs
=
std
::
list
<
Job
*>
();
profiles
=
std
::
list
<
Profile
*>
();
if
(
active_session
==
nullptr
)
/* Add the free sessions starting now to the list of active sessions */
while
(
!
free_sessions
.
empty
()
&&
free_sessions
.
top
()
->
start_time
<=
date
)
{
PPK_ASSERT_ERROR
(
!
free_sessions
.
empty
(),
"User %s has been called to sumbit but she has neither an active "
"session nor free sessions"
,
user_name
.
c_str
());
PPK_ASSERT_ERROR
(
free_sessions
.
top
()
->
start_time
<=
date
,
"Next free session of user %s has greater start time than "
"current date"
,
user_name
.
c_str
());
active_session
=
free_sessions
.
top
();
active_sessions
.
push_back
(
free_sessions
.
top
());
free_sessions
.
pop
();
}
auto
job_list
=
&
active_session
->
jobs
;
PPK_ASSERT_ERROR
(
!
job_list
->
empty
(),
"User %s has been called to sumbit but the job list in her active "
"session is empty"
,
PPK_ASSERT_ERROR
(
!
active_sessions
.
empty
(),
"User %s has been called to sumbit but she has no active session"
,
user_name
.
c_str
());
double
offset
=
active_session
->
start_time
;
PPK_ASSERT_ERROR
(
job_list
->
front
()
->
submission_time
+
offset
<=
date
,
"First job in user %s's job list has greater sumbmission time than "
"current date"
,
user_name
.
c_str
());
/* Submit all jobs that have same submit time */
while
(
!
job_list
->
empty
()
&&
job_list
->
front
()
->
submission_time
+
offset
<=
date
)
/* For each active session, add the jobs to submit now to the list `jobs` */
for
(
auto
iter
=
active_sessions
.
begin
();
iter
!=
active_sessions
.
end
();)
{
Job
*
job
=
new
Job
(
*
job_list
->
front
());
/* Cast const Job * -> Job * */
Profile
*
job_profile
=
new
Profile
();
Session
*
active_sess
=
*
iter
;
auto
job_list
=
&
active_sess
->
jobs
;
PPK_ASSERT_ERROR
(
!
job_list
->
empty
(),
"Active session %d has no job to submit"
,
active_sess
->
id
);
/* Handle the job according to the user behavior. */
bool
execute_now
=
handle_job
(
date
,
job
,
job_profile
);
double
offset
=
active_sess
->
start_time
;
if
(
execute_now
)
while
(
!
job_list
->
empty
()
&&
job_list
->
front
()
->
submission_time
+
offset
<=
date
)
{
job
->
submission_time
=
date
;
/* Add it to the list of jobs (and profiles, if new) to submit */
jobs
.
push_back
(
job
);
if
(
sent_profiles
.
count
(
job
->
profile
)
==
0
)
Job
*
job
=
new
Job
(
*
job_list
->
front
());
// Cast const Job * -> Job *
Profile
*
job_profile
=
new
Profile
();
/* Handle the job according to the user behavior. */
bool
execute_now
=
handle_job
(
date
,
job
,
job_profile
);
if
(
execute_now
)
{
profiles
.
push_back
(
job_profile
);
sent_profiles
.
insert
(
job
->
profile
);
job
->
submission_time
=
date
;
/* Add it to the list of jobs (and profiles, if new) to submit */
jobs
.
push_back
(
job
);
if
(
sent_profiles
.
count
(
job
->
profile
)
==
0
)
{
profiles
.
push_back
(
job_profile
);
sent_profiles
.
insert
(
job
->
profile
);
}
ongoing_job_counter
++
;
/* Delete job from the job list */
job_list
->
pop_front
();
}
ongoing_job_counter
++
;
/* Delete job from the job list */
job_list
->
pop_front
();
}
}
/* Update next submit time */
if
(
!
job_list
->
empty
())
date_of_next_submission
=
job_list
->
front
()
->
submission_time
+
offset
;
else
{
active_session
=
nullptr
;
if
(
!
free_sessions
.
empty
())
date_of_next_submission
=
free_sessions
.
top
()
->
start_time
;
if
(
job_list
->
empty
())
/* active session finished: close it */
iter
=
active_sessions
.
erase
(
iter
);
else
date_of_next_submission
=
DATE_UNKNOWN
;
++
iter
;
}
PPK_ASSERT_ERROR
(
!
jobs
.
empty
(),
"User %s called to submit but did not submit any job"
,
user_name
.
c_str
());
/* Update next submit time */
update_date_next_sub
();
}
void
FeedbackUser
::
wake_on_feedback
(
double
date
,
std
::
list
<
Job
*>
&
ended_jobs
)
@@ -131,16 +162,8 @@ void FeedbackUser::wake_on_feedback(double date, std::list<Job *> &ended_jobs)
close_session
(
date
,
j
->
session
);
}
/* If no active session, find the next submit time */
if
(
active_session
==
nullptr
)
{
if
(
!
free_sessions
.
empty
())
date_of_next_submission
=
free_sessions
.
top
()
->
start_time
;
else
if
(
ongoing_job_counter
>
0
)
date_of_next_submission
=
DATE_UNKNOWN
;
else
date_of_next_submission
=
DATE_NEVER
;
}
/* The next submit time might have changed in reaction to feedback */
update_date_next_sub
();
}
/* FBUserThinkTimeOnly */
Loading