billroper: (Default)
2018-09-20 06:42 pm

Changing the Subject

So, meanwhile, back at work, I think I have gotten the last bugs out of the Java side of what I was working on. Now, I just need to figure out exactly how to port all of the fixes back to C++, where the code is "similar", but not "identical". It's that difference between the two that makes porting so much fun!
billroper: (Default)
2018-08-24 11:58 pm

Refactoring Factorial

I'm refactoring some code that another fellow refactored, but which didn't quite come out to match the design that I had in my head. I think it's better now. I'll know for sure when it's done and I see how it runs.
billroper: (Default)
2018-07-25 11:43 pm

Cloning Around

Most of the objects that I'm attempting to fix up Java cloning for came together nicely.

Then, however, there are the ones that share references to a single object. This worked really nicely with MFC serialization, but it makes cloning an unholy mess.

*sigh*
billroper: (Default)
2018-04-12 10:37 pm

Hack and Slash

We've picked up a highly dimensional client file for testing here and have discovered that the calculations are running a good bit slower than they were in older versions of the product. Part of this is due to the fact that I eliminated a number of direct pointers in favor of map lookups, because I was told that maps would be very, very fast in our Java code. Well, maybe they are faster in Java than they are in C++, but they are still not fast enough in either case, because the calculations are way too slow.

So I've been putting back in various bits of caching in both the C++ and the Java code. With nothing cached, the calculations were taking a minute and 47 seconds. Caching two data items cut the time to 1:25, which was respectable, but still slower than I had in mind.

I have now cached a third bit of interesting data and have cut the calculation time down to 57 seconds.

This is good.

Tomorrow, I'll finish this up and try caching a fourth and final bit of data and we'll see where we end up. :)
billroper: (Default)
2018-04-04 10:58 pm

Cache On the Barrelhead

I've been cleaning up one of the subsystems in our product (that I did not write) and it is now substantially faster than it was. Aside from the earlier improvements I made in it, I taught it to cache two values that my version of this particular subsystem has cached since it was written. Doing this took the execution time to retrieve and write to a text stream a grid of nearly 700,000 cells from about 35 seconds down to 19 seconds.

There's other code that's running that is still taking way too long too execute, but this particular subsystem is now running much better.
billroper: (Default)
2018-04-03 10:43 pm

Time, Time, Time, See What's Become of Me

It's back to the optimization grindstone for me after discovering yesterday that one of the optimizations that I put in that seemed to work really well was broken -- which was why it worked so well! I'm having a lot of difficulty improving the rendering performance by optimizing my code further. Of course, I've managed to improve that bit by fixing up not just my code, but some of the rendering code on our side of the fence to the tune of about a 37% improvement. This isn't good enough, but I'm starting to suspect that a good bit of the rendering delay is due to some change on the other side of the fence here. We'll see.

Meanwhile, today's early optimizations have improved the calculation speed by about 11%.

I can do better than that. I still know where the bodies are buried...
billroper: (Default)
2018-03-27 10:38 pm

Not As Fast As You Intimated

When I ported all of our C++ code over to Java, one of the things I was told was "You don't have to worry about the speed of looking things up in hash maps. They're really fast." And since maintaining shared references to a single copy of an object was a pain in the butt, I started storing keys to the objects and looking them up in a master hash map for each of the different types of objects.

Then I found out that I was spending too much time looking up some of the things in the hash maps. So I made sure that the keys for the most frequently accessed object were immutable and shared via a common cache. And then I stored the pre-computed hash code inside the key, because not having to hash the key every time would speed up the searches a lot.

But the C++ code was running too slow, as I'd replaced the old shared pointers there. So I did the same trick in C++ that I done with the shared immutable cached keys with the pre-computed hash codes. Still not fast enough though.

Well, there was this value that I had previously pre-computed and stored, but was now looking up on the fly in a hash map with potentially multiple checks per value. Let's try putting that stored value back and only updating it when it needs to be updated.

Yes, that is fast enough.

*sigh*
billroper: (Default)
2018-01-23 11:06 pm

Bugs, Mr. Rico!

I have been head down in bugs for the last two days since I came back from Confusion, dealing with nasty interactions between MFC in C++ and interoperable code in Java. I think that I've managed to sort out the nastiness, although it was disconcerting to find a big fat bug in a built-in Windows method.

*sigh*
billroper: (Default)
2017-11-29 06:28 pm

On the Drift

I have just finished porting a big chunk of code from our Java implementation back to our C++ implementation.

I swear that the thing that will kill me is the continuing drift between the two implementations. There are many lovely new methods that I have coded in Java that had to be ported back to C++ so that I could call them there. And in Java, it's an OK thing to return a List<Something>. In C++, you want to create a CArray<Something*> and pass the reference into the method that in Java is returning a List<Something>. So the method signatures get screwy as you copy code back and forth. And "." turns into "->" or vice versa.

Eventually, I also need to clean up the variant versions of the camelCasing between the two implementations so that the old C++ IsSomething() ends up being the Java-style isSomething() on both sides of the great divide. As it is, the Java code is partially converted to the new style, as is the C++ code. But not all of the same methods have been converted on both sides.

