• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Easy to use Java performance booster

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java performance can be increased many times if we can optimize our code down to the machine level. And now it is possible without the need for anything else than Java IDE. Here is a long description, but in short it is all about easiness of a native code integration with plain Java programs. All you need is just to extent a base class and write native method implementation in Java. Everything else is made by the Machine Level Java (except the actual call of a native method in your program, of course). And all the code of a native method implementation is 100% Java.

And about speed increase. It is demonstrated to be as much as 5 times on matrix multiplication example. On different hardware it can show different numbers, but many times increase is absolutely real.

Another point here is about performance test holy war, when C and Java developers fight for better speed numbers. But now it is easy to move anything possible in C world into the world of Java with the help from low level methods, written 100% in Java
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a poorly designed algorithm will always be slower than a well designed one, regardless of what language it was originally written in or compiled to.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

fred rosenberger wrote:a poorly designed algorithm will always be slower than a well designed one, regardless of what language it was originally written in or compiled to.


A best ever possible algorithm will suck if it is executed on a vacuum tube computer.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:Java performance can be increased many times if we can optimize our code down to the machine level...


And if you need that level of optimization, YOU'RE USING THE WRONG LANGUAGE.

Java is not, and has never claimed to be, the fastest language on the planet. All it (or its disciples; like me) have claimed is that it is fast enough. And for the vast majority that use it, and the millions of things that it has been asked to do, it IS.

Adding another layer of complexity - even if it is completely extra-lingular AND people are prepared to trust the claims you make - is not going to attract disciples (IMO).

If this truly is a new way of looking at Java, then why not write a JVM/compiler based on it? I suspect that will get people looking at the performance difference.

Winston
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:And if you need that level of optimization, YOU'RE USING THE WRONG LANGUAGE.


Well, then you just haven't worked in the areas, where performance is very important. So, it is better to let performance hungry developers to have new tool, instead of talking them into another language. And, by the way, claiming that Java is wrong language from the efficiency point of view, is not very exciting action.
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I first worked with Java (JKD1.1) Java was very very slow but with the introduction of JIT this changed dramatically. My experience, and I have a fair amount, of performance comparison between C, C++, FORTRAN and Java (with JIT) is that the difference in speed between C, C++ and Java when implementing the same algorithms is very small with typically Java being less than 10% slower than C++ and C. Marginally FORTRAN tends to have the best performance which by looking at the resulting assembler is normally due to it's addressing modes since it does not need to access data via an object and virtual methods by lookup table.

So what is my experience? I'm a control systems engineer and for all but 10 or so of the last 50 odd years I have worked mainly with high speed real time systems where speed is vitally important. During that time I have had cause to look at the assembler produced by compilers to see how one might optimise the code to get the best performance. In the early days compilers did very little optimisation but over the last 20 or so year this has changed to the point where there is little point in writing in assembler since the optimisation seems to produce better code than I can generate by using assembler.

My primary bench mark these days is to implement my mixed radix 2, 3 and 5 FFT and here the performance difference between C, C++ and Java is very very small. Most of the time, for a given CPU, C and C++ come out marginally better (less than 10%) than Java but there are some input conditions where Java is actually better than C and C++. When I first ported my FFT implementations to the Raspberry PI there was a dramatic difference between the C/C++ implementations and the Java implementation but this was due to the early PI JDK using software floating point and not hardware floating point. With the introduction of hardware floating point JDK the difference once again became small. I don't claim that my FFT routines have anything like the performance of FFTW ( http://www.fftw.org/ ) but I try to make my implementation in the various languages as similar as possible so that my comparisons are legitimate. Measuring performance is not always easy since the operating system tends to get in the way but since for a given OS I always measure using the same basic technique I'm confident that my results are reasonable.

Given all this then why would I use your 'booster' ?







 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Richard Tookey wrote:Given all this then why would I use your 'booster' ?


