Articles & Nouns

Using Articles : 

The evolution of man / The book is about evolution ( use article “the” when you are referring to something specific, like the water in sonoma creek, but when you refer to water in “water is an essential part of life and air is too, but the air in LA is bad )

Articles & Singular Nouns : 

  • A pencil contains lead 
  • I need a Pencil 
  • The Pencil on that desk is Jim’s 
  • My Pencil is on that desk  ( is better than ) The Pencil on that desk is mine 

Articles & Plural Nouns :

You don’t need to use articles at all when you have plurals, except for specific objects  

  • Pencils contain lead 
  • Bob has some pencils in the pocket 
  • The pencils on that desk is Jim’s 
  • Bananas are yellow ( is better than A Banana is yellow )

Articles & NonCount Nouns : 

  • I like music / The music is too loud 
  • I would like to have some water 
  • Food is good for you / The Food in this bowl is good for you 

Note : You can’t use many for non-counts 

Examples : Food, Water , Furniture, Luggage, air 

Some of the usage of Non-Count Nouns 

  • Knowledge is power 
  • Beauty is in the eyes of the beholder 
  • How these things came into “the” picture 

Where ever you use quantity to describe you use plural or singular based on context 

  • A Child that is 2 years old 
  • He is a 2 year old child 
  • My son is a 2 year old or My son is 2 years old 

Article & Idioms : 

They have a “Hard TIme”  ( you usually use an article based on the context , but you always use an article for Idioms ) – Idioms can’t be literally understood 

Ex Idiom – Monkeys are able to tell the difference 

Leave a comment

Filed under Uncategorized

3 knobs you should know in redhat transparent hugepage

There are 3 knobs  in redhat_transparent_hugepage/ in the order of effectiveness

  • enabled   – this is the main knob. Setting as disable will disable THP entirely.
  • defrag – THP is on. If disabled, no defrag by application thread. See note (1) below.
  • khugepaged/defrag – THP is on. If disabled, no defrag by kernel thread khugepaged. See note (2) below

 Note that defrag can happen in 2 scenarios:

  1. When application thread needs memory, it traps into kernel and tries to allocate huge page. If defrag is on, the process will try to coalescent small pages into large pages. (This is what Espresso ran into and the Hadoop blog describes)
  2. THP also has a khugepaged that tries to defrag in the background (so that more huge pages are avail and application thread defrags less frequently).

Thus echo “disable” to “enabled” is sufficient. 

Leave a comment

Filed under Uncategorized

Measuring the response bytes using jmeter

If you want/need to measure the response bytes size from the jmeter results and analyze/get the trends. Following will help

Make sure you disable the flag “Keep-alive” in your HTTP request. (Found that enabling this can skew the payload size that jmeter reports. In a thread, if the request is made multiple times jmeter tool provides the cumulative payload size instead of the individual request response bytes. )

If you create CDF for this bytes data, the graph is a straight line with very high payload data which is ever increasing. Unless you need the keep-alive for your request, disable it in your http request.

Leave a comment

Filed under JMeter

Hugepages and Java

As a data point, at a previous employer we played a little with the use of HugePages and memory mapped files in an attempt to get better performance.
Java’s support for the use of HugePages is on a best effort basis and our experimentation found that java was initially using the HugePages, but over time (a few hours), the HugePages were no longer used by the JVM—thus effectively reducing the available amount of RAM by the amount allocated for HugePages. We ended up disabling HugePages for our usage. I do not recall any concern/investigation about the Anonymous huge pages.
 
In the above case, however, we were constantly changing the memmapped files (these were large image files), since each request would access different image files, and the files were accessed over network storage.

Leave a comment

Filed under JVM, Linux

Performance impact of dirty pages in Linux

Memory (RAM) is divided into pages of equal size. A page is the smallest unit of memory that can be manipulated.

My Tech Project Notes describes Dirty Pages as

Dirty pages are the pages in memory (page cache) that have been updated and therefore have changed from what is currently stored on disk. This usually happens when an existing file on the disk is modified or appended.

Page cache on a Linux system is the area where filesystem based I/O is cached and that these settings affect how the cache is utilized by the kernel.

We can tune pdflush to determine how much RAM based cache to use for (dirty pages) data targeted to disk and how frequently to flush that cached data by writing the pages back to disk.

There are two types of flush to disk in Linux and parameters / ratios controlling how often they are triggered

1. Stop the world – Controlled by dirty_ratio.

This is the Big ass flush, that will lock the memory during the flush, the ditry_ratio determines the threshold based on the total size of the Memory/Dirty page Cache  ( Dirty page cache size is not the same as total RAM size, its usually less than total RAM size)

For example, if the dirty_ratio is set to 20%, or 0.2, a “stop the world” flush is invoked when the dirty page cache is  20% full.

2. Background Flush – controlled by dirty_background_ratio

This is a intrusive flush, similar to CMS in JVM, which happens in parallel and does not block the memory for reads and writes.

The default value for dirty_background_ratio is 50% of dirty_ratio, or any value lower than 50%  of the dirty_ratio set by the admin.

for example, if you set the dirty_page ratio to be 20% and the dirty_background_ratio to be 20% as well, then the kernel will set the dirty_background_ratio to 10%.

the logic in the kernel would look something similar to this.

If ( dirty_background_ratio >= dirty_ratio )

{

dirty_background_ratio = dirty_ratio / 2

{

Leave a comment

Filed under Linux

BeanShell Assertion in Jmeter

Below is a quick example of Assertion using BeanShell in Jmeter –

if (ResponseCode != null && ResponseCode.equals ("200") == false )
{
// this is standard stuff
Failure=true ;
FailureMessage ="Response code was not a 200 response code it was " + ResponseCode + "." ;
print ( "the return code is " + ResponseCode);   // this goes to stdout
log.warn( "the return code is " + ResponseCode); // this goes to the JMeter log file
} else {
String body= new String(ResponseData);
if(!body.contains("pagekey-abook_imported_contacts_to_invite"))
{
Failure= true ;
FailureMessage = "expected pagekey-abook_imported_contacts_to_invite != " + vars.get("pagekey");
print("DisplayImportedContacts failed for ticketId=" + vars.get("polling_id"));
log.warn("DisplayImportedContacts failed for ticketId=" + vars.get("polling_id"));
}
}

1 Comment

Filed under Uncategorized

Useful links for Regular Expression (RegEx) in Java

Regular Expression RegEx is one of the unsung heros in application development, it does not have the same appeal as terms like “pattern recognition”. Many developers are not comfortable admitting to customers that they use regular expression for extracting or manipulating data.

Regular expression is more popular among scripting languages like perl or python. Since these languages are usually used for developing internal tools, regular expressions are not a taboo and are freely used.

There are legitimate concerns about using regular expressions in  applications as they introduce dependence on the format of data and hence making your application vulnerable to changes in data format.

But if you know that your data format will not change frequently you can try using regular expressions in your code. If you are interested the following resources are a good place to start.

Reference :

Regular Expression Primer

Regex Patterns in Java

 

Leave a comment

Filed under Java