Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
installer
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
Container Registry
Model registry
Operate
Environments
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
redox-os
installer
Commits
7b24f868
Verified
Commit
7b24f868
authored
2 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Optimization for block aligned I/O in disk wrapper
parent
0b4f836f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/disk_wrapper.rs
+16
-2
16 additions, 2 deletions
src/disk_wrapper.rs
with
16 additions
and
2 deletions
src/disk_wrapper.rs
+
16
−
2
View file @
7b24f868
...
@@ -46,16 +46,30 @@ impl DiskWrapper {
...
@@ -46,16 +46,30 @@ impl DiskWrapper {
self
.size
self
.size
}
}
//TODO: improve performance by directly using block aligned parts of buf
fn
io
<
'a
>
(
&
mut
self
,
buf
:
&
mut
Buffer
<
'a
>
)
->
Result
<
usize
>
{
fn
io
<
'a
>
(
&
mut
self
,
buf
:
&
mut
Buffer
<
'a
>
)
->
Result
<
usize
>
{
let
buf_len
=
match
buf
{
let
buf_len
=
match
buf
{
Buffer
::
Read
(
read
)
=>
read
.len
(),
Buffer
::
Read
(
read
)
=>
read
.len
(),
Buffer
::
Write
(
write
)
=>
write
.len
(),
Buffer
::
Write
(
write
)
=>
write
.len
(),
};
};
let
block_len
:
u64
=
self
.block
.len
()
.try_into
()
.unwrap
();
// Do aligned I/O quickly
if
self
.seek
%
block_len
==
0
&&
buf_len
as
u64
%
block_len
==
0
{
self
.disk
.seek
(
SeekFrom
::
Start
(
self
.seek
))
?
;
match
buf
{
Buffer
::
Read
(
read
)
=>
{
self
.disk
.read_exact
(
read
)
?
;
return
Ok
(
read
.len
());
},
Buffer
::
Write
(
write
)
=>
{
self
.disk
.write_all
(
write
)
?
;
return
Ok
(
write
.len
());
}
}
}
let
mut
i
=
0
;
let
mut
i
=
0
;
while
i
<
buf_len
{
while
i
<
buf_len
{
let
block_len
:
u64
=
self
.block
.len
()
.try_into
()
.unwrap
();
let
block
=
self
.seek
/
block_len
;
let
block
=
self
.seek
/
block_len
;
let
offset
:
usize
=
(
self
.seek
%
block_len
)
.try_into
()
.unwrap
();
let
offset
:
usize
=
(
self
.seek
%
block_len
)
.try_into
()
.unwrap
();
let
remaining
=
buf_len
.checked_sub
(
i
)
.unwrap
();
let
remaining
=
buf_len
.checked_sub
(
i
)
.unwrap
();
...
...
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