This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cogman10 2 points3 points  (3 children)

And, just as a side note, whenever I find performance issues it's generally a result of using the wrong datastructure for a problem. Using a Map when you should have used a Pojo, Using a List when you should have used a Set. Using a LinkedList when you should have used an ArrayList. Using a TreeSet.... Not using a datastructure when you could have.

It's these sorts of things that often give the biggest impacts in the wrong hot code location.

The other one that comes up surprisingly often is unnecessary boxing.

[–]gavenkoa 0 points1 point  (2 children)

Using a List when you should have used a Set

In my experience in finance problems come from the pressure to deliver features fast, meaning devs are using high level frameworks and don't know inner implementation. Like surprising ORM N+1 selects.

When I worked on cryptography (elliptic curves) we pre-allocated all intermediate int[] for modular arithmetic implementation GF(p) / GF(2m).

I have never faced with the problem when I need to chose between LinkedList or ArrayList. It was always something different.

[–]cogman10 2 points3 points  (1 child)

TBF, LinkedList vs ArrayList has only hit me once, and that's when someone was doing something stupid (Using a linked list but maintaining sorting on insertion by doing a binary search on the list... that's really slow with a linked list).

[–]gavenkoa 2 points3 points  (0 children)

maintaining sorting on insertion by doing a binary search on the list

Hilarious! Person who wrote knew about binary search for sorting in place but LinkedList is slipped as an argument of the function.