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

Check for HAM/config provider more efficiently #18399

Merged
merged 8 commits into from
Dec 7, 2021

Conversation

jdmcclur
Copy link
Member

@jdmcclur jdmcclur commented Sep 1, 2021

When enabling mp-4.0 there is a small regression compared to mp-3.3 due to bringing in appsecurity-3.0 and needing to check for jaspic. This is an attempt to address that in BuildBridgeIfNeeded.

  1. Checking for getModulePropertiesUtils().isHttpAuthenticationMechanism() first before the getConfigProvider call, because it is faster (see 2) and can avoid the sync on the whole method.
  2. Caching the results of isHttpAuthenticationMechanism() true/false so it doesn't have to check every time
  3. Updating the unit tests to work with these changes.

@jdmcclur jdmcclur self-assigned this Sep 1, 2021
@jdmcclur
Copy link
Member Author

jdmcclur commented Sep 1, 2021

#build

@LibbyBot
Copy link

LibbyBot commented Sep 1, 2021

Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_MGTioAsrEeygdL3FgLlrXw

Target locations of links might be accessible only to IBM employees.

@LibbyBot
Copy link

LibbyBot commented Sep 1, 2021

@LibbyBot
Copy link

LibbyBot commented Sep 2, 2021

The build jdmcclur-18399-20210901-1453
https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_MGTioAsrEeygdL3FgLlrXw
completed and has errors or failures.

For help analyzing your personal build, go to https://cognitive.hursley.ibm.com/buildAnalysis.html?uuid=_MGTioAsrEeygdL3FgLlrXw

@jdmcclur
Copy link
Member Author

A lot of FATS failed, so may need to rethink this - haven't had time to investigate yet.

@jdmcclur
Copy link
Member Author

jdmcclur commented Oct 6, 2021

#build

@LibbyBot
Copy link

LibbyBot commented Oct 6, 2021

Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_pD3mcCa8EeyWeMDU9jagxQ

Target locations of links might be accessible only to IBM employees.

@jdmcclur
Copy link
Member Author

jdmcclur commented Oct 6, 2021

#libby

@LibbyBot
Copy link

LibbyBot commented Oct 7, 2021

The build jdmcclur-18399-20211006-0953
https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_pD3mcCa8EeyWeMDU9jagxQ
completed successfully!

@jdmcclur jdmcclur requested review from jhanders34 and ayoho October 7, 2021 18:10
@ayoho ayoho requested review from utle and removed request for ayoho October 7, 2021 18:17
Copy link
Member

@jhanders34 jhanders34 left a comment

Choose a reason for hiding this comment

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

Yeah the code will work this way, but I would suggest getting rid of the returns. Instead of return on the first one, just do an else to the rest of it where it is doing the synchronized. Similarly I would suggest that for the since return statement that you swap the if condition and put the remaining logic in the == null condition instead. The code will be much cleaner.

Can you also do a double check synchronize to avoid the synchronization if it is already set?

        AuthConfigProvider authConfigProvider = providerFactory.getConfigProvider(JASPIC_LAYER_HTTP_SERVLET, appContext, (RegistrationListener) null);
        if (authConfigProvider == null) {
            // Synchronized since checking if there is a provider and registering one need to be done as a single atomic operation.
            synchronized (this) {
                authConfigProvider = providerFactory.getConfigProvider(JASPIC_LAYER_HTTP_SERVLET, appContext, (RegistrationListener) null);
                if (authConfigProvider == null) {

HttpAuthenticationMechanism ham = getHttpAuthenticationMechanism(false);
if (ham != null) {
return true;
if (isHam == null) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this will work. The call for getting the http authentication mechanism is on a ThreadLocal so it can be different per thread. Also this class is a singleton. A new instance would not be created when there is a config change that could change the http authentication mechanism.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, bummer. If we can't speed up this check, not sure the other change is really worth it. It would probably still help my scenario, but would slow down a scenario where there is an authConfigProvider I think.

@jdmcclur
Copy link
Member Author

jdmcclur commented Dec 2, 2021

@jhanders34 @vijaysun-omr @utle

I looked at this some more. It looks like the change helps my case (no jaspic/authconfigprovider) by ~1.5%. However, I think it would regress a scenario where there is an authconfigprovider configured by ~0.5%. So, the question is, do many customers use jaspic? Is this a big deal to regress it? Thoughts?

@utle
Copy link
Member

utle commented Dec 3, 2021

We are not aware of that many customers using the jaspic provider. Can you give a little detail why we regress for jaspic customers?

@jdmcclur
Copy link
Member Author

jdmcclur commented Dec 3, 2021

@utle - Yes, because of the way I switched things around to avoid the sync lock on the method, it now always does this check first getModulePropertiesUtils().isHttpAuthenticationMechanism()

Before, it didn't do this check if an authconfigprovider is already in the cache. This is a pretty minor regression though. Maybe 0.5%.

@utle
Copy link
Member

utle commented Dec 3, 2021

@utle - Yes, because of the way I switched things around to avoid the sync lock on the method, it now always does this check first getModulePropertiesUtils().isHttpAuthenticationMechanism()

Before, it didn't do this check if an authconfigprovider is already in the cache. This is a pretty minor regression though. Maybe 0.5%.

I am ok with the minor regression since we do not have that many customer using JASPI provider.

@jdmcclur
Copy link
Member Author

jdmcclur commented Dec 6, 2021

#libby

@jdmcclur
Copy link
Member Author

jdmcclur commented Dec 6, 2021

#build

@LibbyBot
Copy link

LibbyBot commented Dec 6, 2021

Code analysis and actions

DO NOT DELETE THIS COMMENT.
  • 1 product code files were changed.
  • Please describe in a separate comment how you tested your changes.

@LibbyBot
Copy link

LibbyBot commented Dec 6, 2021

Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_UfyIIFawEeyWaZwSyDrk3A

Target locations of links might be accessible only to IBM employees.

@OpenLiberty OpenLiberty deleted a comment from jdmcclur Dec 6, 2021
@LibbyBot
Copy link

LibbyBot commented Dec 7, 2021

The build jdmcclur-18399-20211206-1015
https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_UfyIIFawEeyWaZwSyDrk3A
completed successfully!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants