mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
Add four extra fields to gc_status() (#9336)
- running: true if garbage collection is currently running - protected: true if the garbage collector is protected and root additions are forbidden - full: true if the garbage collector buffer size exceeds GC_MAX_BUF_SIZE - buffer_size: current garbage collector buffer size Documentation for existing fields: - runs: the number of times the garbage collector has been run - collected: the number of objects collected - threshold: the number of roots in the buffer which will trigger garbage collection - roots: the current number of roots in the buffer Updated manual example output: array(8) { ["running"]=> bool(false) ["protected"]=> bool(false) ["full"]=> bool(false) ["runs"]=> int(5) ["collected"]=> int(100002) ["threshold"]=> int(50001) ["buffer_size"]=> int(131072) ["roots"]=> int(0) }
This commit is contained in:
parent
db012a8ba7
commit
b8811d4ff1
@ -18,7 +18,7 @@ static const func_info_t func_infos[] = {
|
|||||||
F1("get_defined_constants", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY),
|
F1("get_defined_constants", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY),
|
||||||
F1("debug_backtrace", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY),
|
F1("debug_backtrace", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY),
|
||||||
F1("get_extension_funcs", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
|
F1("get_extension_funcs", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
|
||||||
F1("gc_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG),
|
F1("gc_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_FALSE|MAY_BE_ARRAY_OF_TRUE),
|
||||||
F1("bcadd", MAY_BE_STRING),
|
F1("bcadd", MAY_BE_STRING),
|
||||||
F1("bcsub", MAY_BE_STRING),
|
F1("bcsub", MAY_BE_STRING),
|
||||||
F1("bcmul", MAY_BE_STRING),
|
F1("bcmul", MAY_BE_STRING),
|
||||||
|
@ -13,23 +13,39 @@ gc_collect_cycles();
|
|||||||
var_dump(gc_status());
|
var_dump(gc_status());
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
array(4) {
|
array(8) {
|
||||||
|
["running"]=>
|
||||||
|
bool(false)
|
||||||
|
["protected"]=>
|
||||||
|
bool(false)
|
||||||
|
["full"]=>
|
||||||
|
bool(false)
|
||||||
["runs"]=>
|
["runs"]=>
|
||||||
int(0)
|
int(0)
|
||||||
["collected"]=>
|
["collected"]=>
|
||||||
int(0)
|
int(0)
|
||||||
["threshold"]=>
|
["threshold"]=>
|
||||||
int(10001)
|
int(10001)
|
||||||
|
["buffer_size"]=>
|
||||||
|
int(16384)
|
||||||
["roots"]=>
|
["roots"]=>
|
||||||
int(1)
|
int(1)
|
||||||
}
|
}
|
||||||
array(4) {
|
array(8) {
|
||||||
|
["running"]=>
|
||||||
|
bool(false)
|
||||||
|
["protected"]=>
|
||||||
|
bool(false)
|
||||||
|
["full"]=>
|
||||||
|
bool(false)
|
||||||
["runs"]=>
|
["runs"]=>
|
||||||
int(1)
|
int(1)
|
||||||
["collected"]=>
|
["collected"]=>
|
||||||
int(1)
|
int(1)
|
||||||
["threshold"]=>
|
["threshold"]=>
|
||||||
int(10001)
|
int(10001)
|
||||||
|
["buffer_size"]=>
|
||||||
|
int(16384)
|
||||||
["roots"]=>
|
["roots"]=>
|
||||||
int(0)
|
int(0)
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,21 @@ for ($j = 0; $j < 10; $j++) {
|
|||||||
var_dump(gc_status());
|
var_dump(gc_status());
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
array(4) {
|
array(8) {
|
||||||
|
["running"]=>
|
||||||
|
bool(false)
|
||||||
|
["protected"]=>
|
||||||
|
bool(false)
|
||||||
|
["full"]=>
|
||||||
|
bool(false)
|
||||||
["runs"]=>
|
["runs"]=>
|
||||||
int(10)
|
int(10)
|
||||||
["collected"]=>
|
["collected"]=>
|
||||||
int(25000)
|
int(25000)
|
||||||
["threshold"]=>
|
["threshold"]=>
|
||||||
int(10001)
|
int(10001)
|
||||||
|
["buffer_size"]=>
|
||||||
|
int(16384)
|
||||||
["roots"]=>
|
["roots"]=>
|
||||||
int(10000)
|
int(10000)
|
||||||
}
|
}
|
||||||
|
@ -140,9 +140,13 @@ ZEND_FUNCTION(gc_status)
|
|||||||
|
|
||||||
array_init_size(return_value, 3);
|
array_init_size(return_value, 3);
|
||||||
|
|
||||||
|
add_assoc_bool_ex(return_value, "running", sizeof("running")-1, status.active);
|
||||||
|
add_assoc_bool_ex(return_value, "protected", sizeof("protected")-1, status.gc_protected);
|
||||||
|
add_assoc_bool_ex(return_value, "full", sizeof("full")-1, status.full);
|
||||||
add_assoc_long_ex(return_value, "runs", sizeof("runs")-1, (long)status.runs);
|
add_assoc_long_ex(return_value, "runs", sizeof("runs")-1, (long)status.runs);
|
||||||
add_assoc_long_ex(return_value, "collected", sizeof("collected")-1, (long)status.collected);
|
add_assoc_long_ex(return_value, "collected", sizeof("collected")-1, (long)status.collected);
|
||||||
add_assoc_long_ex(return_value, "threshold", sizeof("threshold")-1, (long)status.threshold);
|
add_assoc_long_ex(return_value, "threshold", sizeof("threshold")-1, (long)status.threshold);
|
||||||
|
add_assoc_long_ex(return_value, "buffer_size", sizeof("buffer_size")-1, (long)status.buf_size);
|
||||||
add_assoc_long_ex(return_value, "roots", sizeof("roots")-1, (long)status.num_roots);
|
add_assoc_long_ex(return_value, "roots", sizeof("roots")-1, (long)status.num_roots);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
@ -194,7 +194,7 @@ function gc_enable(): void {}
|
|||||||
function gc_disable(): void {}
|
function gc_disable(): void {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, int>
|
* @return array<string, int|bool>
|
||||||
* @refcount 1
|
* @refcount 1
|
||||||
*/
|
*/
|
||||||
function gc_status(): array {}
|
function gc_status(): array {}
|
||||||
|
2
Zend/zend_builtin_functions_arginfo.h
generated
2
Zend/zend_builtin_functions_arginfo.h
generated
@ -1,5 +1,5 @@
|
|||||||
/* This is a generated file, edit the .stub.php file instead.
|
/* This is a generated file, edit the .stub.php file instead.
|
||||||
* Stub hash: 80355bb52d643177e3a661a515d9ea915bd1e2fc */
|
* Stub hash: 73e9ef76bde5ab44254185175d4d8dae2e797d12 */
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_version, 0, 0, IS_STRING, 0)
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_version, 0, 0, IS_STRING, 0)
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
|
@ -1675,9 +1675,13 @@ finish:
|
|||||||
|
|
||||||
ZEND_API void zend_gc_get_status(zend_gc_status *status)
|
ZEND_API void zend_gc_get_status(zend_gc_status *status)
|
||||||
{
|
{
|
||||||
|
status->active = GC_G(gc_active);
|
||||||
|
status->gc_protected = GC_G(gc_protected);
|
||||||
|
status->full = GC_G(gc_full);
|
||||||
status->runs = GC_G(gc_runs);
|
status->runs = GC_G(gc_runs);
|
||||||
status->collected = GC_G(collected);
|
status->collected = GC_G(collected);
|
||||||
status->threshold = GC_G(gc_threshold);
|
status->threshold = GC_G(gc_threshold);
|
||||||
|
status->buf_size = GC_G(buf_size);
|
||||||
status->num_roots = GC_G(num_roots);
|
status->num_roots = GC_G(num_roots);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,13 @@
|
|||||||
BEGIN_EXTERN_C()
|
BEGIN_EXTERN_C()
|
||||||
|
|
||||||
typedef struct _zend_gc_status {
|
typedef struct _zend_gc_status {
|
||||||
|
bool active;
|
||||||
|
bool gc_protected;
|
||||||
|
bool full;
|
||||||
uint32_t runs;
|
uint32_t runs;
|
||||||
uint32_t collected;
|
uint32_t collected;
|
||||||
uint32_t threshold;
|
uint32_t threshold;
|
||||||
|
uint32_t buf_size;
|
||||||
uint32_t num_roots;
|
uint32_t num_roots;
|
||||||
} zend_gc_status;
|
} zend_gc_status;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user