mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-10-04 16:08:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3368a26ad3 | ||
|
|
5c2bb34708 | ||
|
|
9f084e151c | ||
|
|
c0d61bc6a4 | ||
|
|
ce8588ce4b | ||
|
|
6c6cb1efc1 |
@@ -1,3 +1,18 @@
|
||||
----------------------------------------------------------------------
|
||||
|
||||
LINKING EXCEPTION
|
||||
|
||||
In addition to the permissions in the GNU General Public License,
|
||||
the authors give you unlimited permission to link the compiled
|
||||
version of this library into combinations with other programs,
|
||||
and to distribute those combinations without any restriction
|
||||
coming from the use of this file. (The General Public License
|
||||
restrictions do apply in other respects; for example, they cover
|
||||
modification of the file, and distribution when not linked into
|
||||
a combined executable.)
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
|
||||
+13
-5
@@ -58,20 +58,28 @@ void uwsgi_init_cache() {
|
||||
exit(1);
|
||||
}
|
||||
uwsgi.cache_items = (struct uwsgi_cache_item *) mmap(NULL, uwsgi.cache_filesize, PROT_READ | PROT_WRITE, MAP_SHARED, cache_fd, 0);
|
||||
if (uwsgi.cache_items == MAP_FAILED) {
|
||||
uwsgi_log("Unable to mmap %llu bytes.\n", uwsgi.cache_filesize);
|
||||
uwsgi_error("mmap()");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
uwsgi_cache_fix();
|
||||
|
||||
}
|
||||
else {
|
||||
uwsgi.cache_items = (struct uwsgi_cache_item *) mmap(NULL, (sizeof(struct uwsgi_cache_item) * uwsgi.cache_max_items) + (uwsgi.cache_blocksize * uwsgi.cache_max_items), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
|
||||
ssize_t cache_size = (sizeof(struct uwsgi_cache_item) * uwsgi.cache_max_items) + (uwsgi.cache_blocksize * uwsgi.cache_max_items);
|
||||
uwsgi.cache_items = (struct uwsgi_cache_item *) mmap(NULL, cache_size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
|
||||
if (uwsgi.cache_items == MAP_FAILED) {
|
||||
uwsgi_log("Unable to mmap %llu bytes.\n", cache_size);
|
||||
uwsgi_error("mmap()");
|
||||
exit(1);
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < (int) uwsgi.cache_max_items; i++) {
|
||||
memset(&uwsgi.cache_items[i], 0, sizeof(struct uwsgi_cache_item));
|
||||
}
|
||||
}
|
||||
if (!uwsgi.cache_items) {
|
||||
uwsgi_error("mmap()");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
uwsgi.cache = mmap(NULL, uwsgi.cache_blocksize * uwsgi.cache_max_items, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../../uwsgi.h"
|
||||
#include <uwsgi.h>
|
||||
|
||||
/*
|
||||
|
||||
@@ -13,6 +13,7 @@ struct uwsgi_cheaper_busyness_global {
|
||||
uint64_t busyness_max;
|
||||
uint64_t busyness_min;
|
||||
uint64_t *last_values;
|
||||
int *was_busy;
|
||||
uint64_t tcheck;
|
||||
uint64_t last_cheaped; // last time worker was cheaped due to low busyness
|
||||
uint64_t next_cheap; // timestamp, we can cheap worker after it
|
||||
@@ -140,6 +141,9 @@ int cheaper_busyness_algo(void) {
|
||||
if (!uwsgi_cheaper_busyness_global.last_values) {
|
||||
uwsgi_cheaper_busyness_global.last_values = uwsgi_calloc(sizeof(uint64_t) * uwsgi.numproc);
|
||||
}
|
||||
if (!uwsgi_cheaper_busyness_global.was_busy) {
|
||||
uwsgi_cheaper_busyness_global.was_busy = uwsgi_calloc(sizeof(int) * uwsgi.numproc);
|
||||
}
|
||||
|
||||
// set defaults
|
||||
if (!uwsgi_cheaper_busyness_global.busyness_max) uwsgi_cheaper_busyness_global.busyness_max = 50;
|
||||
@@ -179,6 +183,10 @@ int cheaper_busyness_algo(void) {
|
||||
|
||||
if (uwsgi.workers[i+1].cheaped == 0 && uwsgi.workers[i+1].pid > 0) {
|
||||
active_workers++;
|
||||
uwsgi_cheaper_busyness_global.was_busy[i] += uwsgi.workers[i+1].busy;
|
||||
}
|
||||
else {
|
||||
uwsgi_cheaper_busyness_global.was_busy[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +200,19 @@ int cheaper_busyness_algo(void) {
|
||||
for (i = 0; i < uwsgi.numproc; i++) {
|
||||
if (uwsgi.workers[i+1].cheaped == 0 && uwsgi.workers[i+1].pid > 0) {
|
||||
uint64_t percent = (( (uwsgi.workers[i+1].running_time-uwsgi_cheaper_busyness_global.last_values[i])*100)/t);
|
||||
if (percent > 100) percent = 100;
|
||||
if (percent > 100) {
|
||||
percent = 100;
|
||||
}
|
||||
else if (uwsgi.workers[i+1].running_time-uwsgi_cheaper_busyness_global.last_values[i] == 0 && percent == 0 && uwsgi_cheaper_busyness_global.was_busy[i] > 0) {
|
||||
// running_time did not change but workers were busy
|
||||
// this means that workers had response times > busyness check interval
|
||||
if (uwsgi_cheaper_busyness_global.verbose) {
|
||||
uwsgi_log("[busyness] worker %d was busy %d time(s) in last cycle but no request was completed during this time, marking as 100%% busy\n",
|
||||
i+1, uwsgi_cheaper_busyness_global.was_busy[i]);
|
||||
}
|
||||
percent = 100;
|
||||
}
|
||||
uwsgi_cheaper_busyness_global.was_busy[i] = 0;
|
||||
total_busyness += percent;
|
||||
if (uwsgi_cheaper_busyness_global.verbose && active_workers > 1)
|
||||
uwsgi_log("[busyness] worker nr %d %llus average busyness is at %llu%%\n",
|
||||
|
||||
@@ -419,6 +419,7 @@ PyObject *py_uwsgi_register_rpc(PyObject * self, PyObject * args) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(func);
|
||||
|
||||
if (uwsgi_register_rpc(name, 0, argc, func)) {
|
||||
return PyErr_Format(PyExc_ValueError, "unable to register rpc function");
|
||||
@@ -454,6 +455,8 @@ PyObject *py_uwsgi_register_signal(PyObject * self, PyObject * args) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(handler);
|
||||
|
||||
if (uwsgi_register_signal(uwsgi_signal, signal_kind, handler, 0)) {
|
||||
return PyErr_Format(PyExc_ValueError, "unable to register signal");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user