Skip to content
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

PHP: Improve the performance for Go to Declaration #6712

Conversation

junichi11
Copy link
Member

- apache#3933
- apache#6634
- Don't add empty type names to avoid getting types from an index using them
@junichi11 junichi11 added PHP [ci] enable extra PHP tests (php/php.editor) ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Nov 17, 2023
@junichi11 junichi11 added this to the NB21 milestone Nov 17, 2023
@terax6669
Copy link

terax6669 commented Nov 17, 2023

Compared against 20-rc4, this new build breaks refactoring.
image

@junichi11
Copy link
Member Author

junichi11 commented Nov 17, 2023

this new build breaks refactoring.

I'm not sure if you don't write what you are doing exactly. (I can't reproduce it.)

@terax6669
Copy link

terax6669 commented Nov 17, 2023

Try to rename a class or a property in the project I sent you for testing.

I'm using the dev build now and I can see that alt+f7 (see usages) is not working as well, disappeared from the context menu.

@terax6669
Copy link

Nevermind, after going into options NetBeans did some PHP initialization and it's working now.

@terax6669
Copy link

terax6669 commented Nov 17, 2023

I keep using the dev build throughout the day and I just noticed a red icon on my status bar. I don't know when it occured and if it's related to the PR, but I'll paste my IDE log here. The exception appears a few times in the log.

image

IDE log
WARNING [org.netbeans.modules.csl.hints.infrastructure.SuggestionsTask]
java.lang.NullPointerException: Cannot invoke "org.openide.filesystems.FileObject.canWrite()" because "fileObject" is null
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.visit(IntroduceSuggestion.java:291)
	at org.netbeans.modules.php.editor.parser.astnodes.FieldAccess.accept(FieldAccess.java:58)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:786)
	at org.netbeans.modules.php.editor.parser.astnodes.ArrayDimension.accept(ArrayDimension.java:64)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:158)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:171)
	at org.netbeans.modules.php.editor.parser.astnodes.ArrayAccess.accept(ArrayAccess.java:63)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:182)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:199)
	at org.netbeans.modules.php.editor.parser.astnodes.Assignment.accept(Assignment.java:105)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:340)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:370)
	at org.netbeans.modules.php.editor.parser.astnodes.ExpressionStatement.accept(ExpressionStatement.java:51)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:150)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:212)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:237)
	at org.netbeans.modules.php.editor.parser.astnodes.Block.accept(Block.java:70)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:422)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:454)
	at org.netbeans.modules.php.editor.parser.astnodes.IfStatement.accept(IfStatement.java:85)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:150)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:212)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:237)
	at org.netbeans.modules.php.editor.parser.astnodes.Block.accept(Block.java:70)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:371)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:398)
	at org.netbeans.modules.php.editor.parser.astnodes.ForEachStatement.accept(ForEachStatement.java:96)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:150)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:212)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:237)
	at org.netbeans.modules.php.editor.parser.astnodes.Block.accept(Block.java:70)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:422)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:454)
	at org.netbeans.modules.php.editor.parser.astnodes.IfStatement.accept(IfStatement.java:85)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:150)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:212)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:237)
	at org.netbeans.modules.php.editor.parser.astnodes.Block.accept(Block.java:70)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:396)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:419)
	at org.netbeans.modules.php.editor.parser.astnodes.FunctionDeclaration.accept(FunctionDeclaration.java:144)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:485)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:531)
	at org.netbeans.modules.php.editor.parser.astnodes.MethodDeclaration.accept(MethodDeclaration.java:73)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:150)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:212)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:237)
	at org.netbeans.modules.php.editor.parser.astnodes.Block.accept(Block.java:70)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:252)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:279)
	at org.netbeans.modules.php.editor.parser.astnodes.ClassDeclaration.accept(ClassDeclaration.java:140)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:150)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:212)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:237)
	at org.netbeans.modules.php.editor.parser.astnodes.Block.accept(Block.java:70)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:686)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:143)
	at org.netbeans.modules.php.editor.parser.astnodes.NamespaceDeclaration.accept(NamespaceDeclaration.java:88)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:143)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceFixVisitor.scan(IntroduceSuggestion.java:185)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.scan(DefaultVisitor.java:150)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor.visit(DefaultVisitor.java:517)
	at org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultTreePathVisitor.visit(DefaultTreePathVisitor.java:573)
	at org.netbeans.modules.php.editor.parser.astnodes.Program.accept(Program.java:67)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion.invoke(IntroduceSuggestion.java:146)
	at org.netbeans.modules.php.editor.verification.PHPHintsProvider$RulesRunnerImpl.adjustAndInvoke(PHPHintsProvider.java:221)
	at org.netbeans.modules.php.editor.verification.PHPHintsProvider$RulesRunnerImpl.run(PHPHintsProvider.java:202)
	at org.netbeans.modules.php.editor.verification.PHPHintsProvider.computeSuggestions(PHPHintsProvider.java:102)
	at org.netbeans.modules.csl.hints.infrastructure.SuggestionsTask$1.run(SuggestionsTask.java:131)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:586)
	at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:132)
	at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:116)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:181)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:178)
	at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:153)
	at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:335)
	at org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(DataObjectEnvFactory.java:118)
	at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:67)
	at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:178)
