Vaclav Kosar's face photo

Vaclav Kosar

Vaclav Kosar is a senior software developer. This blog is focused on interesting technology, tips and news.

Geecon 2017 Notes Day 2

20 Oct 2017


Missing breakfast break at the begging of second day may have been suprising to some attendees. The day ended with a announcement of winners of little conference game that was prepared. Video recordings of all presentations were promised to be uploaded soon.

Architecting for performance

Design Patterns

Matrix multiplication for performance. Cpu caching is important.

Row traversal vs Column traversal

Row traversal has greater throughput as it traverses the way cpu cache expects.


Reduce code footprint as possible. (Smaller methods are better.) Remember JVM already performs some optimizations.



Data Patterns for cachign and eviction algo affect performance.


Minimmizing round trips in server communications. Remember bandwidth and receiver handling rate.

Design Asynchronous

Prefer async by default, synchronous only when needed. Use also stateless. In Java use CompletableFuture.

Mem Access Patters

Access in most linear manner possible. Any jumps reduce access speed. Typ


Read Ulrich Drepper

Lock Free Algos

Avoiding blocking by locks generally lead to beter performance.

Cache Oblivious Algos

Thread Affomotu

Thread binding to single cpu thus can leverage cpu cache.

Non Uniform Memory Access

Large Pages

Can represent larger memory range hence reduces TLB misses Java has switch to turn on large pages if supported in the OS. Suitable for mem intensive apps. Large contiguous mem access. Not recomm for shoft lived apps with small working set or apps with large sparsely used heap.

RamFS or TmpFS

Simulate FS by accessing RAM instead of FS.

Hardware Recomms

False sharing

Java annotian: @sun.misc.Contended

ZeroBit Recording

hdd stores more sectors per track in the outer parts of hdd than in the inside.


Enable Trim: delete immediately istead of delaying to write causing delays I/O Scheduler: noop vs deadline vs cfg: noop seems little bit better. Enable write caching


Ky Latency Hierachical Model

cleancode, cyclomatic complexity, cohesion, abstrations. affordable latency: data strcutures, algos complexities, btaching, caching. low latency: memory access pattern, lock free, asynchronous processing, stateless, RamFS/TmpFS, GC andobject lifecycle tning. ultra low latency: Trhead affinity, numa, large pages, false sharing, data oriented design.

Adam Bien: No Migrations: Use Webstandard

I lost most of my notes as idea crashed and nothing was autosave to disk. The point that webstandards are suffient. Uber-Jar doesnot make sense as u dont need to deploy such a huge file.


bsyncn tool to push file changes to the browser Visual Studio Code for js, html, css


Possible easily with standard CSS webstandard.



Value binding

saveButton.onclick = (e) => this.header.innerText =


import KrtekSerivce from “./KrtekService.js”;


new WebSocket("ws://localhost:8080/heroes/heroes")
  .onmessage = e => console.log(

JaxRS Backend


TypeScript Problems

Very good, but architects encourage strange patterns. Refactoring is made easier. Use tsc compiler. Disadvantage is the build step.

Java 9 Security

JSSE blocking mode

SSLSocket class. Usedin the smae manner as regular socket.

JSSE non blocking mode

SSLEngine. Methods wrap() n unwrap() used to transfer data. Handshake triggered by wrap, unwrap, beginHandshake.

Java 9 new feature: DTLS

DTLS is TLS over UDP.

Skipped rest and left for another.

Hibernate Tips n Tricks

Primary Keys


Advantage in distribution of ability to create id. Hibernate can generate UUID for you.

Generation Strategies:


Entities support getters returning optinals.

Java 8 Date and Time

JPA 2.2+. Hibernate 5+.


Attirubte convertor

@Convertor LocalDateConvertor implements AttributeConvereter<LocalDate, Date>
  java.sql.Date convertToDatanaseColumn(LocalDate date)
  LocalDate convertToEntityAtrribute(sql.Date date)

Auto apply

Allows no need to specify the convertor on all columns. @Convertor(autoApply = true)


One db serves multiple consumers sharing same app.

Tenant -> App -> Db

TenantIdResolver implements CurrentTenantIdentifierResolver



jgroups, lucene, jbossmarshalling. proto buffers, push events,

4 Modes of data distrib


Not distrib.

Invalidation mode

Sending invalidation to other nodes. Infinispan does not hold any data.


Holds data in replicated manner.


Is AP system. …missed.


Client writes. Leader is already elected. Leader maintains partially-orderedreplicated log. Raft cluster accepts write when n/2+1 nodes are up. It is thus CP system. Recovery is complicated sometimes not possible.

Raft is great when you have much more reads than writes.


Split will happen i.e. cluster will split into two at some point. Rebalance has to happen. Data will be accumulated on both sides of the split.


Merge happens when we have two different values for same key. There are auto policies, but they are not enough.


Merging has to happen using our business logic.


Clocks are never the same cross the cluster. It is very hard to sync clock. Do not use time for coordination.

Append only approach


Op requiing coord

Seq num generator.


For order and rollback. Order not needed as mentioned. Rollback is not supported. Readers need to able to recover from inconsistent states.




Client ->* JobServices

@Autowired JobController(DefaultCacheManager)

  jobCache.putIfAbsent(, job)


Is posible with Lucene integrated into Hibernate.

Take Away

Infinispace is sometimes better fit than Raft. Avoid need for coordination as it is problematic in distrib syss Distrib is hard to encapsulate

VR Coding

Jarek Ratajski: Scala, JS, Java, live in Swiss

Currect PC interaction is limited.

Planned Obsolence

Lot of hardware has designed failure after warranty. Peoples bodies also have warranty. Devs have commonly issues with sitting.

Dream IDE


Fits missing parts. Really immersive.

Conding for VR

WebVR is not very stable for products.


Basic environment def in XML. Scene building using JS. Text input: Various apporaches but very limited. No keyboard.

How To Distribute classes in space.

Classes are placed into 3d space where imports creates attractive force between the classes.

Results Currently

Passive viewing of code almost useful. Probably soon useful. Edditing is not possible at the moment.

Software Is Detail

Dijkstra: Purpose of abstraction is not to be vague, but to create new semantic level in which one can be absolutely precise.

Software is about all of the details. The software should need all the details. Nothing extra is kept thus everything that is there matters. Proper metafor for writting code is constant zooming in and zooming out. Architecture represents significant desing decisions that shape a sys where significant is measured by cost of change.

Architecture is costly decisions

Modules hide mostly likely changing costly decisions. Architecture are costly decisions performed at the beginning of the project.

GraalVM: JS & co for J devs

GraalVM is polyglot VM for interoperability, debugging

GraalVM Arch

Enterprise React

Subscribe: Twitter , Facebook , RSS ,
Share on: Twitter , Facebook , Google+ , LinkedIn , Reddit .

Report any trackers to [email protected].