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

PiT 24.5: prepare-frontend and build-frontend seems to scan classes multiple times #19874

Closed
Tracked by #6634
manolo opened this issue Sep 3, 2024 · 3 comments · Fixed by #20148
Closed
Tracked by #6634

PiT 24.5: prepare-frontend and build-frontend seems to scan classes multiple times #19874

manolo opened this issue Sep 3, 2024 · 3 comments · Fixed by #20148

Comments

@manolo
Copy link
Member

manolo commented Sep 3, 2024

Description of the bug

prepare-frontend and build-frontend scan classes multiple times, and it probably causes wasting some seconds during the build


mvn clean package -Pproduction

[INFO] --- vaadin-maven-plugin:24.5.0.alpha14:prepare-frontend (default) @ bakery-app-starter-flow-spring ---
[INFO] Reflections took 1569 ms to scan 197 urls, producing 10632 keys and 56187 values
[INFO] Reflections took 1236 ms to scan 197 urls, producing 10632 keys and 56187 values
[INFO] Reflections took 1275 ms to scan 197 urls, producing 10632 keys and 56187 values
[INFO] Visited 120 classes. Took 358 ms.
[INFO] Copying frontend resources from jar files ...
[INFO] Visited 201 resources. Took 291 ms.

...
[INFO] --- vaadin-maven-plugin:24.5.0.alpha14:build-frontend (default) @ bakery-app-starter-flow-spring ---
[INFO] Reflections took 1252 ms to scan 197 urls, producing 10632 keys and 56187 values
[INFO] Reflections took 1135 ms to scan 197 urls, producing 10632 keys and 56187 values
[INFO] Scanning classes to find frontend configurations and dependencies...
[INFO] Visited 7475 classes. Took 7552 ms.

Expected behavior

classes are visited once per goal

Minimal reproducible example

Download and compile bakery-app-starter-flow-spring

Versions

  • Vaadin / Flow version: 24.5.0.alpha
@mcollovati
Copy link
Collaborator

This was changed time ago, to make sure that DevModeInitializer and prepare-fronted behave the same to prevent excessive server restarts during development.
IIRC, the problem was that if you have the application running through the IDE, and you do a maven compilation, then some generated frontend files were removed and not recreated, causing several reloads.

Here's the PR #19011

@mshabarov
Copy link
Contributor

We have to investigate if/how we can cache the scanning results for build-frontend.

@jorgheymans
Copy link

Here's the full picture for our build, 9 times at about 1200ms each that's noticeable in a build. Caching the scanning results can be done from maven, see https://github.com/ronmamo/reflections-maven/ for the example.

[INFO] --- vaadin:24.4.12:configure (configure) @ ims ---
[INFO] Reflections took 2346 ms to scan 321 urls, producing 17915 keys and 93773 values
[WARNING] The 'configure' goal is only meant to be used in Hilla projects with endpoints.
[ims] [INFO]
[ims] [INFO] <<< vaadin:24.4.12:prepare-frontend (default) < :configure @ ims <<<
[ims] [INFO]
[ims] [INFO]
[ims] [INFO] --- vaadin:24.4.12:prepare-frontend (default) @ ims ---
[ims] [INFO] Reflections took 1563 ms to scan 321 urls, producing 17915 keys and 93773 values
[ims] [INFO] The globally installed Node.js version 14.18.0 is older than the required minimum version 18.12.0. Using Node.js from /home/afis4/.vaadin.
[ims] [INFO] Reflections took 1203 ms to scan 321 urls, producing 17915 keys and 93773 values
[ims] [INFO] Reflections took 1246 ms to scan 321 urls, producing 17915 keys and 93773 values

[ims] [INFO] Visited 328 classes. Took 672 ms.
[ims] [INFO] Copying frontend resources from jar files ...
[ims] [INFO] Visited 347 resources. Took 250 ms.
[ims] [INFO]
[ims] [INFO] >>> vaadin:24.4.12:build-frontend (default) > :configure @ ims >>>
[INFO]
[INFO] --- vaadin:24.4.12:configure (configure) @ ims ---
[INFO] Reflections took 1244 ms to scan 321 urls, producing 17915 keys and 93773 values
[WARNING] The 'configure' goal is only meant to be used in Hilla projects with endpoints.
[ims] [INFO]
[ims] [INFO] <<< vaadin:24.4.12:build-frontend (default) < :configure @ ims <<<
[ims] [INFO]
[ims] [INFO]
[ims] [INFO] --- vaadin:24.4.12:build-frontend (default) @ ims ---
[ims] [INFO] Reflections took 1242 ms to scan 321 urls, producing 17915 keys and 93773 values
[ims] [INFO] Reflections took 1082 ms to scan 321 urls, producing 17915 keys and 93773 values

[ims] [INFO] Scanning classes to find frontend configurations and dependencies...
[ims] [INFO] Visited 7251 classes. Took 5940 ms.
[ims] [INFO] Checking if a production mode bundle build is needed
[ims] [INFO] Frontend build requested.
[ims] [INFO] Skipping npm install because the frontend packages are already installed in the folder '/home/afis4/src/acd/backends/ims/app/node_modules' and the hash in the file '/home/afis4/src/acd/backends/ims/app/node_modules/.vaadin/vaadin.json' is the same as in 'package.json'
[ims] [INFO] Copying frontend resources from jar files ...
[ims] [INFO] Visited 347 resources. Took 154 ms.
[ims] [INFO] The globally installed Node.js version 14.18.0 is older than the required minimum version 18.12.0. Using Node.js from /home/afis4/.vaadin.
[ims] [INFO] Running Vite ...
[ims] [INFO] Reflections took 1157 ms to scan 321 urls, producing 17915 keys and 93773 values
[ims] [INFO] Reflections took 1128 ms to scan 321 urls, producing 17915 keys and 93773 values

[ims] [INFO] Scanning classes to find frontend configurations and dependencies...
[ims] [INFO] Visited 7251 classes. Took 4594 ms.
[ims] [INFO] Unable to determine Vaadin version. No META-INF/maven/com.vaadin/vaadin-core/pom.properties found
[ims] [INFO] Build frontend completed in 33329 ms.
[ims] [INFO]

mcollovati added a commit that referenced this issue Oct 4, 2024
Store ClassFinder instance in project context to reuse the same instance during
maven execution.

Fixes #19874
mcollovati added a commit that referenced this issue Oct 4, 2024
Store ClassFinder instance in project context to reuse the same instance during
maven execution.

Fixes #19874
mcollovati added a commit that referenced this issue Oct 4, 2024
Creates ClassFinder once per mojo execution, preventing eccessive and
useless scans.

Fixes #19874
vaadin-bot pushed a commit that referenced this issue Oct 7, 2024
Creates ClassFinder once per mojo execution, preventing eccessive and
useless scans.

Fixes #19874
vaadin-bot added a commit that referenced this issue Oct 7, 2024
Creates ClassFinder once per mojo execution, preventing eccessive and
useless scans.

Fixes #19874

Co-authored-by: Marco Collovati <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

4 participants