Your experience was with C vs Java comparison, or more correctly, C compiler vs JIT comparison. But optimization techniques are much wider than only high level language tricks. Low level allows you to use hardware caches effectively, with it you can use a combination of instructions, that, most probable, all compilers just unable to reproduce. Often you have an option of high level algorithm optimization, which is not available to any existing compiler.

If in your experience was no extensive assembly level optimizations, then even if you had a look at a decompiled code, it doesn't mean there is no more options to make it faster. For more insight into the optimization techniques this document is a good starting point for those, who knows basics of assembly.
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:

Richard Tookey wrote:Given all this then why would I use your 'booster' ?


Your experience was with C vs Java comparison, or more correctly, C compiler vs JIT comparison. But optimization techniques are much wider than only high level language tricks. Low level allows you to use hardware caches effectively, with it you can use a combination of instructions, that, most probable, all compilers just unable to reproduce. Often you have an option of high level algorithm optimization, which is not available to any existing compiler.

If in your experience was no extensive assembly level optimizations, then even if you had a look at a decompiled code, it doesn't mean there is no more options to make it faster. For more insight into the optimization techniques this document is a good starting point for those, who knows basics of assembly.



Sorry Alexey but this just comes across as babble. As far as I can see there is nothing in your 'booster' that automatically makes use of the sort of optimisation tricks in this document so it is down to developers to spend major effort in applying these micro optimisations for what at best will be most probably be micro rewards.

Unless you can provide concrete examples of the use of your 'booster' providing a significant performance increase then I personally will dismiss your 'booster' as snake oil.

 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:Well, then you just haven't worked in the areas, where performance is very important. So, it is better to let performance hungry developers to have new tool, instead of talking them into another language. And, by the way, claiming that Java is wrong language from the efficiency point of view, is not very exciting action.


It might not be "exciting", but I stand by the statement. If performance is the ONLY (or overriding) benchmark you are interested in, then you should choose a language that allows you to tweak to your heart's delight. If I want to write a printer driver, for example, I would NOT choose Java to do it.

Picking the right tool for the job is part of the art of good programming. If I want a jeweller's hammer, then that's what I want; not a "reverse-engineered" mallet.

Winston
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Richard Tookey wrote:As far as I can see there is nothing in your 'booster' that automatically makes use of the sort of optimisation tricks in this document so it is down to developers to spend major effort in applying these micro optimisations for what at best will be most probably be micro rewards.


But do you think a JVM "automatically makes use of the sort of optimisation tricks in this document"? Unfortunately very often it is not. So, it is almost always the developer's responsibility to manage the quality of his code. If you want to get better performance, then you should spend some time optimizing your program. But if you feel that the default performance goes well, then, of course, you can forget about any optimization. However, there are many areas, where default performance just sucks and a developer should make some search for a better algorithm with better hardware utilization.

Richard Tookey wrote:Unless you can provide concrete examples of the use of your 'booster' providing a significant performance increase then I personally will dismiss your 'booster' as snake oil.


It seems you haven't read even a short list of chapter references from the link in the first post. There is a link to the chapter about performance testing.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:but I stand by the statement. If performance is the ONLY (or overriding) benchmark you are interested in, then you should choose a language that allows you to tweak to your heart's delight.


There is A LOT of projects, where performance is very important. And price for it is measured in human-years. So, if your project has no hard performance requirements, then it is possible to go without any optimization. But there are high load servers in the world, they service millions of requests per minute and the performance is very important for the owners of the servers. As you can see, such situation just draws a line between an ordinary web site with 100-1000 visitors per day and performance hungry systems. The last area is the target for the performance booster.
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:

Richard Tookey wrote:As far as I can see there is nothing in your 'booster' that automatically makes use of the sort of optimisation tricks in this document so it is down to developers to spend major effort in applying these micro optimisations for what at best will be most probably be micro rewards.


But do you think a JVM "automatically makes use of the sort of optimisation tricks in this document"? Unfortunately very often it is not. So, it is almost always the developer's responsibility to manage the quality of his code. If you want to get better performance, then you should spend some time optimizing your program. But if you feel that the default performance goes well, then, of course, you can forget about any optimization. However, there are many areas, where default performance just sucks and a developer should make some search for a better algorithm with better hardware utilization.