Caused: org.netbeans.modules.parsing.spi.ParseException
	at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:186)
	at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:83)
[catch] at org.netbeans.modules.csl.hints.infrastructure.SuggestionsTask.run(SuggestionsTask.java:97)
	at org.netbeans.modules.csl.hints.infrastructure.SuggestionsTask.run(SuggestionsTask.java:54)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:561)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:786)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:288)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
	at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1420)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2035)

@junichi11
Copy link
Member Author

junichi11 commented Nov 18, 2023

@terax6669 It's not related to this. So, could you report it as a new issue? (But it's strange... NPE should not occur there...)

@tmysik
Copy link
Member

tmysik commented Nov 18, 2023

@terax6669

Several unexpected exceptions can happen sooner or later when using the dev builds of NetBeans. From time to time, it could be a good idea to (a) download a fresh build of NetBeans from the website and/or (b) clean (delete) the userdir (please note that you will lose your configuration, so using configuration export and import might be useful).

Copy link
Member

@tmysik tmysik left a comment

Choose a reason for hiding this comment

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

Harmless checks, I would say.

@junichi11
Copy link
Member Author

@tmysik Thank you for your review! I'll wait a little while because someone else might test it with the dev version.
https://github.com/apache/netbeans/suites/18271218545/artifacts/1056392947

@tmysik
Copy link
Member

tmysik commented Nov 18, 2023

@junichi11 Sure, up to you, of course 👍

@czukowski
Copy link
Contributor

@junichi11 I'm testing it with a project containing 50k+ PHP classes, the navigation is instantaneous, brilliant! I haven't seen any issues with it so far. If there's still a chance to squeeze this into NB20, I'd say go for it, the improvement is too large to ignore 😁

Thanks for all the hard work!

@KacerCZ
Copy link
Contributor

KacerCZ commented Nov 20, 2023

@junichi11 Today I was using dev build with this patch for regular development, cache was cleared before starting.
Navigation was faster than in 20-rc4 on same project.
Thank you for your work.

@czukowski Unless some critical bug is found in 20-rc4, no more changes will be merged.

@junichi11
Copy link
Member Author

junichi11 commented Nov 20, 2023

@terax6669 @czukowski @KacerCZ Thank you for testing it!

the navigation is instantaneous, brilliant! I haven't seen any issues with it so far.

Navigation was faster than in 20-rc4 on same project.

Great to hear!

If there's still a chance to squeeze this into NB20

Unfortunately, we cannot merge this into NB20. (I wish I could have fixed it sooner, but it was too late.)
At least, we can merge it into the next version :)

@czukowski
Copy link
Contributor

I guess I'll hold onto this dev build then, for the time being 😊

@haidubogdan
Copy link

On windows 11 with medium-large sized projects
I'm not seeing any issues so far. It seems stable, the declaration info, find usage, go to method actions are more consistent overall.

For me the indexing process seems to be a little slower (maybe as a dev build the application doesn't use all the processor threads ? or something has changed on nb 20 compared to nb 19).
The same slowness is on changing git branches (reindex), in the sense that it takes some time until the declaration origin of methods or class is discovered by the project.

I don't think the slowness is related to the fix, but I would have to wait for the release of netbeans 20 to compare with it.

@junichi11 junichi11 removed the ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) label Nov 23, 2023
@junichi11
Copy link
Member Author

Thank you, guys! Merging.

@junichi11 junichi11 merged commit 0b3757b into apache:php-nb21-features Nov 23, 2023
34 checks passed
@junichi11 junichi11 deleted the php-gh-3933-6634-improve-gotodecl branch November 23, 2023 10:29
@mvorisek
Copy link

mvorisek commented Dec 3, 2023

Can a nb21 module be copied into nb20 install, is the API compatible/standardized?

@junichi11
Copy link
Member Author

NB21 is the next release version. Please use it as it is without copying it into NB20 when NB21 is released.

@mvorisek
Copy link

mvorisek commented Dec 4, 2023

I know. My question is if the (fixed) nb21 php module from nightly build can be used with regular nb20 install.

@junichi11
Copy link
Member Author

I'm not sure whether it works correctly. If you want to do it, please do it at your own risk.
Usually, in such a case, please use the dev build version (after the php-nb21-features branch is merged into the master). Or, please wait until NB21 is released.

@tmysik
Copy link
Member

tmysik commented Dec 4, 2023

@mvorisek

In short - it should not work (once a release is done, all module versions and dependencies are increased, typically). However, as @junichi11 wrote, you should be able to download the fresh dev build, that now contains just a minimum changes in comparison to the latest release (yes, I noticed the bug you just reported).

Please note that the auto-update in dev builds can be broken; this is expected and if this happens to you, simply download a new, fresh build, it should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants