Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
balloon-tx-monolith
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
Stephen D
balloon-tx-monolith
Commits
a14e6219
Commit
a14e6219
authored
1 year ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
fix slowdown bug with thousands of images
parent
53b7baaa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/img.rs
+6
-3
6 additions, 3 deletions
src/img.rs
src/main.rs
+0
-1
0 additions, 1 deletion
src/main.rs
with
6 additions
and
4 deletions
src/img.rs
+
6
−
3
View file @
a14e6219
use
image
::{
imageops
::
FilterType
,
io
::
Reader
as
ImageReader
,
ImageOutputFormat
};
use
std
::{
cmp
::
max
,
fs
,
io
::
Cursor
,
path
::
PathBuf
,
sync
::
mpsc
::
Receiver
};
use
std
::{
cmp
::
max
,
collections
::
HashSet
,
fs
,
io
::
Cursor
,
path
::
PathBuf
,
sync
::
mpsc
::
Receiver
};
const
IMG_MAX_SIZE
:
u32
=
2048
;
const
JPEG_QUALITY
:
u8
=
100
;
// let ssdv do the compression
...
...
@@ -80,6 +80,7 @@ impl ImgInfo {
pub
struct
ImgManager
{
paths
:
Vec
<
PathBuf
>
,
imgs
:
Vec
<
ImgInfo
>
,
seen_imgs
:
HashSet
<
PathBuf
>
,
// used to receive image requests, which will be sent at full resolution
rx
:
Receiver
<
u8
>
,
...
...
@@ -99,6 +100,7 @@ impl ImgManager {
Self
{
paths
,
imgs
:
vec!
[],
seen_imgs
:
HashSet
::
new
(),
rx
,
iter
:
0
,
...
...
@@ -230,19 +232,20 @@ impl ImgManager {
// only files
.filter
(|(
p
,
_
)|
p
.is_file
())
// only new files
.filter
(|(
p
,
_
)|
!
self
.
imgs
.iter
()
.any
(|
i
|
i
.path
==
p
.as_path
()
))
.filter
(|(
p
,
_
)|
!
self
.
seen_imgs
.contains
(
p
))
.collect
();
for
(
path
,
metadata
)
in
new_imgs
{
let
size_bytes
=
metadata
.len
();
self
.imgs
.push
(
ImgInfo
{
path
,
path
:
path
.clone
()
,
path_idx
:
self
.path_idx
,
size_bytes
,
txed
:
false
,
found_on_iter
:
self
.iter
,
});
self
.seen_imgs
.insert
(
path
);
}
Ok
(())
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
0
−
1
View file @
a14e6219
...
...
@@ -16,7 +16,6 @@ fn main() -> anyhow::Result<()> {
let
config
=
Config
::
load
()
?
;
let
controller
=
Controller
::
new
(
config
);
controller
.run_forever
();
Ok
(())
...
...
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