Skip to content

Faster TrinaryLogic->and() #3860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2025
Merged

Faster TrinaryLogic->and() #3860

merged 1 commit into from
Mar 7, 2025

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Mar 7, 2025

Similar to #3859 this method is called super often.

we make it faster by reducing how often the php runtime needs to switch between userland code and php-src native code.
as this method is called so often, switching between userland and native code takes more time compared to the time we safe by running it natively.

before

➜  PhpSpreadsheet git:(master) ✗ hyperfine 'php ../phpstan-src/bin/phpstan analyze src/PhpSpreadsheet/Reader/Xlsx.php --debug' # after
Benchmark 1: php ../phpstan-src/bin/phpstan analyze src/PhpSpreadsheet/Reader/Xlsx.php --debug
  Time (mean ± σ):      8.775 s ±  0.011 s    [User: 8.608 s, System: 0.163 s]
  Range (min … max):    8.751 s …  8.790 s    10 runs

after

➜  PhpSpreadsheet git:(master) ✗ hyperfine 'php ../phpstan-src/bin/phpstan analyze src/PhpSpreadsheet/Reader/Xlsx.php --debug' # before
Benchmark 1: php ../phpstan-src/bin/phpstan analyze src/PhpSpreadsheet/Reader/Xlsx.php --debug
  Time (mean ± σ):      8.744 s ±  0.017 s    [User: 8.571 s, System: 0.170 s]
  Range (min … max):    8.723 s …  8.772 s    10 runs

@ondrejmirtes ondrejmirtes merged commit faef8e0 into phpstan:2.1.x Mar 7, 2025
413 of 418 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the trin-and branch March 7, 2025 09:13
@kamil-tekiela
Copy link
Contributor

Does it make any sense for the or method to be aligned with this change?

@staabm
Copy link
Contributor Author

staabm commented Mar 9, 2025

I did not yet see a profile in which or() was slow, but we could for consistency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants