young, productive developers (GS

Regarding my young GS colleague … He learns the production codebase very fast, so

* he can understand, in-depth, how and where all those complicated logic is implemented in production system
* he can understand what users mean, which is usually condensed in very terse emails, or quick phone calls
* he can quickly come up with quick solutions
* he knows what test scenarios are extremely unlikely so we need not handle them or test them
* he is faster navigating the code base from java to perl/shell scripts, to stored proc and big queries, to autosys and javascript, where business logic lives.

(I was weaker on all these aspects, for a long time.)

He’s more confident fixing existing codebase than architecting a rewrite. Limited experience. In this aspect, employer would see limited value in him.

gemfire cache listener runs in updater-thread

By default, CacheListener methods run on the cache updater thread.  You can easily verify it.

 

            final CacheListener listener = new CacheListenerAdapter() {

                  @Override

                  public void afterCreate(EntryEvent event) {

                        log.info(“afterCreate({})”, event);

                        count.incrementAndGet();

                  }

            };

           

            final AttributesMutator mutator = region.getAttributesMutator();

            mutator.addCacheListener(listener);

            try {

                  final TestBean bean = new TestBean();

                  region.put(“testAddCacheListener”, bean);

how a spring app stays alive after main() method returns

In fact, the main() method doesn’t return — prevented from returning. Prevented because main() calls await() of this class below.


protected static class ContextClosedCompleteListener implements ApplicationListener {
private final CountDownLatch countDownLatch = new CountDownLatch(1);
public ContextClosedCompleteListener(ConfigurableApplicationContext applicationContext) {
applicationContext.addApplicationListener(this);
}

// required by spring's ApplicationListener
public void onApplicationEvent(ContextClosedCompleteEvent event) {
log.info("Received context closed complete event");
countDownLatch.countDown();
}

// called from main()
public void await() throws InterruptedException {
countDownLatch.await();
}
}

c# q(NEW) keyword – 3 meanings

I’m sure there are excellent online articles, but here’s my own learning note.

Java “new” always hits Heap, period. Simple and clean.

C++ has array-new, placement-new, and class-specific-new. C++ “new” almost always hits the heap except
– except placement-new
– except you can customize op-new for your class to hit your allocator.

C# “new” doesn’t always mean Heap. The code “new MyStruct” usually hits the stack rather than the heap. See P55[[c#precisely]] for a nice diagram.

C# actually gives 3 unrelated (mildly confusion) meanings to the “new” keyword. One is the Java meaning. The 2nd meaning is “hide base type Member” and can apply to
* virtual methods — Most confusing
* non-virtual methods
* fields
* nested classes/interfaces
* events??

“Type” can be a base interface.

3rd meaning – select-new creates an instance of an anonymous type [3]. See http://www.dotnetperls.com/select-new.  http://stackoverflow.com/questions/2263242/select-new-keyword-combination is a summary of select-new

[3] java also let’s you create an instance of an anonymous type but you need to specify the supertype.

max throughput vs max concurrency

I now feel this is a a bit too academic. In practice, I feel concurrency is a technique to achieve throughput.

“max concurrency” is a system feature and probably means “full exploitation of processor and threading capacity”. I know a single SUN processor can have 4 cores and 32 concurrent kernel threads. In such a system, it’s also possible to create user-level threads so total concurrent threads can far exceed 32. I would think thousands are possible.

“max throughput” is a tangible benefit. I think it’s measured by the max number of completed requests per second. The highest throughput is usually achieved in latency-insensitive batch systems rather than synchronous or asynchronous request/response. The fastest way to transfer billions of terabytes of data is to load flash drives on trucks and ship to the receiving site – batch mode.

Max throughput requires finding out bottlenecks. Throughput of a given system is the throughput of the “narrowest” or “slowest” link on the critical path. Adding concurrency to the bottleneck spots (not other spots) improves throughput. For a realistic system, people would buy the max amount of memory they can afford to avoid hitting disk, put in a lot of processors, and somehow multiplex I/O. In low-latency systems, network I/O is often the biggest latency contributor. People use java NIO and exchange collocation, among other things.

Other concurrency techniques include partitioned table, parallel query, disk array, grid and cloud computing.

By “narrowest” I mean the high-way. The more lanes, the better the throughput. A 32-thread processor has 32 lanes. Each thread has a capacity limited by clock speed and software synchronization – that’s what I mean by “slowest”.