Your apparent definition of quality seem to be directly at odds with mine. In my definition as a minimum code quality comes down to - does it meet the design requirements, is it maintainable and would any further speed improvement be worth the cost of obtaining it? Yours seems to be - does it get every ounce of performance from the processor regardless of whether it needs every ounce of performance regardless of the ease of maintenance and regardless of whether or not it takes far longer to write and so costs more money?

Alexey Bezrodnov wrote:

Richard Tookey wrote:Unless you can provide concrete examples of the use of your 'booster' providing a significant performance increase then I personally will dismiss your 'booster' as snake oil.


It seems you haven't read even a short list of chapter references from the link in the first post. There is a link to the chapter about performance testing.




You provide a table of performance figures but I don't see a link to the code used to provide those figures either on the page or in the distribution so we are unable to either verify the figures or to comment on your implementation. Am I missing something?

I see little point in continuing my involvement in this thread since the gap seems too large to bridge.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:There is A LOT of projects, where performance is very important. And price for it is measured in human-years. So, if your project has no hard performance requirements, then it is possible to go without any optimization. But there are high load servers in the world, they service millions of requests per minute and the performance is very important for the owners of the servers.


And if that's the case, then you'll build the server according to the performance you need, and that will likely involve choices about hardware and firmware (I was a system builder for several years, so I do know something about this). Simply choosing stuff such as multi-core processors, more memory, higher speed network cards, faster/newer OS, or even something as simple as an SSD are likely to make far more difference to the overall performance of your system than a "language booster".

Also: Hardware upgrades are likely to be MUCH cheaper and more flexible than putting all your eggs in one "booster" basket; and a decent server platform will usually be built with them (not to mention redundancy) in mind.

As you can see, such situation just draws a line between an ordinary web site with 100-1000 visitors per day and performance hungry systems. The last area is the target for the performance booster.


And, as Richard already said, I highly doubt that any "booster" could give you much more than a 10-20% improvement. An few extra gig of memory OTOH....Fifty bucks. Sorted.

Winston
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Richard Tookey wrote:Your apparent definition of quality seem to be directly at odds with mine. In my definition as a minimum code quality comes down to - does it meet the design requirements, is it maintainable and would any further speed improvement be worth the cost of obtaining it? Yours seems to be - does it get every ounce of performance from the processor regardless of whether it needs every ounce of performance regardless of the ease of maintenance and regardless of whether or not it takes far longer to write and so costs more money?


My answer starts with "If you want to get better performance...". So, it defines the goal in a very clear manner. The whole subject of this thread is about performance. Of course, if your project is about low load web applications, then performance hunting really can raise the costs too much. But enterprise Java very often is about high load servers, where performance matters a lot. So it is important to define your position in terms of a need for performance - is there such a need in your project? If it isn't, then all your arguments are about something not applicable to the high load application development.

Richard Tookey wrote:You provide a table of performance figures but I don't see a link to the code used to provide those figures either on the page or in the distribution so we are unable to either verify the figures or to comment on your implementation. Am I missing something?


There is a table of contents at the top of the page, the last item in the table is named "Download", if you follow the link there will be a sourceforge page with the zip archived Eclipse project. The project contains every class, that is required to implement the Machine Level Java.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:then you'll build the server according to the performance you need, and that will likely involve choices about hardware and firmware (I was a system builder for several years, so I do know something about this). Simply choosing stuff such as multi-core processors, more memory, higher speed network cards, faster/newer OS, or even something as simple as an SSD are likely to make far more difference to the overall performance of your system than a "language booster".


Why do you think big corporations spend billions on server farms and all the similar installations? And how do you think, is a billion dollar question about something like this:

Winston Gutkowski wrote:Also: Hardware upgrades are likely to be MUCH cheaper and more flexible than putting all your eggs in one "booster" basket


