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

Improve the performance of creating/building a client instance #323

Open
tdauth opened this issue Jan 20, 2022 · 5 comments
Open

Improve the performance of creating/building a client instance #323

tdauth opened this issue Jan 20, 2022 · 5 comments
Assignees
Labels

Comments

@tdauth
Copy link

tdauth commented Jan 20, 2022

Expected Behavior

Building a client should be a fast operation since I do not expect anything to be done.

Current Behavior

The operation

com.cdancy.bitbucket.rest.BitbucketClient$Builder.build()

seems to be really slow.

Context

My application retrieves data from multiple Bitbucket repositories creating the client multiple times which apparently was the wrong approach since it is for one endpoint only. However, I am able to close the client so to write clean code I create a new client and close it afterwards.

Steps to Reproduce (for bugs)

Create many clients.

Your Environment

Anywhere I guess.

@cdancy
Copy link
Owner

cdancy commented Jan 20, 2022

multiple Bitbucket repositories

@tdauth when you say "multiple Bitbucket repositories" do you mean the same Bitbucket instance but against multiple repos within that instance or do you mean quite literally multiple Bitbucket instances you're connecting to? If the former you can just create 1 client as it's thread safe and can be shared amongst many requests/etc.

@cdancy cdancy self-assigned this Jan 20, 2022
@tdauth
Copy link
Author

tdauth commented Jan 20, 2022

Yes I can create only 1 but for the first scenario I would need many clients. I am just wondering why it is so slow.

@cdancy
Copy link
Owner

cdancy commented Jan 20, 2022

@tdauth how slow are we talking? Can you provide measureable numbers? I've never created many clients at once before but underneath it's using the jclouds framework which itself can tend to be heavy and so may be doing a lot of setup.

@tdauth
Copy link
Author

tdauth commented Jan 20, 2022

Well my test took 18 minutes and then only like 4 minutes after using only one client per endpoint (using two endpoints). I created a client per repository and sometimes also per file. It would be nice to at least document it in the README or somewhere to not write your code like I did or even better to improve the performance. Even when you are always using the same Bitbucket endpoint you might want to clean up the bitbucket client with close afterwards. I am not sure when to close the client now when using two static client instances.

@cdancy
Copy link
Owner

cdancy commented Jan 20, 2022

It would be nice to at least document it in the README or somewhere to not write your code like I did or even better to improve the performance.

This to me is just general knowledge when working with java. Unless documentation states otherwise you can use a given client across the board.

I am not sure when to close the client now when using two static client instances.

That would be up to you the developer to implement. You could so as part of a shutdownHook or when your object is destroyed or any other number of means. It all depends on your setup and application and what you want to do.

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

No branches or pull requests

2 participants