How less processes its input

Here’s an interesting bit I ran into few days ago. I got curious how is that less (or more) can read file contents from standard input and yet it is able to process input that comes from user. Both of them come from standard input, yet these are quiet heterogeneous streams of information. So, how can it be?

Read the rest of this entry »

I got a new job, take 3

I got a new job, again. Dell decided to obtain what have left of Exanet LTD, a company I worked for in the past. They kindly decided to offer a job to majority of ex-Exanet engineers, me included.

So, I decided to leave Fabrix and as of last week I am software engineer and senior consultant at Dell IDC (Israel Developer Center).

What is direct I/O anyway?

Few days ago I’ve written a post explaining how to do a direct I/O in Python. But then I thought that it might be a good idea to explain what direct I/O is. So, here we go.

As surprising as it is, when you write some information to the disk, it doesn’t get there immediately. In Linux especially, the kernel tries to cache write requests in memory as much as it can. This means that in addition to writing the data to the disk, kernel keeps it in memory. Consecutive read request to the same place on the disk will be much faster because there’s no need to read the information from slow disk – it is already in memory. On the other hand, the information goes to the hard-disk only after some period of time (short though) or when the system runs out of memory. In the meantime, Linux reports that data has been written, despite it is not yet on the disk. Read the rest of this entry »

Recursively deleting symbolic link and what it points to

Recently I looked for a solution to this little problem. how do you, programmatically, delete a symbolic link and a file that it points to?

One problem that you should take care of when tackling this problem, is that symbolic link can point to a symbolic link. Then symbolic link should also point to symbolic link. And once again, and again and again…

Read the rest of this entry »

Direct IO in Python

Doing file I/O of any kind in Python is really easy. You can start with plain open() and friends, working with Python’s file objects. by the way, Python’s open() resembles C‘s fopen() so closely that I can’t stop thinking that open() may be based on fopen().

When its not enough, you can always upgrade to open() and close() from os module. Opening man page on open() (the system call – open(2)) reveals all those O_something options that you can pass to os.open(). But not all of them can be used in Python. For example, if you open a file with O_DIRECT and then try to write to it, you will end up with some strange error message.

Read the rest of this entry »

I got a new job, take 2

I got a new job, again :-) Today I signed a contract with a company named Fabrix.TV. Fabrix is developing a new generation of video content delivery platform.

I am joining as a chief video content consumer senior software engineer.

Rethinking linked list insertion

There is one nice thing in looking for a new job. That is, you meet lots of new people and have a chance to learn from them. For example in one of the companies I was asked about something called anti-debugging. I didn’t have a clue what that is and had to ask for an explanation. Apparently, this is a set of techniques used to fool a debugger and make the code undebuggable.

Anyway, here’s something else that I learned during one of the interviews.

Read the rest of this entry »

I am looking for a new job

I am sorry to say that, but Exanet, a company that I joined less than a month ago, has been closed.

This means that I am looking for a new job. The good thing is that now your or your friend’s company has  a chance to hire a programmer with ten years of experience in writing application for Linux and Linux kernel. So, if you can help, please pass my resume. You can find it here.

Thanks.

Alex.

I got a new job

You probably noticed that I didn’t write anything new for awhile. Well, I was looking for a new job and didn’t have much time to write. Luckily, this is over. I am now a senior software engineer at Exanet LTD.

Exanet is developing storage solutions for large organisations. ExaStore, main product of the company, is a clustered NAS gateway solution providing highly available and distributed data storage.

MSI-X – the right way to spread interrupt load

When considering ways to spread interrupts from one device among multiple cores, I can’t not to mention MSI-X. The thing is that MSI-X is actually the right way to do the job.

Interrupt affinity, which I discussed here and here, has a fundamental problem. That is inevitable CPU cache misses. To emphasise this, think about what happens when your computer receives a packet from the network. Packet belongs to some connection. With interrupt affinity the packet would land on core X, while the chances are that previous packet on the same TCP connection has landed on core Y (X ≠ Y).

Handing the packet would require kernel to load TCP connection object into X’s cache. But, this is so ineffective. After all, the TCP connection object is already in Y’s cache. Wouldn’t it be better to handle second packet on core Y as well?

Read the rest of this entry »