• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interview question on performance tuning  RSS feed

 
Vivek Hingorani
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ques1. If there is a code(method) inside a jar and it takes 10 seconds to do business processing, then how can we performance tune it? So there are 10 integer values which the method needs to process, and it will take 10s and 10 = 100s which is too much time and how can it be reduced to say 10secs or 20 secs.

ques2: I have a flat table which has all details of Employee object. Now I search all "Vivek" in the employee table and want to show on UI, which datastructure should I use?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Well... What was your initial answer? What follow up did you do for the questions? Etc.

Henry
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That first one is almost certainly (if it's as worded) something to see how you would go about solving a problem with very little initial data.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you almost certainly need to ask more questions or suggest more strategies to find out more info on this performance problem. Some ideas:

Is there documentation for the library? Look there to see if you can find more information. Can you Google more information about it? What about a search like "FooLibraryName performance problems"? Are there other people out there who have had similar problems? What did they do to solve them? If it's proprietary code, or not widely known to the public, can you contact the people who wrote it? Do they have any ideas?

Do you have access to the source code for the library? Or, can you use something like IntelliJ to decompile the source for you?

Look at the other methods and classes in the library. Are there other ways to get the information you need? E.g. perhaps there's some sort of "bulk" method that lets you process a collection of numbers simultaneously, rather than one at a time.

Can you use a performance profiler to get more information about which methods, exactly, are really taking up the time?

Can you reproduce the problem? On you own machine? In a relatively simple project setup, maybe with just the one outside jar file, and some test code of your own? Having an easy-to-run test setup will both help you find the problem, and verify if your solution really fixes it.

Do you need to bring in other libraries and systems to reproduce the problem? If so, consider that the problem may actually be in those other libraries or systems. Again, try a performance profiler here.

Can you identify where the bottleneck is? Is there a particular resource that is being used to its maximum? Is the CPU at 100%? Is there a lot of file IO being done, or a network connection being waited on?

Are there other configuration files the system depends on? Does changing some parameters change the performance? It could be you just need to give the program more memory, or increase the size of a thread pool. Or maybe you're accessing a database somewhere and there's a query that would perform better if you add an appropriate index to a table.

Can you solve the problem by using multiple threads to run multiple calculations simultaneously, rather than one at a time?

Are you using the latest/newest version of the library? And of Java? If not, can you upgrade?

Are there other libraries available that might solve the same problem? Are they any faster? Can you write your own? If the library is open-source, or if it's created by others at your own company, it may be possible to create an improved version of the library.

One thing you should not do: don't get stuck on any one possible explanation and solution for the problem, unless and until you have tried the solution out and verified that it solves the problem. (And even then, check carefully to be sure.) Since there are many possible diagnoses and fixes here, it's easy to waste time on something that you think will fix the problem, but it doesn't. Often, you just have to try different things until something works, and it may be unavoidable to waste some time trying things that don't work. But, try to keep an open mind, alert to the possibility that you've misunderstood the problem. If a "solution" is not working, remember that the problem may not be where you think it is.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!