Of course, it is possible to grow a server farm, but at some point just electricity cost will push you to the brink of bankruptcy.

Winston Gutkowski wrote:I highly doubt that any "booster" could give you much more than a 10-20% improvement. An few extra gig of memory OTOH....Fifty bucks. Sorted.


The tests here clearly demonstrate much bigger gains. An you can look at the code, it is short and takes just a few hours to get performance increase of 5 times.
 
Marshal
Posts: 5787
366
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have some examples of some resource intensive algorithms written in plain Java and written with your booster what would serve as an example that we could try at home?

I'm interested in seeing the actual performance gains achieved from a real life example, and I'd also like to see what the code looks like and compare it to the regular Java implementation.

Thanks
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:Of course, it is possible to grow a server farm, but at some point just electricity cost will push you to the brink of bankruptcy.


And your single-language "booster" is going to solve that?

If you need a server farm, you need a server farm; and one would assume that the people that built it factored expenses such as electricity into their forecasts. Indeed, changes such as SSDs or more modern memory or CPUs can actually reduce power consumption rather than increase it - at least in flops/wH.

My worry is that your solution is too targeted because it only deals with ONE of the hundreds of possible bottlenecks that can occur in a system and - while it might give you better throughput for highly localized, CPU/memory-intensive Java applications - it won't matter a darn to anything that, for example, needs to read or write to a disk or a network card.

However, I wish you luck with your project and hope that you can prove me wrong.

Winston
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:Do you have some examples of some resource intensive algorithms written in plain Java and written with your booster what would serve as an example that we could try at home?


There is an example in the project that you can download. But it seems that your meaning of the word "example" is different from my. It is important to calculate matrices in real life, but is it a viable example for you?

More complex example can be found in more complex applications. But all applications are different. One application needs a tree search algorithm, another application needs plain array scan, yet another application requires a lot of calculations, and some other application requires quick scan of a graph, search for some graph's vertices or some connected vertice pattern or something else.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:

Alexey Bezrodnov wrote:Of course, it is possible to grow a server farm, but at some point just electricity cost will push you to the brink of bankruptcy.


And your single-language "booster" is going to solve that?


Not always, of course, but sometime a cloud application really needs performance boost to decrease time and cost.

Winston Gutkowski wrote:My worry is that your solution is too targeted because it only deals with ONE of the hundreds of possible bottlenecks that can occur in a system


Yes, the Machine Level Java technology success area is much narrower than the Java as a whole, but my bet is that your assessment of one to hundreds is a bit skewed. My assessment would be one of tenths or even better.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:It is important to calculate matrices in real life, but is it a viable example for you?


Seems a perfectly reasonable one to me, but there are many structures that can boost performance for a standard matrix - just one being views based on a Node with two pointers: 'right' and 'down'.

But then you might get into localization issues, which linked lists are not so wonderful with; unless maybe the structure is superimposed on top of an array...

Optimization takes all sorts of forms, and a generalized "let's optimize the bytecode" (or the machine code generated from bytecode) one doesn't strike me as particularly revolutionary - and a new version of the Java compiler might well plug some of the inefficiencies that obviously bother you anyway.

But like I say, good luck. And I mean it - it's possible that you're "seeing" something that old codgers like me just can't due to my background; but I'll need to see a lot more before I concede that you've created a "better mousetrap".

And that's one of the problems of invention.

Winston
 
Tim Cooke
Marshal
Posts: 5787
366
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:There is an example in the project that you can download.


OK that's good. I'll take a look at those.

For the purposes of discussion in the forum, could you pick one algorithm as an example and post the code for implementing it in plain Java, and the code for implementing it using your booster? Including the benchmark results that you have observed with your example would be most welcome too.

It would be really interesting to see that. Thanks
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:But then you might get into localization issues, which linked lists are not so wonderful with; unless maybe the structure is superimposed on top of an array...


Yes, the last part of your reply is about to be the only one currently viable for the Machine Level Java. Arrays are the best structures for a processor to manipulate. And JNI exposes ordinary objects in a bit inefficient manner. Together those two facts mean that to get the best possible performance from the low level we need a converter class, that is able to lay the fields of our objects in a linear fashion within some array. But happily enough, the efforts, required to create such converter, are not very time consuming. And as a result we can get a full speed processing of our data (of course, if data is big enough to deal with it at low level).

Winston Gutkowski wrote:Optimization takes all sorts of forms, and a generalized "let's optimize the bytecode" (or the machine code generated from bytecode) one doesn't strike me as particularly revolutionary - and a new version of the Java compiler might well plug some of the inefficiencies that obviously bother you anyway.


It is not claimed to be revolutionary. There even is another project, which is older and proposes an option to write assembly in Java, but it's lack of documentation and the need to write assembly in a plain text (without IDE's help) has pushed me to make it better. And I still don't know how transparent the assembly usage is in the mentioned project. In my project a Java programmer just won't think about anything outside of a Java IDE.

Winston Gutkowski wrote:I say, good luck. And I mean it - it's possible that you're "seeing" something that old codgers like me just can't due to my background; but I'll need to see a lot more before I concede that you've created a "better mousetrap".


Thanks for wishing me luck! But my "mousetrap" should be seen as one of available optimization tools, instead of a revolutionary big thing, that kills everything around.

The place for optimization is simple - if your application hits 100% processor load and the performance is still not very promising, then it's time to use the Machine Level Java.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:could you pick one algorithm as an example and post the code for implementing it in plain Java, and the code for implementing it using your booster?


The code in Java is as such:

But the code in the low level requires a bit of assembly knowledge. Here is one simple function:

Tim Cooke wrote:Including the benchmark results that you have observed with your example would be most welcome too.


Oh, come on! The benchmarks are just waiting for your click!
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:The place for optimization is simple - if your application hits 100% processor load and the performance is still not very promising, then it's time to use the Machine Level Java.


I'd be careful about statements like that. If your app hits hits 100% processor load for long periods and the performance is still not very promising, then it might be time to try your "java booster".

But, as always, you should benchmark before AND after, and make sure that it does indeed solve your problems before you declare success.

Winston
 
Tim Cooke
Marshal
Posts: 5787
366
IntelliJ IDE Python TypeScript Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do those two snips of code perform the same operation?

Also, the Java one doesn't make sense as it appears to be incomplete. Variables 'n', 'as1', and 'as2' are undefined.

Alexey Bezrodnov wrote:Oh, come on! The benchmarks are just waiting for your click!


I didn't think it was an unreasonable request. I'm encouraging you to show off your project and performance claims by publishing your findings in a format that others can replicate for themselves.

It would be great to see a full example where you show two functionally identical methods, and you show the performance statistics for each. I'd like an example where the CodeRanch readers can easily take the code and run it on their own machines so see for themselves. Does that make sense? We're new to this project, so help us understand it, spoon feed us an example, get us excited about it.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:I'd be careful about statements like that. If your app hits hits 100% processor load for long periods and the performance is still not very promising, then it might be time to try your "java booster".


May be a better shot will be like this - just think carefully about your application and it's algorithm. Here I try to start some reasoning in a developer's mind. First the application, next the algorithm, next the algorithm improvements, next the JIT defined limit, next - just go outside the JIT. And of course, the whole thing is required only if the performance is not as good as you expect. All the the next steps are about standard optimization techniques, like benchmarking, looking for bottlenecks, changing algorithm, selecting most suitable instructions and so on.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:Do those two snips of code perform the same operation?


multiplicationLoopInGPRs method performs just what is in the name:

It is one variant of low level code. Another variant uses SSE2 instructions (it is a wider operation support technology, that is able to perform calculations on 4 integer numbers simultaneously).

Tim Cooke wrote:Also, the Java one doesn't make sense as it appears to be incomplete. Variables 'n', 'as1', and 'as2' are undefined.


The variables are method parameters. And method name is excluded because the essence of a problem is defined by the shown loops only.

