Skip to content

Conversation

@jtnord
Copy link
Member

@jtnord jtnord commented Jul 21, 2025

https://issues.jenkins.io/browse/JENKINS-67829

As we do not support dynamic class unloading the mappting between a URL and a Checksum can never change for the lifetime of the JVM. That is in Jenkins we can only install new plugins, upgrades always require a restart.

To that end the Checksum cache in JarLoaderImpl always is the checksum of the file on the local side so the only way it can change is if the JVM is restarted.
Therefor we do not need to calculate it for every Channel, rather we can create it once for all Channels on a given JVM.

Testing done

  • functionally run an inbound (java -jar agent.jar) against a Jenkins that has this patch from an agent that does not
  • functionally run an inbound (java -jar agent.jar) against a Jenkins that has this patch from an agent that also has this patch

Both of the above had some extra logging in hudson.remoting.Checksum.forUrl(URL) to show when a checksum was created. Observed that without the each new agent / reconnection of the agent the method is called and with the path the method is called once per URL for the first connection since startup.

ToDo: run the ATH suite, benchmark(?), stress tests(?)

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@jtnord jtnord force-pushed the JENKINS-67829 branch 2 times, most recently from b415c7c to c16b704 Compare July 21, 2025 17:04
@jtnord jtnord force-pushed the JENKINS-67829 branch 2 times, most recently from a78d8a4 to 8c94636 Compare October 29, 2025 15:00
as we do not support dynamic class unloading a URL to a checksum can
never change for the lifetime of the JVM.  That is in Jenkins we can
only install new plugins, upgrades always require a restart.

To that end we the Checksum cache in JarLoaderImpl always is the
checksum of the file on the local side so the only way it can change
is if the JVM is restarted.
Therefor we do not need to caclulate it for every channel, rather we can
create it once for all Channels on a given JVM.
As access to CHECKSUMS and the computation of the Checksum was
non-atomic we could still have lots of threads attempting to checksum
the same jar file at startup.
Whilst the jar would likely end up in the disk cache and IO would not be
too high, the digest calculation would still occur causing wasted CPU
that could be used for other things.

Make the computation atomic wrt checking that we have the checksum
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.

1 participant