04:33PM Jul 25, 2010 in category General by Zoltan Farkas
With the new generation of developers I increasingly see less desire of writing efficient code. It also makes me quite angry when I hear arguments like "disk is cheap", "memory is cheap", ... "premature optimization is evil".
Writing code is a difficult task, it is a continuous balancing between implementation choices, but writing a efficient implementation is not always hard and time consuming.
I will give a small, recent example:
I recently spent 10 minutes of my time to optimize a data cache component that was taking up 250 Mb of RAM, and reduced the memory usage by 150Mb. Since this optimization was on a component that was reused in several processes my 10 minutes spent became even more valuable. All I did I internalized the string attributes that were highly redundant.
By reducing the amount of memory my application uses, I also increased the performance:
Less GC overhead, higher CPU cache hit ratios, less interconnect utilization (NUMA), more memory available to the disk cache, less process swapping.
One of the metrics you can monitor is: "cycles per instruction" (how to measure: http://blogs.sun.com/brendan/entry/amd64_pics). This metric can improve significantly by reducing your memory footprint.
Conclusion: Using String.intern is a simple and efficient way of optimizing your implementation.
10:54PM Oct 13, 2009 in category General by Zoltan Farkas
Today's latest trend is going Green, everybody is talking about reducing it's carbon footprint, we have Green cars, Green Buildings, Green Data Centers,.....
The major hardware vendors battle each other on who makes the most energy efficient hardware, and some electricity utility companies even offer rebates for using energy efficient hardware (ex: Sun's UltraSparc T1).
10:56AM Jun 30, 2009 in category Solaris by Zoltan Farkas
There is no secret that I am a big Solaris fan. For me as a developer ZFS and DTrace changed my life, improoving my productivity significantly. With ZFS and its snapshoting/cloning capabilities, I have no fear in doing experiments and I can always go back in time and recover in case something goes wrong. On the other hand DTrace with D-Light allows you to look inside your running application.
If you want to learn more there is an excellent tutorial that describes how to use DLight to profile your applications:
12:08PM Jun 15, 2009 in category General by Zoltan Farkas
I was wondering if I can improve the performance of my number computations in ZEL by using the Gnu MP library, so I went ahead and implemented a native version of BigInteger called OperableBigInteger
The class OperableBigInteger has a private transient member pointer of type long(to work on 64 bit systems too) that holds a reference to mpz_class. The finalize method is the one that deletes the object referenced by pointer :-) (finally I found a good use for it...)
07:19PM Jun 02, 2009 in category General by Zoltan Farkas
I have added support for lambda expressions in ZEL, also added a FOR statement that can iterate all variables that match a wildcard and apply a lambda function to it.
abc=1;
afe=2;
bfa =3;
x=0;
result=for("`a*`",lambda(x=x+arg(0);));
print x; // x will be 3
Functions are objects, so you can do, and apply using the () operator:
05:29PM May 28, 2009 in category General by Zoltan Farkas
In my projects I am required to switch back and forth from C++ and Java.
The typical reason for using C++ is performance and tight integration with OS/Hardware (ex: process management).
The typical reason for using Java is coding speed and portability.
One of the major barriers that I encounter in my development work is how software is organized in C++ vs Java, at this chapter java is arguably better than the classic C++ way. (the hpp/cpp separation is evil :-) )
I found an interesting article about how C++ code can be organized in a more Java like way:
05:07PM May 21, 2009 in category Java by Zoltan Farkas
Customer informs you: "Application is not working". You log in into
the system, check the app processes, you see all of them there, you run
a top or prstat and you notice one of them hugging a CPU/Core way too
tightly.What can you do ?[Read More]
07:29PM May 13, 2009 in category General by Zoltan Farkas
I stumbled a few years ago upon the NASA worldwind project, at the time it was quite unusable on most platforms (lack of powerful hardware graphics), however the project progressed quite a bit since and even works on my opensolaris workstation today... I was quite surprised to see a seamlessly working 3d mapping applet on my obscure OS... Now this was enough to grab my attention, so I went on and explored the project a bit.
[Read More]
11:32AM Feb 12, 2009 in category Java by Zoltan Farkas
Sometimes you have a reporting application running reports on a
oracle database. Your oracle database might consolidate data from quite
a few mysql databases (via ETL). However some detail data remains
always on the mysql databases. Of course the day will come when the
reporting application will need the ability to drill down to the detail
data from the mysql databases.
That day you will read up on Oracle Heterogeneous Data Access, ODBC, Mysql Proxy...
In
case you need only read access to the mysql databases, you might not
feel like dealing with licensing for Oracle Heterogeneous Data Access
via ODBC or Mysql protocol manipulation in LEA. Here is what you might
want to do:
Use oracle table functions implemented in java to access your mysql tables via JDBC and your queries might look like:
select
* from table (typeName_FT('SELECT * FROM remoteTable where condition'
,'jdbc:mysql://host:port/database', 'user', 'password',
timeout,'typeName'));
(to create typeName_FT table function you need to call createSqlObjects defined in the code that follows)
To write a java stored
procedure is straight forward, use your favorite IDE, make sure your
JVM is same version with the Oracle JVM, after you are done, load your
jar[s] with:
your
java stored procedures/functions are nothing else than java static
functions, however for you to access them from plsql you need to create
a PLSQL call wrapper:
CREATE OR REPLACE PROCEDURE createSqlObjects( p1 IN VARCHAR2, p2 IN VARCHAR2, p3 IN VARCHAR2, p4 IN VARCHAR2, p5 IN VARCHAR2) RETURN VARCHAR2 AS
LANGUAGE JAVA NAME
'mypack.JDBCUtil.createSqlObjects(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)';
Here is the java source you need for my sql example:
11:10AM Dec 17, 2008 in category General by Zoltan Farkas
Got a new "workstation" from Dell, a XPS 730 with the new Core I7 cpu and DDR3 memory. (the usual with Dell, you always feel funny when you buy from them with their confusing deals and coupons...)
This machine is basically a gaming machine, but I thought that opensolaris would not complain about it ...
Hmm, instalation was far from painless...
the following parts were not recognized out of the box:
1. Nvidia gforce 9800 GTS
2. Broadcom Netlink BCM5784M Gigabit Ethernet
3. Creative Labs Sound Blaster XFI
the video card problem I resolved with help from the xwin-discuss mailing list:
# update_drv -a -i '"pci10de,605"' nvidia # reboot
The sound card I have attempted to resolve with oss, however the sbxfi driver provided is beta and looks like it does not recognize my card... I have posted my issue on the driver-discuss mailing list ... hope that a future update will resolve the issue.
UPDATE: I have removed the plastics that were covering the onboard audio, removed the creative card and activated in BIOS the onboard audio and I have some bad quality sound on my system right now, better than nosound.
The Network card issue I temporarily resolved by installing a pci network card that was recognized by opensolaris. Meanwhile a RFE has been filled: http://bugs.opensolaris.org/view_bug.do?bug_id=6786742 it does not look like too much priority is given to desktop cards by Broadcom, well I will have to go ahead and purchase a card from their competitors...
12:11PM Nov 19, 2008 in category Java by Zoltan Farkas
JBoss Rules is one of the best open source rules engines available to integrate inside your application (for more information on features: http://www.jboss.org/drools/).
JBoss Rules provides both a Rule Engine and a Rule Management System (Guvnor).
1. Integrating the Rule Management System UI.
Guvnor is a web based jbrms that allows you to create, test, deploy your rules and a lot more. It uses Apache Jackrabit to persist the rules, Apache Jackrabbit is a fully conforming implementation of the Content Repository for Java Technology API (JCR). here is how your J2EE app will look like:
You will need to create an war maven 2 project that will overlay the guvnor war, and allow you to customize rules persistence and integrate security, for this you will only need to customize components.xml located in WEB-INF.
You will also need to add some menu item or buttons to jump to your new BRMS GUI from your app and you have a brand spanking new gui module in your app.
12:18PM Nov 13, 2008 in category General by Zoltan Farkas
I upgraded to snv101a and to my surprise a feature called Time Slider was available.
The implementation is quite nice, in nautilus you have a time line
slider that you activate pushing the new time buton in the toolbar, you
slide to the desired point in time right click on the file/folder you
want to recover and select restore to desktop ...
11:51AM Oct 03, 2008 in category General by Zoltan Farkas
We were Maven 1.X early adopters and used m1 for the last 4 years and
saved us from the "jarmagedon" at the time . Maven1 increased
componentization in our company and as a result we have 200+ internal
maven projets.[Read More]
10:19PM Sep 06, 2008 in category Solaris by Zoltan Farkas
Finally a rainy day to give me some time to update my workstation/server to a newer release of opensolaris.
This is why:
1.
ZFS everywhere, I used to have UFS, with 2 alternate boot
environments. With ZFS I will have more flexibility in my experiments
(snapshots to rollback in case something will go wrong, clones for test
environments), it is so easy with ZFS...
07:44PM Jun 06, 2008 in category General by Zoltan Farkas
The trip was an amazing experience, we rode through lonely desert roads, dense forests, twisty mountain passes, spectacular coastal roads... This trip is mandatory once in a lifetime for anybody who considers himself a biker. (includes a visit to mecca)[Read More]
Hmm, so if the garbage collector is running like crazy (98% of the time) then the jvm will throw a OOM. This seems to be a feature of the paralel GC ...
11:40AM Nov 18, 2007 in category Java by Zoltan Farkas
I see a lot of java code every day with code that does Exception handling in non-conventional ways (download jboss or glassfish sources and take a look and see the aboundance of catch(Throwable)). Here is my opinion about theese practices and it is pretty much in line with the java documentation.
02:58PM Oct 26, 2007 in category Solaris by Zoltan Farkas
Duplicating a Oracle database running on a Sun fire X4200 + T3 disk array(Solaris 10U1 + UFS) to a Dell PowerEdge 2950 with a JBOD running Solaris 10 U04 and ZFS. The workload of this database is a warehouse workload and expectations are that ZFS compression will reduce io and improve overall performance. Theese tests focus on the impact of filesystem compression on performance. [Read More]