But I see that it can be more clear if I post here complete methods with method name and parameters. Here is the same loop as above, but the innermost loop is replaced with optimized version:

Here ArrayMultiplicationSSE2 and ArrayMultiplicationGPRsOnly are classes, that have a native method, which performs calculations using low level instructions directly.

Tim Cooke wrote:It would be great to see a full example where you show two functionally identical methods, and you show the performance statistics for each.


Here is the full pure Java calculation method:

Tim Cooke wrote:I'm encouraging you to show off your project and performance claims by publishing your findings in a format that others can replicate for themselves.


Ok, here is the copy from the page:

Here SSE2 stays for performance metrics of ArrayMultiplicationSSE2's multiply method. GPR is for ArrayMultiplicationGPRsOnly's multiply method.">
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:May be a better shot will be like this - just think carefully about your application and it's algorithm.


Alexey, I will say this:

What I like about your solution (if indeed, it works universally) is that it's a "no-brainer":
Use Alexey's "booster", and the chances are that your Java program will work faster.

And as long as you can guarantee three things:
1. That it will NEVER work any slower.
2. That I don't need to change ANY of my code to use your "booster".
3. That it will ALWAYS work in multi-threaded situations.
then I can't see any particular reason not to use it.

Ie; If it is an extra-lingular solution, I'm happy. If not, I won't be.

But that's me - old sceptical dinosaur.

Winston
 
author
Posts: 23958
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

BTW, is this a general purpose optimizer? Meaning it will optimize anything written in Java?

Or is this a matrix library, that is written very well, and can beat standard calculations? And since there isn't really a matrix library in the core java library, it will be a strawman set of calculations?

Henry
 
Tim Cooke
Marshal
Posts: 5787
366
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:BTW, is this a general purpose optimizer? Meaning it will optimize anything written in Java?


I don't think so Henry.

As far as I can make out, it's a framework to allow you to write assembler in your Java app. It's that 'down to the bone', 'close to the hardware' type of programming that professes to have superior performance characteristics. If you know what you're doing, of course.

It's a very niche area and not for general purpose programming (because the readability is horrid). The only way I could imagine it being used would be if I were writing some library where performance was paramount and I would be hiding the gnarly implementation away behind a nice interface. I would liken the use of this library to using the Unsafe class.
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:

It's a very niche area and not for general purpose programming (because the readability is horrid). The only way I could imagine it being used would be if I were writing some library where performance was paramount and I would be hiding the gnarly implementation away behind a nice interface. I would liken the use of this library to using the Unsafe class.



But one has to ask the question - why not just use JNI ? I have not used assembler in JNI but as far as I can see there is nothing to stop one using it as long as one obeys the JNI protocol.

The biggest problem I see with the 'booster' is selling it as a performance booster when it just seems to me to be a (simpler ?) way of interfacing with assembler.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:And as long as you can guarantee three things:
1. That it will NEVER work any slower.
2. That I don't need to change ANY of my code to use your "booster".
3. That it will ALWAYS work in multi-threaded situations.
then I can't see any particular reason not to use it.


1. Intel guarantees, that it will never remove any part of ancient processors from modern hardware. The 8086 (early beginning of 1980s) processor is still within every modern processor. So, everything we have now in modern processors will be with us for very long time. And as a consequence - any program for modern processor will work in next 20-30 years.

2. Unfortunately, you just have to change one line - the actual call to a native method.

3. It will always work in multi-threaded environment unless a developer forget about using JNI's corresponding functions.

So, except the #2, there is a very nice match between your requests and the actual technology capabilities.

And even more, the framework can generate a wrapper, which will call a pure Java implementation in case of unsupported platform/architecture, on which a program runs.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:is this a general purpose optimizer? Meaning it will optimize anything written in Java?


It will optimize anything written in Java if a developer is ready to optimize anything written in Java. So, because a developer is a general enough "device", then this optimizer can be seen as general, as a developer is.

Or in a bit different words - now you have a tool which can help you to program really efficient software. But, as any other tool, it requires a bit of skill to use it properly.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:The only way I could imagine it being used would be if I were writing some library where performance was paramount and I would be hiding the gnarly implementation away behind a nice interface.


Not only libraries has important performance requirements. Any viable high load application has it. So, if anybody wants to make his application faster (and more competitive, with lesser life cycle cost), then this technology is a real enabler.
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Richard Tookey wrote:But one has to ask the question - why not just use JNI ?


If you have corresponding tools - of course, you can. But do you have the tools and required skills?

Richard Tookey wrote:I have not used assembler in JNI but as far as I can see there is nothing to stop one using it as long as one obeys the JNI protocol.


It is even possible to write a program in a plain binaries, but it's a very hard exercise and I wouldn't advice it to anybody.

In fact this technology makes life easier and the level of complexity decrease is comparable with writing programs using notepad.exe and Eclipse IDE.

Richard Tookey wrote:The biggest problem I see with the 'booster' is selling it as a performance booster when it just seems to me to be a (simpler ?) way of interfacing with assembler.


It is not a way of interacting with assembly programs (it's the JNI, who is responsible for low level interactions), but it is a technology of rapid application development in the area of high performance applications, written in 100% Java. There is no need for those murky editors, linkers, translators and so on, only Java IDE and nothing more.
 
Tim Cooke
Marshal
Posts: 5787
366
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alexey, do you think your technology would be suitable for writing a very high throughput, non blocking, queue?
 
Alexey Bezrodnov
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:Alexey, do you think your technology would be suitable for writing a very high throughput, non blocking, queue?


I think it is suitable. But of course, if you give more details then it will be possible to be more precise.

In general - any memory structure operations can be definitely speeded up. It's just the area where the hardware really works well.
 
Tim Cooke
Marshal
Posts: 5787
366
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I propose a challenge. Mostly for you Alexey.

Write a single producer, single consumer queue that implements java.util.Queue. The challenge is to have it outperform the queue of the same type written by Martin Thompson that forms part of the LMAX Disruptor. A discussion of how to use that queue can be found here which includes a link to the source.

I'm not just throwing out a random challenge here. The company I work for is one of the biggest, if not the biggest, financial trading platforms in the world, and we spend a lot of resources finding ways to improve the throughput speed of our systems. Blindingly fast queues are a big deal. So, if you can outperform Martin's queue implementation (which I believe to be the fastest there is) then you're really on to something.

Are you up for a challenge?
 
Henry Wong
author
Posts: 23958
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote: I don't think so Henry.

As far as I can make out, it's a framework to allow you to write assembler in your Java app. It's that 'down to the bone', 'close to the hardware' type of programming that professes to have superior performance characteristics. If you know what you're doing, of course.



Interesting. This is actually something that ...

Richard Tookey wrote:
But one has to ask the question - why not just use JNI ? I have not used assembler in JNI but as far as I can see there is nothing to stop one using it as long as one obeys the JNI protocol.

The biggest problem I see with the 'booster' is selling it as a performance booster when it just seems to me to be a (simpler ?) way of interfacing with assembler.



... that C have been doing for many years. In fact, IMO, this is why no-one uses an assembler anymore. Just program in C, which is very low level anyway, and when you actually need direct assembly calls, just use the asm pragmas that is supported by C/C++. And of course, Java can't support this as there is no way to do this in platform independent manner.

And yes, I agree. An API to assembly is *not* a performance booster !!

It is interesting though. And perhaps a performance project comes up that I may try it with (instead of using JNI).

Henry
 
Henry Wong
author
Posts: 23958
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexey Bezrodnov wrote:
It will optimize anything written in Java if a developer is ready to optimize anything written in Java. So, because a developer is a general enough "device", then this optimizer can be seen as general, as a developer is.



Ahhh, no. Nice try though...

The "programmer is the optimizer" is basically saying that the tool is not a general purpose optimizer. I was asking whether it can take any program and boost it by changing the compiling process only.

Henry
 
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic