作者:odile微笑头 | 来源:互联网 | 2024-12-09 19:47
Thispullrequestaimstooptimizethenpminstallretrytimeinbranch0.7,reducingdelayscausedbylongtimeoutswhennonetworkconnectionisavailable.
Purpose of This Pull Request
This pull request targets branch 0.7 and addresses the issue of excessive delay during npm install when the machine is not connected to any network. The root cause is the lengthy retry timeout configured for npm install operations. This PR introduces a reduction in the retry timeout to mitigate these delays. It is related to the master branch PR: https://github.com/apache/zeppelin/pull/2095.
Type of Pull Request
Enhancement
Jira Issue
https://issues.apache.org/jira/browse/ZEPPELIN-2094
Testing Instructions
To test this change, you need to have at least one Helium visualization enabled. The specific changes can be found on line 221 of the file zeppelin-zengine/org.apache.zeppelin.helium.HeliumVisualizationFactory.java
.
First, configure the npm install command as follows:
1 | String commandForNpmInstall = "install --loglevel=error"; |
Then, disconnect from all network connections and perform a build and run operation.
Next, modify the command to include custom retry parameters:
1 2 3 4 | String commandForNpmInstall = String.format("install --fetch-retries=%d --fetch-retry-factor=%d "+ "--fetch-retry-mintimeout=%d", FETCH_RETRY_COUNT, FETCH_RETRY_FACTOR_COUNT, FETCH_RETRY_MIN_TIMEOUT); |
Again, ensure there is no network connection, and then build and run the application.
Additionally, perform the same steps on line 345, where an npm install operation for a specific artifact is executed.
Explanation of Parameters
The following table explains the impact of the changes made to the retry parameters:
Description | Before | After |
---|
Condition | npm's default settings | Custom settings |
Random factor | False = 1 | False = 1 |
Retry count | 2 | 2 |
Minimum timeout (sec) | 10 | 5 |
Maximum timeout (sec) | 60 | 60 |
Factor | 10 | 1 |
First retry calculation | Math.round(1 * 10 * 10^1) | Math.round(1 * 5 * 1^1) |
First retry result (approx.) | 100 sec | 5 sec |
Second retry calculation | Math.min(Math.round(1 * 10 * 10^2), 60) | Math.min(Math.round(1 * 5 * 1^2), 60) |
Second retry result (approx.) | 60 sec | 5 sec |
Total waiting time (approx.) | 160 sec | 10 sec |
These changes significantly reduce the total waiting time for npm install operations when no network is available.
Screenshots
Below are screenshots comparing the behavior before and after the changes:
Before | After |
---|
Image placeholder | Image placeholder |