And then there is "const". I love "const" in C++. I don't have it in Java. But I have immutable classes there that I don't have in my C++ implementation.

All of this is a recipe for a great thumping headache.
billroper: (Default)
2017-11-13 11:27 pm

Mix and Match

Trying to keep code that is in both Java and C++ in sync is starting to drive me slowly insane. The problem is that the two development environments that we're using (the standard Java libraries plus a lot of Apache libraries for Java vs. mostly MFC for C++) have ways of doing things that are just different enough to make things really difficult.

I am considering this problem. No great ideas yet. I think...
billroper: (Default)
2017-11-07 10:57 pm

A Hole In the Pipe

Some code that had been working with piped streams in Java has suddenly stopped working. I am annoyed.

I also suspect that something is being done wrong by somebody. I just haven't figured out who or what yet.
billroper: (Default)
2017-10-26 06:52 pm

Traction

I'm finally gaining a bit of traction on the current project at work.

Mind you, today I took a side trip to convert the caching of a couple of ID classes from being model-based to being server-based. But this will be a good side trip to have taken.

And I have now written the first of the classes for the project that will actually do something as opposed to being boilerplate and necessary utilities to make things run.

So it's progress. Maybe not as much progress as I would like, but progress.
billroper: (Default)
2017-03-16 11:50 pm
Entry tags:

Lightening the Memory Load

Well, I added caching for another couple of classes today, which should reduce the memory footprint a bit further. Unfortunately, I am getting close to the point of diminishing returns.

The thing that's the real killer is a big doubly-linked list. Unfortunately, it's a big doubly-linked list that I really need.

*sigh*
billroper: (Default)
2017-03-15 10:58 pm
Entry tags:

Plugh!

Here I am, in the maze of twisty passages, all alike. Again.

When we open one of our models on the Java side, the memory usage in the JVM goes up by 200 MB. The heap dump says that the data associated with the model is only about nine MB.

Where the heck is the other 191 MB coming from? You'd think it would be easy to figure this out, but so far, not so much.

*sigh*
billroper: (Default)
2017-03-14 09:45 pm
Entry tags:

Shrinkage

So we're studying heap dumps for our Java app to try to determine why our models are taking up as much space as they are. After staring down some of the models, I dropped in a bit of new code.

The model that I was working with -- one of the smaller ones, admittedly! -- shrank by almost 10% in its memory footprint. Larger models probably won't shrink quite as much, but it was a gratifying result.

Now to see if I can use this trick in some other places. :)
billroper: (Default)
2017-02-23 11:55 pm
Entry tags:

Oh, Heck. Or Words Like That.

Yesterday, I discovered that someone had (in error) created a new session object and left it to hang around forever.

Further investigation showed that had happened more than once, sometimes with big blocks of memory left attached to the session.

I have now exterminated those cases.

I also did a massive cut-and-paste operation to insert code that would throw an exception every time that an attempt to assert a transient lock failed. (Normally, it should wait a short period of time, the other lock should clear, and the operation should complete.) This was frustrating, but in the defense of the folks who wrote the code that wasn't throwing the exception, I hadn't added the quick-and-easy method of throwing the exception with all of the error information in it when they first started using the locks, so...

(Now, it's just call the constructor for the exception and pass in the lock object so that it can load up from the failure info. One line, nice and easy does it. This is because I am lazy and don't want to write this code more than once. :) )

All of this fell into the category of "more fun than human programmers should be allowed to have".
billroper: (Default)
2016-12-15 11:36 pm
Entry tags:

Oops

I am in a maze of twisty Java generics, all alike.
billroper: (Default)
2016-10-21 11:44 pm
Entry tags:

The Perils of Positive Thinking

So there's a class that I ported over from C++ to Java two years and a bit ago as part of this project. It works fine when you convert it from C++ and you can use it for a great many things successfully. However, when you try to edit it, the class falls to pieces.

I haven't really touched the class in any significant way in quite some time, so when I looked at it, I was pretty much horrified to find that I had managed to port it in such a way that there was the ported-from-C++ array of children for each member of the class and the Java array of children that was hiding in the new Java-side base class. Only one of these was populated and it was -- naturally -- the ported-from-C++ array, which meant that all manner of bad things are happening when I try to edit the data structures.

I am now in the process of removing the ported-from-C++ array (which I will only use during serialization because I have to be able to get the data back into the C++ side of the world) in favor of the Java-side array. This requires a lot of hand editing of code in this lovely 4300 line class.

*grumble*

Well, at least I've learned something in the past two years.
billroper: (Default)
2016-09-30 11:30 pm
Entry tags:

Close, Very Close

My code appears to be working. The code that is downstream from it, maybe not. We're trying to get my code into the downstream environment to test it, but that is proving more difficult than it should.

*sigh*
billroper: (Default)
2016-09-27 10:48 pm
Entry tags:

Fun With Java Generics

It took a while to get things straightened out, but I think I finally got my inner interface to successfully return a List of objects that implement the interface. Whee!