Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ddcd4b58
Commit
ddcd4b58
authored
Aug 30, 2021
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address latest review
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
d4b10599
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
scripts/static-analysis
scripts/static-analysis
+10
-10
No files found.
scripts/static-analysis
View file @
ddcd4b58
...
...
@@ -19,7 +19,7 @@ class StaticAnalysis
command
.
join
(
' '
)
end
end
NodeAssignment
=
Struct
.
new
(
:index
,
:tasks
,
:total_duration
)
do
NodeAssignment
=
Struct
.
new
(
:index
,
:tasks
)
do
def
total_duration
return
0
if
tasks
.
empty?
...
...
@@ -53,7 +53,7 @@ class StaticAnalysis
Task
.
new
(
%w[scripts/lint-rugged]
,
1
),
Task
.
new
(
%w[scripts/gemfile_lock_changed.sh]
,
1
),
Task
.
new
(
%w[scripts/frontend/check_no_partial_karma_jest.sh]
,
1
)
].
reject
{
|
t
|
t
.
nil?
}
.
freeze
].
compact
.
freeze
def
run_tasks!
(
options
=
{})
node_assignment
=
tasks_to_run
((
ENV
[
'CI_NODE_TOTAL'
]
||
1
).
to_i
)[(
ENV
[
'CI_NODE_INDEX'
]
||
1
).
to_i
-
1
]
...
...
@@ -129,17 +129,17 @@ class StaticAnalysis
def
tasks_to_run
(
node_total
)
total_time
=
TASKS_WITH_DURATIONS_SECONDS
.
sum
(
&
:duration
).
to_f
ideal_time_per_
job
=
total_time
/
node_total
ideal_time_per_
node
=
total_time
/
node_total
tasks_by_duration_desc
=
TASKS_WITH_DURATIONS_SECONDS
.
sort_by
{
|
a
|
-
a
.
duration
}
nodes
=
Array
.
new
(
node_total
)
{
|
i
|
NodeAssignment
.
new
(
i
+
1
,
[]
,
0
)
}
nodes
=
Array
.
new
(
node_total
)
{
|
i
|
NodeAssignment
.
new
(
i
+
1
,
[])
}
puts
"Total expected time:
#{
total_time
}
; ideal time per job:
#{
ideal_time_per_
job
}
.
\n\n
"
puts
"Total expected time:
#{
total_time
}
; ideal time per job:
#{
ideal_time_per_
node
}
.
\n\n
"
puts
"Tasks to distribute:"
tasks_by_duration_desc
.
each
{
|
task
|
puts
"*
#{
task
.
cmd
}
(
#{
task
.
duration
}
s)"
}
# Distribute tasks optimally first
puts
"
\n
Assigning tasks optimally."
distribute_tasks
(
tasks_by_duration_desc
,
nodes
,
ideal_time_per_
job:
ideal_time_per_job
)
distribute_tasks
(
tasks_by_duration_desc
,
nodes
,
ideal_time_per_
node:
ideal_time_per_node
)
# Distribute remaining tasks, ordered by ascending duration
leftover_tasks
=
tasks_by_duration_desc
-
nodes
.
flat_map
(
&
:tasks
)
...
...
@@ -157,17 +157,17 @@ class StaticAnalysis
nodes
end
def
distribute_tasks
(
tasks
,
nodes
,
ideal_time_per_
job
:
nil
)
def
distribute_tasks
(
tasks
,
nodes
,
ideal_time_per_
node
:
nil
)
condition
=
if
ideal_time_per_
job
->
(
task
,
node
,
ideal_time_per_
job
)
{
(
task
.
duration
+
node
.
total_duration
)
<=
ideal_time_per_job
}
if
ideal_time_per_
node
->
(
task
,
node
,
ideal_time_per_
node
)
{
(
task
.
duration
+
node
.
total_duration
)
<=
ideal_time_per_node
}
else
->
(
*
)
{
true
}
end
tasks
.
each
do
|
task
|
nodes
.
each
do
|
node
|
if
condition
.
call
(
task
,
node
,
ideal_time_per_
job
)
if
condition
.
call
(
task
,
node
,
ideal_time_per_
node
)
assign_task_to_node
(
tasks
,
node
,
task
)
break
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment