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
f819bb72
Commit
f819bb72
authored
Apr 26, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize Trace#write/append/raw by caching data and avoiding unnecesary truncate
parent
c588dd84
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
29 deletions
+36
-29
app/models/ci/build_trace_chunk.rb
app/models/ci/build_trace_chunk.rb
+35
-27
lib/gitlab/ci/trace/chunked_io.rb
lib/gitlab/ci/trace/chunked_io.rb
+1
-1
lib/gitlab/ci/trace/stream.rb
lib/gitlab/ci/trace/stream.rb
+0
-1
No files found.
app/models/ci/build_trace_chunk.rb
View file @
f819bb72
...
...
@@ -21,36 +21,14 @@ module Ci
db:
2
}
##
# Data is memoized for optimizing #size and #end_offset
def
data
if
redis?
redis_data
elsif
db?
raw_data
else
raise
'Unsupported data store'
end
&
.
force_encoding
(
Encoding
::
BINARY
)
# Redis/Database return UTF-8 string as default
end
def
set_data
(
value
)
raise
ArgumentError
,
'too much data'
if
value
.
bytesize
>
CHUNK_SIZE
in_lock
do
if
redis?
redis_set_data
(
value
)
elsif
db?
self
.
raw_data
=
value
else
raise
'Unsupported data store'
end
save!
if
changed?
end
schedule_to_db
if
fullfilled?
@data
||=
get_data
end
def
truncate
(
offset
=
0
)
self
.
append
(
""
,
offset
)
self
.
append
(
""
,
offset
)
if
offset
<
size
end
def
append
(
new_data
,
offset
)
...
...
@@ -58,7 +36,7 @@ module Ci
raise
ArgumentError
,
'Offset is out of bound'
if
offset
>
current_data
.
bytesize
||
offset
<
0
raise
ArgumentError
,
'Outside of chunk size'
if
CHUNK_SIZE
<
offset
+
new_data
.
bytesize
se
lf
.
se
t_data
(
current_data
.
byteslice
(
0
,
offset
)
+
new_data
)
set_data
(
current_data
.
byteslice
(
0
,
offset
)
+
new_data
)
end
def
size
...
...
@@ -89,6 +67,36 @@ module Ci
private
def
get_data
if
redis?
redis_data
elsif
db?
raw_data
else
raise
'Unsupported data store'
end
&
.
force_encoding
(
Encoding
::
BINARY
)
# Redis/Database return UTF-8 string as default
end
def
set_data
(
value
)
raise
ArgumentError
,
'too much data'
if
value
.
bytesize
>
CHUNK_SIZE
in_lock
do
if
redis?
redis_set_data
(
value
)
elsif
db?
self
.
raw_data
=
value
else
raise
'Unsupported data store'
end
@data
=
value
save!
if
changed?
end
schedule_to_db
if
fullfilled?
end
def
schedule_to_db
return
if
db?
...
...
lib/gitlab/ci/trace/chunked_io.rb
View file @
f819bb72
...
...
@@ -143,7 +143,7 @@ module Gitlab
trace_chunks
.
where
(
'chunk_index > ?'
,
chunk_index
).
destroy_all
# truncate current chunk
current_chunk
.
truncate
(
chunk_offset
)
if
chunk_offset
!=
0
current_chunk
.
truncate
(
chunk_offset
)
ensure
invalidate_chunk_cache
end
...
...
lib/gitlab/ci/trace/stream.rb
View file @
f819bb72
...
...
@@ -52,7 +52,6 @@ module Gitlab
stream
.
seek
(
0
,
IO
::
SEEK_SET
)
stream
.
write
(
data
)
stream
.
truncate
(
data
.
bytesize
)
stream
.
flush
()
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