Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
c733e399
Commit
c733e399
authored
Apr 20, 2018
by
Jason Madden
Committed by
GitHub
Apr 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1187 from gevent/static-libuv-patch
Make the libuv run QUEUE part of the loop.
parents
d5942f40
0df38a9b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
26 deletions
+57
-26
deps/README.rst
deps/README.rst
+16
-0
deps/gevent-libuv.patch
deps/gevent-libuv.patch
+29
-19
deps/libuv/include/uv-unix.h
deps/libuv/include/uv-unix.h
+3
-0
deps/libuv/src/unix/loop-watcher.c
deps/libuv/src/unix/loop-watcher.c
+9
-7
No files found.
deps/README.rst
View file @
c733e399
================================
Managing Embedded Dependencies
================================
- Modify the c-ares Makefile.in[c] to empty out the MANPAGES variables
so that we don't have to ship those in the sdist.
XXX: We need a patch for that.
Updating libuv
==============
- Apply the gevent-libuv.patch to updates of libuv.
[deps] $ patch -p0 < gevent-libuv.patch
- Clean up the libuv tree:
- rm -rf libuv/.github
- rm -rf libuv/docs
- rm -rf libuv/samples
- rm -rf libuv/test
- rm -rf libuv/tools
- Create new patches by downloading the source tarball:
[deps] $ tar -xf libuv-v1.20.1.tar.gz
[deps] $ diff -r -u libuv-v1.20.1/ libuv > gevent-libuv.patch
deps/gevent-libuv.patch
View file @
c733e399
diff --git a/deps/libuv/src/unix/loop-watcher.c b/deps/libuv/src/unix/loop-watcher.c
index 340bb0df..ff92c8e3 100644
--- a/deps/libuv/src/unix/loop-watcher.c
+++ b/deps/libuv/src/unix/loop-watcher.c
@@ -22,6 +22,17 @@
diff -r -u libuv-v1.20.1/include/uv-unix.h libuv/include/uv-unix.h
--- libuv-v1.20.1/include/uv-unix.h 2018-04-18 08:18:43.000000000 -0500
+++ libuv/include/uv-unix.h 2018-04-20 12:16:19.000000000 -0500
@@ -207,8 +207,11 @@
uv_handle_t* closing_handles; \
void* process_handles[2]; \
void* prepare_handles[2]; \
+ void* prepare_handles_queue[2]; \
void* check_handles[2]; \
+ void* check_handles_queue[2]; \
void* idle_handles[2]; \
+ void* idle_handles_queue[2]; \
void* async_handles[2]; \
void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \
uv__io_t async_io_watcher; \
diff -r -u libuv-v1.20.1/src/unix/loop-watcher.c libuv/src/unix/loop-watcher.c
--- libuv-v1.20.1/src/unix/loop-watcher.c 2018-04-18 08:18:43.000000000 -0500
+++ libuv/src/unix/loop-watcher.c 2018-04-20 13:59:36.000000000 -0500
@@ -22,6 +22,20 @@
#include "uv.h"
#include "internal.h"
+/*
+ * gevent: Fix for https://github.com/gevent/gevent/issues/1126
+ *
+ * Using a stack-based queue variable in uv__run_* badly breaks
+ * for certain stack manipulations when greenlets switch.
+ * Windows keeps the stack in the loop. In ordor to minimize changes,
+ * we move the stack to the heap by changing just this file. We can't
+ * use global static variables because of multiple threads.
+ * Using a stack-based queue variable in uv__run_* badly breaks for
+ * certain stack manipulations when greenlets switch. Windows keeps
+ * the stack in the loop. We originally used malloc/free in uv__run_
+ * to avoid changing any files but this one, but that benchmarked
+ * fairly slow and widely variable across processes
+ * (https://groups.google.com/d/msg/libuv/8BxOk40Dii4/Ke1yotOQBwAJ) so
+ * we moved them to the loop. We can't use global static variables
+ * because of multiple threads.
+ */
+#include <stdlib.h>
+
#define UV_LOOP_WATCHER_DEFINE(name, type) \
int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \
uv__handle_init(loop, (uv_handle_t*)handle, UV_##type); \
@@ -47,1
6 +58,17
@@
@@ -47,1
0 +61,10
@@
\
void uv__run_##name(uv_loop_t* loop) { \
uv_##name##_t* h; \
- QUEUE queue; \
+ QUEUE* queue =
malloc(sizeof(QUEUE));
\
+ QUEUE* queue =
&loop->name##_handles_queue;
\
QUEUE* q; \
- QUEUE_MOVE(&loop->name##_handles, &queue); \
- while (!QUEUE_EMPTY(&queue)) { \
...
...
@@ -34,10 +51,3 @@ index 340bb0df..ff92c8e3 100644
q = QUEUE_HEAD(&queue); \
h = QUEUE_DATA(q, uv_##name##_t, queue); \
QUEUE_REMOVE(q); \
QUEUE_INSERT_TAIL(&loop->name##_handles, q); \
h->name##_cb(h); \
} \
+ free(queue); \
} \
\
void uv__##name##_close(uv_##name##_t* handle) { \
deps/libuv/include/uv-unix.h
View file @
c733e399
...
...
@@ -207,8 +207,11 @@ typedef struct {
uv_handle_t* closing_handles; \
void* process_handles[2]; \
void* prepare_handles[2]; \
void* prepare_handles_queue[2]; \
void* check_handles[2]; \
void* check_handles_queue[2]; \
void* idle_handles[2]; \
void* idle_handles_queue[2]; \
void* async_handles[2]; \
void (*async_unused)(void);
/* TODO(bnoordhuis) Remove in libuv v2. */
\
uv__io_t async_io_watcher; \
...
...
deps/libuv/src/unix/loop-watcher.c
View file @
c733e399
...
...
@@ -25,11 +25,14 @@
/*
* gevent: Fix for https://github.com/gevent/gevent/issues/1126
*
* Using a stack-based queue variable in uv__run_* badly breaks
* for certain stack manipulations when greenlets switch.
* Windows keeps the stack in the loop. In ordor to minimize changes,
* we move the stack to the heap by changing just this file. We can't
* use global static variables because of multiple threads.
* Using a stack-based queue variable in uv__run_* badly breaks for
* certain stack manipulations when greenlets switch. Windows keeps
* the stack in the loop. We originally used malloc/free in uv__run_
* to avoid changing any files but this one, but that benchmarked
* fairly slow and widely variable across processes
* (https://groups.google.com/d/msg/libuv/8BxOk40Dii4/Ke1yotOQBwAJ) so
* we moved them to the loop. We can't use global static variables
* because of multiple threads.
*/
#include <stdlib.h>
...
...
@@ -58,7 +61,7 @@
\
void uv__run_##name(uv_loop_t* loop) { \
uv_##name##_t* h; \
QUEUE* queue =
malloc(sizeof(QUEUE));
\
QUEUE* queue =
&loop->name##_handles_queue;
\
QUEUE* q; \
QUEUE_MOVE(&loop->name##_handles, queue); \
while (!QUEUE_EMPTY(queue)) { \
...
...
@@ -68,7 +71,6 @@
QUEUE_INSERT_TAIL(&loop->name##_handles, q); \
h->name##_cb(h); \
} \
free(queue); \
} \
\
void uv__##name##_close(uv_##name##_t* handle) { \
...
...
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