git reset: 3 steps

In general, a commit procedure involves two transitions between three “trees”:

  • from local tree -> staging
  • from staging -> index

As a “treatment”, git-reset comes in three strengths:

  1. soft: reset the index tree only
  2. mixed: reset the staging tree too
  3. hard: reset local tree and all other trees

  • StampedLocks were introduced in java8 only for internal/low-level utilities in the development of thread-safe components.
  • main advantage over RWlock — optimisticRead, which can reduce writer starvation by readers
  • main drawback — non-reentrant and prone to self-deadlock

— optimistic reading using a StampedLock object
A thread can hold this object in optRead mode. This mode can be thought of as an extremely weak version of a readLock, that can be broken by a writer at any time.

Your thread would first tryOptimisticRead() to get a temporary stamp. Then validate(theStamp) would pass iFF still “free”.

After first successful validation, you should quickly read just a few data items, and validate() again to confirm availability.

Remember that, with zero notice a writeLock can be created from this object, invalidating your optRead lock.

OptRead lock is designed for quick small reads, like stealing…

This class offers too many API methods. I wonder which ones are most often used. I hope the javadoc example helps.

— stamps are long integers explains the stamps superficially.

Most if not all grab attempts return a stamp that is needed for unlocking or lock level upgrade/downgrade.

— why did they design this lock as non-reentrant? Must be some performance reason.

This construct is definitely designed for experts not the casual programmer.

— relation to the (interview-wise) hotter AtomicStampedReference

I don’t see any relation.

competitors to x86 instruction set

Interviewers often focus on x86 instruction sets, but I could point out competing instruction sets.

  • IBM’s PowerPC and Oracle’s Sparc — were a pair of once-popular instruction sets in HighPerformanceComputing. Even if they are less popular now, the still have a presence.
  • AMD64 — instruction set (i.e. x86-64) was created at AMD, as an extension on x86
  • IA-64 — instruction set was created at HP then Intel, widely deployed in data centers.
  • ARM — If interview is not 100% focused on server-side, then I would point out ARM instruction set is dominant in handheld.

brank ≈ luxury car #white elephant

What’s in common between a luxury car and a brank like “Director”?

  • enviable, glamorous, glorifying
  • high maintenance, high visibility
  • you need some minimum personal capacity (“performance“) to maintain it over a long time
  • can wear out quickly, esp. when you age
  • Not a passive income generator,
  • perhaps not a reliable cash-cow asset,

My contractor job is like a mid-range reliable Japanese car.

job hopper^stagnant mediocre#CNA is a Singapore perspective:

Long gone is the notion of the career ladder, where the ideal CV looks like a narrow, vertical progression. Today’s gold-standard CV looks like a career matrix, with horizontal and vertical moves signifying depth and breadth of experience, skills and exposure to different cultures.

Employers have gone from being cynical about hiring job-hoppers to becoming accustomed to seeing diverse CVs from top talent who are in frequent demand.

most U.S.job seekers shun contracts

I often say that the young, bright candidates basically ignore contract jobs — no benefit, no leave, no promotion prospect. is a Singapore perspective:

“many jobseekers turn away such contracts, choosing to hold out for something long-term that may or may not come”



mixing log4j + System.out.println

log4j.rootCategory=INFO, sysout
log4j.category.package1=INFO, logfile

Given this log4j.cfg content,

  • package1 classes’s logger output would go to log file specified
  • other packages’s logger output would go to sysout
  • System.out and System.err would go to sysout
  • In my dev system, sysout messages are saved to a separate sysout log file.

I have seen that System.out is less likely buffered.