Sunday, December 16, 2018

YCSB ( Yahoo's .. Benchmarking )

Abstract :

 Introduction :

I was working with YCSB for a week or so. I wanted to benchmark redis performance for READ adn UPDATE. By default YCSB implements READ, UPDATE using redis commands hgetall and hset. As the YCSB workload does not already do any pipelined Read and update operations. I had tweak it the redis client bindings to YCSB to achieve that.  And coming from a kernel background i was not familiar with the building such java based benchmarks.
I could easily get started by downloading the build snapshot as instructed in the README. So to start with the code i had to clone it form the github repo and started looking at the code. I could find the build command quite easily in the README. But it was not going to be so easily.

It uses maven to build the whole project, so i figured i could use an option -pl to build only redis-bindings instead of building for all the database bindings.
In one of my machines it would not build throwing some exception related java heap. So i moved to another machine.

As started tinkering with the code, what i cared the least was the indentation, but some how the maven build would throw error for indentation and spacing and wouldn't  build. I could not figure out a way to avoid that and had to comply. One of the other things was the indentation was quite different from what i see in linux kernel. It expected to 2 spaces for every next level of indentation, unlike a 4 or 8 spaced tab.

YCSB abstracts the DB client side code quite nicely, and provides hooks like abstact methods like read() and update() which one can implement on the client side.

I had to just go and change some code here to get my things done. YCSB uses jedis, ( redis Java APIs)  to implemetn redis client. I needed to know the basic redis commands and then how to send those commands using the api. Then i needed to figure out how to pipeline it ( and in the meantime i got to know that it has a feature called transaction ).

Just a brief about it , Redis is in-memory data base and commands directly change the contents on the server. Redis's pipelining feature does nothing but makes the command execution asyncronous or non-blocking. You could send n number of commands and collect the response at a later point of time, hence not waiting for the pervious one to finish.

Redis uses Pipeline class to do that. This is a nice tutorial to get stated with. Generally the tutorials introduce both transation and pipelining togethere which becomes confusing to understand which api is meant for what. But this blog helps bring clarity. Basically Transaction makes sure that a set of commands are executed  atomicly and nothing to do wtih pipelining. But beacuse they are syntacically same, it becomes  confusing.

With all the required changes i could sucessfully build it but , as i had to run on a different machine just copied the whole build set up. Which was a mistake. It would give me errors saying that it could not find some classes in the classpath. I figured out , that it creates the snapshot of the build in a tar.gz and a jar. By simply extracting this tar i could use the binaries, without any errors.

It was quite some learning. I enjoyed it.

Friday, April 8, 2016

Bash auto complete for a script

What is the problem ?

I mostly write  a shell script for some trivial tasks, its saves lot of typing and hence time. Initially its kind of hard coded , works for exactly one thing, But as i start using more often, i tend to make it more flexible with command line arguments. Guess what after a while i come down to same amount of typing by typing everything as a argument or write a new script that calls it with parameters.

 But with all of these i felt like it was not efficient because for most commands when i type the arguments , tend to auto-complete on TAB, definitely saved a lot of typing.

Whereas, when i write my own script , even though the parameters were same/similar, it would not auto-complete. It was obvious how will bash know what arguments should be suggested/auto-completed to.

I was curious to figure out how does it work for normal commands like ssh, which could auto complete even with '@' in between. So first i will tell the solution i did for myself and also explain how it

Solution :

On googling i figured out that i could add autocomplete for custom commands or scripts by adding a new script in  /etc/bash_autocompete.d/* . ( To source it the effect immediately you can source ).

These auto-complete scripts seems to do nothing much but , create an array of options that were possible and print it when requested for a auto-complete for a certain commands. There are some standard parameter types like host_names, users, etc. you don't have to do even that. "complete" is a command line utility which has in some in built capabilities to do that.

Well i only wanted to have hostname as parameters so , i could do that with a simple one line script put in /etc/bash_autocomplete.d/

compete -F _known_hosts <script/command>

in my case it looked like this :

compete -F _known_hosts ./login 

How does it work already for installed commands/utilities? 

In fedora 23 (Others should have a similar approach , but need ot check on that) which i am using, the pre-installed commands have autocompletion. It comes from the script located in  "/usr/share/bash-completion/bash_completion". This gets loaded for every new bash session.
The call chain is  :
.bashrc -> /etc/bashrc -> /etc/profile.d/bash_completion.sh ->  /usr/share/bash-completion/bash_completion 

Well this is only true for very basic commands. Each command has its own the auto complete script in /usr/share/bash-completion/.
Wow! that's a treasure. This should cover most of the kinds of arguments, just reusing this might actually make it easier. 

Next we will see how does a newly installed command installs its auto-complete script. Sounds exciting??  Stay tuned!

Friday, April 26, 2013

To be or not be Dr


 Abstract :

Dilemma of whether to go for a PhD was the question at hand. I did some research to arrive at an answer after looking at three main parts (mainly socio-economic fronts across India, US and Europe) :


  1.  Surviving as a PhD student,
  2.  Difference it makes in a your career
  3.  Difference from a corporate career,

Motivation :


Questions about pursuing PhD has been bothering me since a year now. But as it always happen, unless you have a deadline, you don't conclude. I had always dreamed of being a scientist, my innocent motivation to PhD. Moreover, I found quite a few people who were in a similar situation. I set myself up to figure out what's in store apart from being a scientist as a PhD and the journey for becoming a Doctorate.

Conclusion :

I have always chosen things which opens up more opportunities. In other words, I have always restrained my self from choosing something which channelizes my efforts and look at a bigger goal.

I have discussed on public forums, read books discussed with colleagues , profs, PhD students and concluded. Currently, I am not prepared to be a doctoral student. Hence, decided not to go for PhD immediately after my Masters. (Keeping my options open ..).

Sunday, November 18, 2012

Kalman Filter simplified

While trying to understand what "Kalman Filter" is all about, I encountered that there were very less instances when people have explained in layman's terms.

After searching a lot , I have came up with a combination of three sources which can help you grasp this concept in a easier way.

Before we move on, I always consider a one line description/definition which we can always look back.

First line in the Kalman's Original paper [1] tell us that :
    its a "recursive solution to the discrete-data linear filtering problem"
just re-framing it  :
   "recursive solution for digtal filters"

If you are familiar with digital filters  (low butterworth filters ,etc) it manipulates the incoming data according to the given constraints. Keep in mind frequency is not the only way to characterize a signal. What if one cannot quantify the constants in terms of frequency,wavelets,etc? We land up to something called stochastic method, where we consider variables to be random (with certain constraints) and essentially don't try to characterize in a terms of a "feature" like frequency.

When we are looking at a digital filter, what we should be looking for is :
> type of input
      Discrete-time data. this data can be either scalar or vector.
      E.g. of discrete time scalar data : x
      At t=1 , x=4; At t=2 , x=2; At t=1 , x=8; At t=1 , x=6 ;

> type of constraints and how to apply?
     Constraint is given in terms of Model parameters ( coefficients of the equations given by Kalman )
     Kalman arrives at a linear stochastic equation which is generalization of system prone to noise.
     We apply the constraints guessing the behavior of the system and noise.

> suitable applications
   Filtering noise in most signals (sampled at certain rate). Majorly, used in noise removal from measured quantities when the behavior of the system is known.

The three sources are :
1)  Buffalo tutorial :
start by refering to the block-diagram on page 6. and the description of the variable on page 2.
This will help you visualize what these equations are about.

2) Bilgin's Blog :
  Awesome blog on Kalman filter. It tell you every thing about how can you apply Kalman filters.

3) Cornell course material   :
  Refer to the example of  measurement of water level in tank. This could give a good ending to your pursuit of learning kalman filters.


References:
[1] Kalman, Rudolph Emil. "A new approach to linear filtering and prediction problems." Journal of basic Engineering 82.1 (1960): 35-45.

Sunday, July 1, 2012

understanding DDR2 RAM modules

I was looking for a proper way to understand the working of a DDR2 SDRAM modules which are readily available in the market. I wanted to understand how to interface, but i figured out that its important to know the a about the working.



I figured out that , one can understand by following the following sequence:
1) Look for a Micron DDR2 data sheet.
    - This will give you an idea about the SDRAM 'Chip' on the modules you buy .
2) Then if you look for DIMM(Dual in-line memory module). wiki page is good enough to give you a good idea. Consider looking for SO-DIMM, which are used for Laptops and even Mini-DIMM ,which are used in some of the development kits .
3) Now you may look for difference b/w buffered and unbuffered  modules.

By the end i feel one may completely understand the working of DDR2 modules.

Monday, June 18, 2012

Idle mode disables JTAG interface in LPC2378

I was working with MCB2300 a ARM7 development/evaluation board from Keil. It has LPC2378 , a 32bit 144pin ,ARM7 by NXP .
Interestingly , when i started working on it , around 8 months before , i couldn't figure out that it had Serial ISP. The online userguide on Kiel website is not very friendly.

So, I am an expert in messing things up. I asked the mcu to sleep , but did not tell when to wake up. So whenever i reset the system , the system did perform some task and within miliseconds it would go into Idle mode.
  PCON |= 1; // MCU goes into idle mode

When i tied to program it using JTAG , it won't respond. I was not able to program .Finally, I asked in forums (ARM and Kiel).
It was pretty simple , if JTAG goes down, go for Serial ISP.

Need to put some jumpers on (ISP and COM0)
remove ETM jumper if there.

Erase flash using flashmagic @ 19200 baudrate .
It not done, you need to put it some new code to see whether you Ulink JTAG debugger is not faulty.

I was very happy that Kiel and ARM guys had replied so fast.

Friday, June 8, 2012

Agilent Soft touch pro

Working with Agilent Logic analyzer , I was thrilled to see the technology that has come up in the field of debugging .

I realized lately that XUP-V5 board has a mictor port available for debugging. Mictor stands for Matched impedance connector , very useful for capturing high speed signals and it also captures lot of signals in a small footprint.
Mictor Connector

After this I saw the Soft touch pro , an awesome implementation of contact-less probing . No its not actually contact-less, but it like the probe just touches the pads/lands. Though it has an overhead of soldering additional holder around the trace temporarily, its can be incorporated in end products. No extra cost on connectors on each board, and small foot print a win-win combo. Only thing is that one needs to buy a Agilent soft touch pro connector , which might cost heavily.

Dying to try them all.

Digitally Controlled Impedance

Working with Xilinx Virtex5 FPGA , I found this feature called DCI (Digitally controlled Impedance) very interesting. 

If we have an IC with several hundred pins and one wants to pull up all the GPIO pins through a resistor and further connect it to some simple device say, switches. Then in a conventional scenario one needs hundreds of resistors to be connected. This increases the area consumed. 
If the IC has DCI, it will match all termination resistors(which will be some transistors already fabricated on the chip ) to this reference resistor and terminate internally. This decreasing the resistors required and the area.

I know only from the application point of view , but will look into how is this implemented in near future.

Wednesday, May 23, 2012

Online compilers a Boon

Sitting on a public computer , its is mostly impossible and feasible to install a compiler and start coding . On line compiler websites, is helping me out of these kinda situations .

 These compilers not only check the syntax but also link it for either windows or linux.
http://www.onlinecompiler.net/
Check out if you are in the same kinda situation. hope it helps.

Saturday, May 19, 2012

Using CAN on LPC2378 Simplified

I had worked on it last semester .The LPC2378 usermanual and the example codes were very helpful . To get started , one can just modify the example codes without understanding function of all the registers . I have given a basic view of how can one implement a CAN protocol using the CAN controller . I  have not discussed the Acceptance filters and the error management. This should give a good kick start to a CAN based project.








Prototype based on MSP430 : Design Issues

Level conversion is just not enough always for a proper UART communication between two devices working at different standard voltages , normally 3.3V and 5V.

This issue crops up when we try to interface a sensor working at 5V [which generally is the case], to a controller or processor working at 3.3V. In our case , we were using the GSM modem which gives a 5V serial UART output and MSP430 powered at 3.3V.

We understood that we need a MAX232 for proper protocol conversion. Without MAX232 we were getting some deterministic values but not correct ones . The reason i feel is that the logic levels are set as -5V and 5V for uart communication , but as we have matched the ground , there may be problems with required voltage levels not getting matched.

A tip : A debug method i use to check whether the rx lines are connected properly. If you ground the rx pin and pull it out , it must give you an ascii character something like  "???" . That's pretty interesting , we done guys ascii codes + uart combined is intelligent enough to tell us "What the F are you doing ??". So if you are getting values like this probably you have loosely connected to gnd  :p.

Believe me its fun to debug this way if your rx wire is crossing 2-3 boards to reach the destination. 

Friday, May 18, 2012

Protype based on MSP430

Together with my friends, we had participated in the TI MCU contest 2012 . It was a good experience of completing the whole design flow for a prototype within 5-6 days.

A small description of the proposed system. Cargo traking system , consisting of sensors ,like accelerometer, GPS reciever , humidity sensor and temprature sensor, communicates the readings of the sensors in a meaningful way to the customers . A GSM modem is used for communication.

Cleary, GPS , GSM and accelerometer, were the USP's . I would describe a bit about the issues we faced while creating this system using MSP430 Lauchpad provided by Texas Instruments.

GSM modem : If you go through the wiki page of RTS (Ready to send) pin of the RS232 DB9 connector. you will clearly understand that though we use only three wires(Tx, Rx, Gnd) for UART communication it is not always true. modems in perticular  requires additional signals like RTS and CTS according to the application. It is not necessary to dedicate a pin of controller for these signal . As they are just signals to start or stop data transmission, in other words they mere flags . Solution is simple , in  the serial being used , we must send the signal back to the modem[ just short them].

Getting started FPGA board design

This summer i am working with Dr Kota Solomon Raju, Senior Scientist at CEERI, Pilani and my classmate Kunal Kedar on FPGA board design. The aim would be develop a complete understanding of what is required to make a stand alone FPGA system , which can be further used to some application which needs custom peripherals to be interfaced.

We are going to design it for Virtex 5 series . We are currently looking at only 2 packages FF1136 and FF1760. We will be using a Virtex 5 AFX FF1136 Proto board to test the design .

The first task was to understand the pins of the FPGA. Unlike other Integrated circuits , all the data about the FPGA cannot be put into one document . So Xilinx provide different documents addressing different users and aspects . The pin information document is what we are looking at. First we have created a simplified layout of pins considering the similarities of the io banks. It cannot be understood in a single , one needs to do two to three iteration to draw a optimal and meaningful pinout .

Tuesday, April 3, 2012

Need to Standardize Simulation Reference Manual



In this age of information, we lack what i call it as 'common interface' to the knowledge and knowledge about the developed tools.

My idea is why don't we have a Standardized way simulators are documented .

Out of many such great tools made by humans one is simulation by computer programs . they help us study without breaking our heads setting up for experiments .Being an electronics engineering student , I understand the necessity as they might cost you billions :P.

Most of the research , I feel first goes into modelling a system/material/whatever . This opens up the scope for all the other people with brilliant ideas to come in. And this new things (invention/discovery) catches fire .. all the researchers around the world come up with possible applications in their respective domains. Hence , the world progresses much faster.

[This blog is mainly inspired from Professor N.N.Sharma , his lecture on simulation and modelling behavior of materials/physics in micro-domain ]

If one looks at the history , the universities/research groups would publish a model. And these publications can only be understood by researchers who were working in that field.

If somebody wonders how these models look like ? Then they are not beautiful at all, like our (super)models :P . In fact ,they might be some long differential equations of some 8-9 order . Too complicated for anyone to solve these models on paper.

With the increase in production of computers , these things became a bit easier . But still ,some one had to teach (program) those stupid computer :P.

Now we have fast but still stupid computers . In the mean time we have developed some good platforms (Java,.NET,) and graphics etc.. . We were all equipped to make simulators , which did all the number crunching without users knowledge. Doors were open for guys from other disciplines to try-out somethings that their techniques. Still, most of the simulators would return some numbers , hence required some knowledge of programming was essential to use it efficiently.

Approaching this age of interdisciplinary research , mostly due to saturation in the core disciplines . Simulators have played a very important role in pacing up the research.

As industries saw potential and took interest in simulation softwares . We have landed into a world where we have 3D graphics , animation , math solvers ,etc .. all integrated into simulators. Now , people think simulators are the only ones which can show some graphical output , which includes some of out faculty members .

This is not it . We have 3D graphics , fine . Good interface , fine . We have all the features can be simulated , great . But , I have worked so hard to understand the previous simulator why would I switch to something else , and why is it necessarily so different ? I look at the getting started tutorials trying to relate what my old simulator had ? When i go through the Help and documentation , the layout seems to be completely different, takes a whole lot of time to figure out where to look for ?

My idea is why don't we have a Standardized way simulators are documented .

There are lot of open source groups who have standardized their documentation , so that they could increase readability , as they get contribution for lot of people around the world and any body should understand it . If a person understands the basic way how to look up a reference maual / user-manual , he should be able to switch to the new ones faster .

Attempts are being made by companies to provide special manuals for smooth transition from others products to theirs , but all these can be saved, if this happens .

Thursday, December 8, 2011

Change Gmail back to old look

I lost few of my hairs looking for the ' revert to old look temporarily ' button. So I thought this would help people get back their lives (old Gmail).

Its basically confusing which gear (setting) to choose. If you choose the usual top-right , then you are on the wrong way. This page has 2 settings button. One on the corner of the page and one just beside the mail navigation keys. The latter is the one you are looking for.



Saturday, November 12, 2011

Time taken to execute the c program

I was executing a C code which was a loop of 65535. It was basically , a program which was testing the outputs for all possible values and hence can say, testing the algorithm.

I used the gcc compiler to compile the c code. When i executed the code it took a good 5-6 secs to complete the execution. But now we all know the command prompt window could display only a few hundred recent lines . So i decided to print the output to a text document using the
a.exe > sample.txt
command. To my astonishment , the code was executed in less than a sec. All this could only inspire me to check out ' how could i know the clock cycles required to execute the program.

it took some google searches to know that clock() is the function i was looking for which is in the header file time.h .

here is the glimpse of the program.

#include
main()
{
long int i;
clock_t clk;
// write your code here
for (i=0;i<10000;i++)
{
printf("%ld",i);
}
//say your code ends here

clk = clock(); // clock fuction give the clock cycles elapsed since the start of the program
printf("the no of clock cycles required to execute the is %ld",clk );

}

clock_t is long integer type of data type defined in sys/types.h
the function clock() returns a value of type clock_t so we need to declare a variable of this type .


P.S. : the clock cycles taken by the program would differ based on the other processes running on your system. one should keep in mind that , it does not give the time taken by your code to execute if it is the only process running. But it gives the time taken in the current complexity of the processing environment.

Thursday, September 8, 2011

15 min Alarm part3

This is the 'relative time' based reminder. it will play a song every 5 mins , one can always change the time . The time specified is in seconds and cannot exceed 999 secs.

REM File name: Reminder.bat
REM Description: this is a Batch file that plays a song every 5 mins.
REM one can change the time by changing the number of secs which is here as '300' in the CHOICE statement.
REM The song can be specified in place of "D:\dwnlds\AIRTEL.wav"
:again
echo off
CHOICE /n /C 12 /d 1 /t 300
if errorlevel == 1 goto sing
if errorlevel == 2 goto sing

:sing
start "C:\Program Files\Windows Media Player\wmplayer.exe" "D:\dwnlds\AIRTEL.wav"

15 min Alarm part2

So , here i am with the code. Rather i have two. I have one which is based in 'absolute times' using the system clock and the other is based on 'relative time'.

This is the code for the 'absolute time' based reminder. Reminds at 10,20,30,40,50 and 00 minutes on the clock.

REM File name: Reminder.bat
REM Description: this is a Batch file that plays a song every 10 mins.
REM The song can be specified in place of "D:\dwnlds\AIRTEL.wav"
:again
@echo off
REM Takes the system time
set t=%time%
REM t2 = seconds
set t2=%t:~6,2%
REM t1 = minutes
set t1=%t:~3,2%
REM One can specify at what minutes do you want a reminder
if %t1%==00 goto alarm
if %t1%==10 goto alarm
if %t1%==20 goto alarm
if %t1%==30 goto alarm
if %t1%==40 goto alarm
if %t1%==50 goto alarm

REM provides a delay of 1 sec.
CHOICE /n /C 12 /d 1 /t 1
cls
if errorlevel == 1 goto again
if errorlevel == 2 goto again


:alarm
if %t2%==30 goto sing
cls
goto again


:sing
REM can provide the link to the desired media player like VLC,etc.
REM provide the link to the compatible audio file .
start "C:\Program Files\Windows Media Player\wmplayer.exe" "D:\dwnlds\AIRTEL.wav"

REM provides a delay of 1 minute.
CHOICE /n /C 12 /d 1 /t 60
cls
if errorlevel == 1 goto again
if errorlevel == 2 goto again
goto again

Wednesday, August 24, 2011

15 min Alarm part1

Inspiration:
When i set myself up for surfing on internet, i usually tend to sway away form what i originally intended. Moreover, i exceed the time limit i had decided upon. One of my friends, made a periodic alarm for himself to get more focused on his job. I really don't know weather it is available already or not. But the happiness of running your own code is definitely more satisfying than anything else.

the reason to choose to make a batch file is that
- i wanted it to be in an un-compiled form so that one can adjust it as and when required .
- one can open on a double click.
- it should not be very complicated.

I will put up the code in my next blog..

Tuesday, December 15, 2009

About This Blog

I am perusing ME Embedded Systems from BITS-Pilani, Rajasthan.

I have completed Electronics Engineering Student From NIT ,Surat.

This Blog Will mainly contain the Experiences related to my works in the Field of computers .

I have another Blog in which i Publish my blogs related to Electronics and communication.

So , one can always check my Blogs out at akshayadiga.wordpress.com .

My Upcoming Blogs Will be Related to Operating System By Sun Microsystems -Opensolaris.

Its About a Application Porting Project which I had completed Two months Ago.