Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
8c2fab05
Commit
8c2fab05
authored
Jul 19, 2016
by
Craig Tiller
Committed by
GitHub
Jul 19, 2016
Browse files
Options
Downloads
Plain Diff
Merge pull request #7399 from sreecha/poll_alloc_fix
Reduce the number of unnecessary allocations
parents
8bcf6c1d
69b74784
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/grpc++/impl/codegen/async_unary_call.h
+1
-1
1 addition, 1 deletion
include/grpc++/impl/codegen/async_unary_call.h
src/core/lib/iomgr/ev_poll_posix.c
+23
-7
23 additions, 7 deletions
src/core/lib/iomgr/ev_poll_posix.c
with
24 additions
and
8 deletions
include/grpc++/impl/codegen/async_unary_call.h
+
1
−
1
View file @
8c2fab05
...
@@ -65,7 +65,7 @@ class ClientAsyncResponseReader GRPC_FINAL
...
@@ -65,7 +65,7 @@ class ClientAsyncResponseReader GRPC_FINAL
const
W
&
request
)
const
W
&
request
)
:
context_
(
context
),
:
context_
(
context
),
call_
(
channel
->
CreateCall
(
method
,
context
,
cq
)),
call_
(
channel
->
CreateCall
(
method
,
context
,
cq
)),
collection_
(
new
CallOpSetCollection
)
{
collection_
(
std
::
make_shared
<
CallOpSetCollection
>
()
)
{
collection_
->
init_buf_
.
SetCollection
(
collection_
);
collection_
->
init_buf_
.
SetCollection
(
collection_
);
collection_
->
init_buf_
.
SendInitialMetadata
(
collection_
->
init_buf_
.
SendInitialMetadata
(
context
->
send_initial_metadata_
,
context
->
initial_metadata_flags
());
context
->
send_initial_metadata_
,
context
->
initial_metadata_flags
());
...
...
This diff is collapsed.
Click to expand it.
src/core/lib/iomgr/ev_poll_posix.c
+
23
−
7
View file @
8c2fab05
...
@@ -844,6 +844,11 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
...
@@ -844,6 +844,11 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
*
worker_hdl
=
&
worker
;
*
worker_hdl
=
&
worker
;
grpc_error
*
error
=
GRPC_ERROR_NONE
;
grpc_error
*
error
=
GRPC_ERROR_NONE
;
/* Avoid malloc for small number of elements. */
enum
{
inline_elements
=
96
};
struct
pollfd
pollfd_space
[
inline_elements
];
struct
grpc_fd_watcher
watcher_space
[
inline_elements
];
/* pollset->mu already held */
/* pollset->mu already held */
int
added_worker
=
0
;
int
added_worker
=
0
;
int
locked
=
1
;
int
locked
=
1
;
...
@@ -899,15 +904,23 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
...
@@ -899,15 +904,23 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
int
r
;
int
r
;
size_t
i
,
fd_count
;
size_t
i
,
fd_count
;
nfds_t
pfd_count
;
nfds_t
pfd_count
;
/* TODO(ctiller): inline some elements to avoid an allocation */
grpc_fd_watcher
*
watchers
;
grpc_fd_watcher
*
watchers
;
struct
pollfd
*
pfds
;
struct
pollfd
*
pfds
;
timeout
=
poll_deadline_to_millis_timeout
(
deadline
,
now
);
timeout
=
poll_deadline_to_millis_timeout
(
deadline
,
now
);
/* TODO(ctiller): perform just one malloc here if we exceed the inline
* case */
if
(
pollset
->
fd_count
+
2
<=
inline_elements
)
{
pfds
=
gpr_malloc
(
sizeof
(
*
pfds
)
*
(
pollset
->
fd_count
+
2
));
pfds
=
pollfd_space
;
watchers
=
gpr_malloc
(
sizeof
(
*
watchers
)
*
(
pollset
->
fd_count
+
2
));
watchers
=
watcher_space
;
}
else
{
/* Allocate one buffer to hold both pfds and watchers arrays */
const
size_t
pfd_size
=
sizeof
(
*
pfds
)
*
(
pollset
->
fd_count
+
2
);
const
size_t
watch_size
=
sizeof
(
*
watchers
)
*
(
pollset
->
fd_count
+
2
);
void
*
buf
=
gpr_malloc
(
pfd_size
+
watch_size
);
pfds
=
buf
;
watchers
=
(
void
*
)((
char
*
)
buf
+
pfd_size
);
}
fd_count
=
0
;
fd_count
=
0
;
pfd_count
=
2
;
pfd_count
=
2
;
pfds
[
0
].
fd
=
GRPC_WAKEUP_FD_GET_READ_FD
(
&
grpc_global_wakeup_fd
);
pfds
[
0
].
fd
=
GRPC_WAKEUP_FD_GET_READ_FD
(
&
grpc_global_wakeup_fd
);
...
@@ -974,8 +987,11 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
...
@@ -974,8 +987,11 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
}
}
}
}
if
(
pfds
!=
pollfd_space
)
{
/* pfds and watchers are in the same memory block pointed to by pfds */
gpr_free
(
pfds
);
gpr_free
(
pfds
);
gpr_free
(
watchers
);
}
GPR_TIMER_END
(
"maybe_work_and_unlock"
,
0
);
GPR_TIMER_END
(
"maybe_work_and_unlock"
,
0
);
locked
=
0
;
locked
=
0
;
}
else
{
}
else
{
...
...
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
sign in
to comment