Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Arti
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
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Jill
Arti
Commits
26bdbc4b
Commit
26bdbc4b
authored
3 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
arti-bench: don't allocate a separate receive-buffer for each job
This makes heap profiling more viable. Closes #391.
parent
cc6ba72d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
crates/arti-bench/src/main.rs
+26
-9
26 additions, 9 deletions
crates/arti-bench/src/main.rs
with
26 additions
and
9 deletions
crates/arti-bench/src/main.rs
+
26
−
9
View file @
26bdbc4b
...
...
@@ -149,11 +149,17 @@ impl TimingSummary {
}
}
/// How much should we be willing to read at a time?
const
RECV_BUF_LEN
:
usize
=
8192
;
/// Run the timing routine
fn
run_timing
(
mut
stream
:
TcpStream
,
send
:
&
Arc
<
[
u8
]
>
,
receive
:
&
Arc
<
[
u8
]
>
)
->
Result
<
()
>
{
let
peer_addr
=
stream
.peer_addr
()
?
;
// Do this potentially costly allocation before we do all the timing stuff.
let
mut
received
=
vec!
[
0_u8
;
receive
.len
()];
let
mut
received
=
vec!
[
0_u8
;
RECV_BUF_LEN
];
let
expected_len
=
receive
.len
();
let
mut
expected
=
receive
.deref
();
let
mut
mismatch
=
false
;
let
mut
total_read
=
0
;
info!
(
"Accepted connection from {}"
,
peer_addr
);
let
accepted_ts
=
SystemTime
::
now
();
...
...
@@ -168,15 +174,26 @@ fn run_timing(mut stream: TcpStream, send: &Arc<[u8]>, receive: &Arc<[u8]>) -> R
panic!
(
"unexpected EOF"
);
}
let
first_byte_ts
=
SystemTime
::
now
();
stream
.read_exact
(
&
mut
received
[
read
..
])
?
;
if
received
[
0
..
read
]
!=
expected
[
0
..
read
]
{
mismatch
=
true
;
}
expected
=
&
expected
[
read
..
];
total_read
+=
read
;
while
total_read
<
expected_len
{
let
read
=
stream
.read
(
&
mut
received
)
?
;
if
read
==
0
{
panic!
(
"unexpected eof"
);
}
if
received
[
0
..
read
]
!=
expected
[
0
..
read
]
{
mismatch
=
true
;
}
expected
=
&
expected
[
read
..
];
total_read
+=
read
;
}
let
read_done_ts
=
SystemTime
::
now
();
info!
(
"Received {} bytes payload from {}."
,
received
.len
(),
peer_addr
);
info!
(
"Received {} bytes payload from {}."
,
total_read
,
peer_addr
);
// Check we actually got what we thought we would get.
if
received
!=
receive
.deref
()
{
if
mismatch
{
panic!
(
"Received data doesn't match expected; potential corruption?"
);
}
let
st
=
ServerTiming
{
...
...
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