Skip to content

Commit

Permalink
Commit gunnarmorling#4: Parallelize munmap() and reduce completion ti…
Browse files Browse the repository at this point in the history
…me further by

10%. As the jvm exits with exit(0) syscall, the kernel reclaims the
memory mappings via munmap() call. Prior to this change. all the unmap()
calls were happening right at the end as the JVM exited. This led to
serial execution of about 350ms out of 2500 ms right at the end after
each shard completed its work. We can parallelize it by exposing the
Cleaner from MappedByteBuffer and then ensure that it is truly parallel
execution of munmap() by using a non-blocking lock (SeqLock). The
optimal strategy for when each thread must call unmap() is an interesting math problem with an exact solution and this code roughly reflects it.

Commit gunnarmorling#3: Tried out reading long at a time from bytebuffer and
checking for presence of ';'.. it was slower compared to just reading int().
Removed the code for reading longs; just retaining the
hasSemicolonByte(..) check code

Commit gunnarmorling#2: Introduce processLineSlow() and processRangeSlow() for the
tial part.

Commit gunnarmorling#1: Create a separate tail piece of work for the last few lines to be
processed separately from the main loop. This allows the main loop to
read past its allocated range (by a 'long' if we reserve atleast 8 bytes
for the tail piece of work.)
  • Loading branch information
vemana committed Jan 17, 2024
1 parent 937272e commit 685f98f
Show file tree
Hide file tree
Showing 2 changed files with 428 additions and 70 deletions.
2 changes: 2 additions & 0 deletions calculate_average_vemana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Basics
JAVA_OPTS=""
JAVA_OPTS="$JAVA_OPTS --enable-preview"
JAVA_OPTS="$JAVA_OPTS --add-exports java.base/jdk.internal.ref=ALL-UNNAMED"
JAVA_OPTS="$JAVA_OPTS --add-opens java.base/java.nio=ALL-UNNAMED"
#JAVA_OPTS="$JAVA_OPTS --add-modules jdk.incubator.vector"
#JAVA_OPTS="$JAVA_OPTS -XX:+UnlockDiagnosticVMOptions"

Expand Down
Loading

0 comments on commit 685f98f

Please sign in to comment.