Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
074934be
"src/diffusers/models/autoencoders/consistency_decoder_vae.py" did not exist on "29b2c93c9005c87f8f04b1f0835babbcea736204"
Commit
074934be
authored
Jan 26, 2024
by
Michael Yang
Browse files
adjust group limit based on download speed
parent
0de12368
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
server/download.go
server/download.go
+31
-0
No files found.
server/download.go
View file @
074934be
...
@@ -152,6 +152,36 @@ func (b *blobDownload) Run(ctx context.Context, requestURL *url.URL, opts *regis
...
@@ -152,6 +152,36 @@ func (b *blobDownload) Run(ctx context.Context, requestURL *url.URL, opts *regis
_
=
file
.
Truncate
(
b
.
Total
)
_
=
file
.
Truncate
(
b
.
Total
)
g
,
inner
:=
NewLimitGroup
(
ctx
,
numDownloadParts
)
g
,
inner
:=
NewLimitGroup
(
ctx
,
numDownloadParts
)
go
func
()
{
ticker
:=
time
.
NewTicker
(
time
.
Second
)
var
n
int64
=
1
var
maxDelta
float64
var
buckets
[]
int64
for
{
select
{
case
<-
ticker
.
C
:
buckets
=
append
(
buckets
,
b
.
Completed
.
Load
())
if
len
(
buckets
)
<
2
{
continue
}
else
if
len
(
buckets
)
>
10
{
buckets
=
buckets
[
1
:
]
}
delta
:=
float64
((
buckets
[
len
(
buckets
)
-
1
]
-
buckets
[
0
]))
/
float64
(
len
(
buckets
))
slog
.
Debug
(
fmt
.
Sprintf
(
"delta: %s/s max_delta: %s/s"
,
format
.
HumanBytes
(
int64
(
delta
)),
format
.
HumanBytes
(
int64
(
maxDelta
))))
if
delta
>
maxDelta
*
1.5
{
maxDelta
=
delta
g
.
SetLimit
(
n
)
n
++
}
case
<-
ctx
.
Done
()
:
return
}
}
}()
for
i
:=
range
b
.
Parts
{
for
i
:=
range
b
.
Parts
{
part
:=
b
.
Parts
[
i
]
part
:=
b
.
Parts
[
i
]
if
part
.
Completed
==
part
.
Size
{
if
part
.
Completed
==
part
.
Size
{
...
@@ -413,6 +443,7 @@ func (g *LimitGroup) Go(fn func() error) {
...
@@ -413,6 +443,7 @@ func (g *LimitGroup) Go(fn func() error) {
func
(
g
*
LimitGroup
)
SetLimit
(
n
int64
)
{
func
(
g
*
LimitGroup
)
SetLimit
(
n
int64
)
{
if
n
>
0
{
if
n
>
0
{
slog
.
Debug
(
fmt
.
Sprintf
(
"setting limit to %d"
,
n
))
g
.
weight
=
g
.
max_weight
/
n
g
.
weight
=
g
.
max_weight
/
n
}
}
}
}
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