Posts

Showing posts from May, 2014

Java 8 parallel sort - internals

Image
Java 8 is a quite big update to the platform and luckily they focused on multicore systems too. The new Arrays.parallelSort() implementation is quite interesting: it is using quicksort, merge sort, and Timsort to achieve the best performance, depending on the underlying data type and size. Arrays.parallelSort() – not always parallel The first thing that needs to be noted is that it’s not always a parallel sort. If the array size is small enough (<= 8192 elements) or the number of reported logical CPUs is 1, it always falls back to a dual pivot quick sort. Note, that the “logical CPU” here refers to hyper-threading, so an average i7 dual core CPU will report 4 logical CPUs to the Java environment. To override the number of reported CPUs for the sort algorithm, we simply need to pass in any value to the following system property when starting the JVM: java.util.concurrent.ForkJoinPool.common.parallelism Sorting the chunks and chunk sizes The algorithm ( Arrays.java ) wi

Git cheat sheet - the most useful commands

After a little practise, Git can be fully utilised from the command line without any GUI. Adding, committing, pulling, and pushing is part of the daily work; however, there are other commands that are useful but not that frequently used. Here is my collection of those: # Create and checkout new branch based on the current branch git checkout -b <newBranch> # Undo all local pending changes git reset --hard HEAD # Erase the last 3 commits git reset --hard HEAD~3 # Undo a single file change git checkout -- <fileName> # Push new branch to server git push origin <branchName> # Delete remote branch git push origin --delete <branchName> # List all local and remote branches git branch -a # Remove remotely deleted branches - will not delete local branches, only copies of remotes git remote prune origin # Pull remote master branch and merge it into current branch git pull origin master # Undo last commit but keep changes unstaged git reset H