Skip to content

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Dec 9, 2022

the changes mainly prevent excessive use of PCRE on windows. this leads to a small performance improvement of ~3%.

more suprising is blackfire reporting a 56% improvement on memory usage (830 MB instead of 1.9 GB).

grafik

tested on windows 11

php -v
PHP 8.1.2 (cli) (built: Jan 19 2022 10:13:52) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with blackfire v1.76.0~win-x64-non_zts81, https://blackfire.io, by Blackfire

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved this normalization below the early return, to prevent unnecessary work

Copy link
Contributor Author

@staabm staabm Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on windows we now take this fast path and prevent PCRE usage for regular paths starting with C:\\

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about other drive letters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you "ok" with allowing any uppercase character?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but I feel like there has to be a better way other than comparing letters as if they were numbers :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt about using ord()? :)

to be honest, I don't like both ways. using regex would work, but we wanne be fast, right? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, another idea. now using range()

@staabm staabm marked this pull request as ready for review December 9, 2022 15:21
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about other drive letters?

@staabm staabm force-pushed the fast-normalize branch 4 times, most recently from e8120e9 to da764b1 Compare December 10, 2022 09:16
@staabm
Copy link
Contributor Author

staabm commented Dec 10, 2022

@ondrejmirtes any reasons this was not merged yet? the memory improvement is even more valuable then the time improvement IMO (less likely the process needs to go to swap)

@ondrejmirtes
Copy link
Member

I think you're overthinking it - what about not checking the letter at all and just checking that 2nd and 3rd character is :\ ?

@staabm
Copy link
Contributor Author

staabm commented Dec 10, 2022

I am fine with that, too. here we go.

@ondrejmirtes ondrejmirtes merged commit d00f0de into phpstan:1.9.x Dec 10, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the fast-normalize branch December 10, 2022 12:22
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