[php-src] PR #17194: Reduce gc stack usage for strings (and resources)

From: Date: Tue, 17 Dec 2024 14:35:25 +0000
Subject: [php-src] PR #17194: Reduce gc stack usage for strings (and resources)
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-30047@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/17194 Author: iluuu1994 Adding strings to the worklist is useless, because they never contribute to cycles. The assembly size on x86_64 does not change. This significantly improves performance in this synthetic benchmark by 33%. ```php function test($a) {} $a = new stdClass(); $a->self = $a; $a->prop1 = str_repeat('a', 10); $a->prop2 = str_repeat('a', 10); $a->prop3 = str_repeat('a', 10); $a->prop4 = str_repeat('a', 10); $a->prop5 = str_repeat('a', 10); $a->prop6 = str_repeat('a', 10); $a->prop7 = str_repeat('a', 10); $a->prop8 = str_repeat('a', 10); $a->prop9 = str_repeat('a', 10); $a->prop10 = str_repeat('a', 10); for ($i = 0; $i < 10_000_000; $i++) { test($a); gc_collect_cycles(); } ``` This requires adding IS_TYPE_COLLECTABLE to IS_REFERENCE_EX to ensure these values continue to be pushed onto the stack. Luckily, IS_TYPE_COLLECTABLE is currently only used in gc_check_possible_root(), where the checked value cannot be a reference. Note that this changes the output of gc_collect_cycles(). Non-cyclic, refcounted values no longer count towards the total reported values collected.

« previous php.git-pulls (#30047) next »