If you made your mind what field you want to work within, consider joining specialized scientific mailing lists related to your field. It's very useful to be on the same mailing list with pioneers of the field. Subscription at such mailing lists give you the following benefits:
- Notifications about call-for-papers/participation at conferences as well as deadline extensions.
- Notifications about special issues at journals.
- Announcements on PhD/MSc opportunities and scholarships.
- Announcements on Research-Assistantship, Post-Doc and relevant job vacancies.
- Resources and tools made available for research community.
- Discussions on research directions by professionals in the field.
Following are examples of fields and respective mailing lists:
- Natural Language Processing: Corpora-list
- Data Mining/Databases: KD-Nuggets, DB-World
- Social Network Analysis: Socnet
- Machine Learning: ML-news, UAI
- Neural Nets: Connectionists
- Information Retrieval: SIG-IRList
Thanks to Hossam Sharara for inspiring this post.
This blog is about R&D in computer science and related fields. It's designed to be a good guide for juniors going into R&D, without getting into details of any particular field (e.g. machine learning). Blog posts will be related to "writing papers", "scholarships", "the PhD experience", "difference between scholar, governmental and industrial research"...etc.
Friday, April 30, 2010
Tuesday, April 13, 2010
Previous research experience (if you plan to apply for a PhD program)
This post is the third episode featuring Prof. Mor Harchol-Balter's talk advising people applying to PhD programs in computer science or related areas.
[first episode - second episode - full article]
As I’ve said earlier, to get into a top graduate school you need prior research experience. This is not necessarily true for schools below the top 10, or maybe even the top 5. Note that prior research experience does not mean that you need to have published a paper. It does not even mean that your research needs to have yielded a result – results can sometimes take years. We just need to have confidence that you know what doing research is like. At CMU we receive hundreds of applications each year from 4.0 GPA students who have never done research. These are all put into the high risk pile and are subsequently rejected.
So the question is, where can you get this research experience?
There are five places where you might get research experience:
...
Warning for international applicants: The admissions committee needs to be able to evaluate your research. If your publications appear in conferences/journals which we are not familiar with and have no access to, then we cannot evaluate the quality of your work. In my experience, this usually leads us to discount such publications. If you don’t want this to happen, here are two things you should do:
[first episode - second episode - full article]
As I’ve said earlier, to get into a top graduate school you need prior research experience. This is not necessarily true for schools below the top 10, or maybe even the top 5. Note that prior research experience does not mean that you need to have published a paper. It does not even mean that your research needs to have yielded a result – results can sometimes take years. We just need to have confidence that you know what doing research is like. At CMU we receive hundreds of applications each year from 4.0 GPA students who have never done research. These are all put into the high risk pile and are subsequently rejected.
So the question is, where can you get this research experience?
There are five places where you might get research experience:
- As an undergraduate, you can do research with a professor. I did this. You can even get course credit for this, and sometimes if you’re really lucky you can get paid a little (e.g., during the summer).
- As an undergraduate, you can apply for a summer internship at a research lab, e.g., AT&T. I did this. They will pay you a little and you will learn a lot about doing research. This was a great experience for me!
Here’s the web site for the AT&T summer program that I attended: http://www.research.att.com/academic/ When you go to this web site, click on “Special Programs and Fellowships.” - After graduating, you can get a job, where sometimes you can do research on the job. I did this.
- As an MS student, you will work on an MS project.
- You can work alone or with a friend. Ask professors in your classes to tell you about interesting open problems and new research (most professors enjoy doing this). Ask them to tell you names of conference proceedings. For example in my area (performance modeling of computer systems) a relevant conference proceeding is Sigmetrics. Sit down and start reading these proceedings. You will come across all sorts of interesting problems. Think about how you can improve upon the solution proposed in the paper.
...
Warning for international applicants: The admissions committee needs to be able to evaluate your research. If your publications appear in conferences/journals which we are not familiar with and have no access to, then we cannot evaluate the quality of your work. In my experience, this usually leads us to discount such publications. If you don’t want this to happen, here are two things you should do:
- Publish in internationally recognized conferences – ask your advisor.
- Create a web site that has links to all of your papers in English in either postscript or pdf. Explain in your application that all of your papers can be found on your web site.
Tuesday, March 16, 2010
How to become a star grad student
In this article, Cal Newport tries to answer this question. He takes James McLurkin as a case study, and starts by explaining how far one could be recognized in his field, and why this is so important.
“Four years earlier, Time Magazine profiled James as part of their Innovators series. The next year, he was featured on an episode of Nova ScienceNOW. Earlier this year, TheGrio, a popular African American-focused news portal, named James one of their 100 History Makers in the Making.”
“In other words, James is famous in his field. So it’s not surprising that in 2009 he landed a professorship at Rice University — one of the country’s top engineering schools — in one of the worst academic job market in decades.”
James' stardom started when he designed a swarm of microbots 'Ants' for his senior thesis project (i.e. graduation project). The devices were designed to perform complex behavior using simple rules. The paper in which he documented this work spread out to the public media, making a star out of James.
“I went to the lab as an undergrad to interview for a position,” James recalls. “Anita Flynn told me they’re not hiring. So I came back with some robots I had built, and some I was halfway through building, and she said, ‘okay, you can work in the lab, and use our parts, but we can’t pay you.’”
Once in the lab, he worked real-hard on one project after another; each stretching his abilities a little bit. He wasn't alone in the lab though. Anita Flynn was shrinking the size of electronic motors, enabling the micro-robot revolution, while Maja Mataric was a leading thinker on robotic swarms.
“By the time he conceived of the Ants project for his thesis, James was an accomplished robot engineer with a number of successful projects under his belt. He also had a cutting-edge knowledge of microrobotics, and was “marinating” in a lab environment obsessed with biologically-inspired systems. With this in mind, the idea of building a robot swarm that behaves like insects was not a big hairy audacious goal to him.”
It was James' knowledge and expertise in cutting-edge techniques in his field that enabled him to take an unprecedented step. To him (and others with equivalent level of knowledge and expertise), Ants was an obvious incremental step. To the rest of the world, including less-aware people in robotics field, it was a huge breakthrough. Cal concludes that, to become a star, you should focus on getting to the bleeding edge of your field as quickly as possible.
“Many graduate students, for example, never arrive at the bleeding edge of their field. Instead, they reach a comfortable level of knowledge — enough to understand relevant research, and make their own acceptably-complex contributions, but not enough to make bold advances. Thousands of chemists could understand Watson and Crick’s 1953 paper on the double helix, but only a handful had the knowledge needed to have discovered it for themselves.”
Now, the obvious question is how do you get to the bleeding edge?
“Every semester, my supervisor, Anita, had me write out goals,” James told Cal. “We would go back at the end of the semester and look at what I did and didn’t do. She would tell me, ‘it’s fine that you didn’t get this all done, but what’s not fine is your inability to estimate how long something will take.’”
James deliberately chose projects that were hard enough to stretch his ability, but reasonable enough to complete in the available timeframe.
“With this in mind, I argue that the secret to James McLurkin’s success is his ability to choose the right projects. By resisting work that reinforced what he’s comfortable with, yet also sidestepping overly-ambitious projects, he consistently advanced his skill until he arrived at the bleeding edge of research robotics. Once there, the “breakthrough” projects that cemented his reputation became obvious next steps. Stretch projects are an effective way to integrate deliberate practice into fields without clear competitive structures and coaching”
To emphasize, Cal gives two definitions:
Stretch Project: A project that requires a skill you don’t have.
Stretch Churn: Number of stretch projects you complete per unit time.
In order to make it to the bleeding edge, you need to maximize your stretch churn. You need to be in a continuous discomfort learning new things and resist the tendency to reinforce what you already know.
Uh.. I think this comment (in response to Cal's article) is also worth quoting
“Nianu: What kind of stretch projects would you recommend I start to tackle? I have a hard time thinking of what would be a good way to start as I am still early in my college career.”
“Cal: College and graduate-level courses are stretch projects in themselves. They force you to acquire new skills, but everyone completes them within a relatively short time frame.
Attack your courses with the mindset. Savor the hard focus required to master the material (coupled, of course, with smart study tactics to eliminate wasted time and effort), knowing that you're building the skills needed to move toward the bleeding edge.”
“Four years earlier, Time Magazine profiled James as part of their Innovators series. The next year, he was featured on an episode of Nova ScienceNOW. Earlier this year, TheGrio, a popular African American-focused news portal, named James one of their 100 History Makers in the Making.”
“In other words, James is famous in his field. So it’s not surprising that in 2009 he landed a professorship at Rice University — one of the country’s top engineering schools — in one of the worst academic job market in decades.”
James' stardom started when he designed a swarm of microbots 'Ants' for his senior thesis project (i.e. graduation project). The devices were designed to perform complex behavior using simple rules. The paper in which he documented this work spread out to the public media, making a star out of James.
“I went to the lab as an undergrad to interview for a position,” James recalls. “Anita Flynn told me they’re not hiring. So I came back with some robots I had built, and some I was halfway through building, and she said, ‘okay, you can work in the lab, and use our parts, but we can’t pay you.’”
Once in the lab, he worked real-hard on one project after another; each stretching his abilities a little bit. He wasn't alone in the lab though. Anita Flynn was shrinking the size of electronic motors, enabling the micro-robot revolution, while Maja Mataric was a leading thinker on robotic swarms.
“By the time he conceived of the Ants project for his thesis, James was an accomplished robot engineer with a number of successful projects under his belt. He also had a cutting-edge knowledge of microrobotics, and was “marinating” in a lab environment obsessed with biologically-inspired systems. With this in mind, the idea of building a robot swarm that behaves like insects was not a big hairy audacious goal to him.”
It was James' knowledge and expertise in cutting-edge techniques in his field that enabled him to take an unprecedented step. To him (and others with equivalent level of knowledge and expertise), Ants was an obvious incremental step. To the rest of the world, including less-aware people in robotics field, it was a huge breakthrough. Cal concludes that, to become a star, you should focus on getting to the bleeding edge of your field as quickly as possible.
“Many graduate students, for example, never arrive at the bleeding edge of their field. Instead, they reach a comfortable level of knowledge — enough to understand relevant research, and make their own acceptably-complex contributions, but not enough to make bold advances. Thousands of chemists could understand Watson and Crick’s 1953 paper on the double helix, but only a handful had the knowledge needed to have discovered it for themselves.”
Now, the obvious question is how do you get to the bleeding edge?
“Every semester, my supervisor, Anita, had me write out goals,” James told Cal. “We would go back at the end of the semester and look at what I did and didn’t do. She would tell me, ‘it’s fine that you didn’t get this all done, but what’s not fine is your inability to estimate how long something will take.’”
James deliberately chose projects that were hard enough to stretch his ability, but reasonable enough to complete in the available timeframe.
“With this in mind, I argue that the secret to James McLurkin’s success is his ability to choose the right projects. By resisting work that reinforced what he’s comfortable with, yet also sidestepping overly-ambitious projects, he consistently advanced his skill until he arrived at the bleeding edge of research robotics. Once there, the “breakthrough” projects that cemented his reputation became obvious next steps. Stretch projects are an effective way to integrate deliberate practice into fields without clear competitive structures and coaching”
To emphasize, Cal gives two definitions:
Stretch Project: A project that requires a skill you don’t have.
Stretch Churn: Number of stretch projects you complete per unit time.
In order to make it to the bleeding edge, you need to maximize your stretch churn. You need to be in a continuous discomfort learning new things and resist the tendency to reinforce what you already know.
Uh.. I think this comment (in response to Cal's article) is also worth quoting
“Nianu: What kind of stretch projects would you recommend I start to tackle? I have a hard time thinking of what would be a good way to start as I am still early in my college career.”
“Cal: College and graduate-level courses are stretch projects in themselves. They force you to acquire new skills, but everyone completes them within a relatively short time frame.
Attack your courses with the mindset. Savor the hard focus required to master the material (coupled, of course, with smart study tactics to eliminate wasted time and effort), knowing that you're building the skills needed to move toward the bleeding edge.”
Wednesday, November 11, 2009
Recommendation letters
This post is the second episode featuring Prof. Mor Harchol-Balter's talk advising people applying to PhD programs in computer science or related areas.
[first episode - full article]
"Perhaps the most important part of your application is the letters of recommendation. You will need 3 letters of recommendation for the Ph.D. program, and typically 4 letters of recommendation for a fellowship.
Whom to ask for a letter
Ideally you would like to make all your letters of recommendation count. Consider the following two letters:
One caveat: It makes some difference whom you ask for a letter. As a general rule (there are always exceptions due to people’s fame), letters from professors count the most. Next highest are letters from research scientists. After that come letters from lecturers, systems scientists, employers, or postdocs. Please do not get a letter from a graduate student. If you found yourself doing research where you were supervised by a graduate student or postdoc, you should ask the professor for whom they work if she can co-write the letter. The reason is simple: professors are the ones reading the letter, and they are most likely to know other professors.
There is an issue for students who have been working for a while. You will certainly want a letter from your employer, but you will also want two letters from professors. This was an issue for me when I applied to graduate school. What I did was to keep touch with a few professors during my time at work. When I was ready to apply to graduate school, I contacted the professors who knew me well and scheduled a meeting with them to discuss the research that I had done while I worked. I gave them each an oral presentation. I also gave them each writeups of each of my projects.
How to ask for a letter
Asking for a letter of recommendation won’t be a problem if you have been doing research with this person, but that won’t be possible in every case. Here’s a guideline which will maximize the contents of your letter. This works on the theory that professors have very little time and little memory (both of which are good assumptions):
[first episode - full article]
"Perhaps the most important part of your application is the letters of recommendation. You will need 3 letters of recommendation for the Ph.D. program, and typically 4 letters of recommendation for a fellowship.
Whom to ask for a letter
Ideally you would like to make all your letters of recommendation count. Consider the following two letters:
- Letter 1: “I highly recommend student X for your graduate program. Student X received an A+ in my undergraduate algorithms class. He was ranked Number 2 out of 100 students. He got the highest score on the final. He worked very hard all semester, never missed a class, and was always able to answer the questions that I asked in class. This conscientious attitude makes him an excellent candidate for any graduate program. ”
- Letter 2: “I highly recommend student Y for your graduate program. Student Y received a B in my undergraduate algorithms class. He was ranked Number 29 out of 100 students. Halfway through the semester we started working on network flows. Student Y seemed extremely excited by this topic. He disappeared for 4 weeks and even missed an exam. However when he came back, he showed me some work he had been doing on a new network flow algorithm for high-degree graphs. He had done some simulations and had some proofs. I’ve been working with student Y for the past couple months since then and he is full of ideas for new algorithms. I think student Y’s initiative makes him an excellent candidate for any graduate program.”
One caveat: It makes some difference whom you ask for a letter. As a general rule (there are always exceptions due to people’s fame), letters from professors count the most. Next highest are letters from research scientists. After that come letters from lecturers, systems scientists, employers, or postdocs. Please do not get a letter from a graduate student. If you found yourself doing research where you were supervised by a graduate student or postdoc, you should ask the professor for whom they work if she can co-write the letter. The reason is simple: professors are the ones reading the letter, and they are most likely to know other professors.
There is an issue for students who have been working for a while. You will certainly want a letter from your employer, but you will also want two letters from professors. This was an issue for me when I applied to graduate school. What I did was to keep touch with a few professors during my time at work. When I was ready to apply to graduate school, I contacted the professors who knew me well and scheduled a meeting with them to discuss the research that I had done while I worked. I gave them each an oral presentation. I also gave them each writeups of each of my projects.
How to ask for a letter
Asking for a letter of recommendation won’t be a problem if you have been doing research with this person, but that won’t be possible in every case. Here’s a guideline which will maximize the contents of your letter. This works on the theory that professors have very little time and little memory (both of which are good assumptions):
- Prepare a packet for each recommender. This packet should contain all the relevant information about you that could help the recommender. Be careful not to make the packet too large. Here’s what should be in it:
- Your statement of purpose.
- A summary of every research project you worked on and with whom, regardless of whether this was at a school or research lab. If you have published a paper, or have a technical report, please include that too.
- A sheet of paper listing all math/cs/engineering/science classes you have taken with the names of professors and grades.
- A list of extracurricular activities and awards/competitions.
At the top of the packet should be:- A recent photo of you – professors receive many such packets and don’t remember you the second after you leave the office.
- Directions. E.g., please seal and sign and send to this address by Jan. 5. Put an earlier date than the real deadline – professors are notoriously late.
- Confirmation information: Please send me email at blank address after you send this off. If I don’t hear from you by Jan. 5th, I will send you an email reminder. (You need this confirmation information because otherwise you’ll never know if the recommendation was sent and you’ll be sitting around biting your nails wondering.)
- Go to your potential recommender with your packet and ask him/her the following question: “Do you feel comfortable writing a strong letter of recommendation for me to graduate school?” You need to phrase the question this way so that the potential recommender has a way out. Do not be upset if the potential recommender says no. It is good that he/she let you know. This is much better than getting a weak letter.
- Check with the school to confirm that they have received a letter from each of your recommenders.
- Remember to at least send your recommender a thank you card! It’s a lot of work to write a decent recommendation letter, and you may need more letters in the future."
Sunday, October 18, 2009
MSc then PhD?
Typical situation: Hamdy was a top ranked student in his university, in a developing country, and now he'd like to get a PhD from a good university in US/Canada (with financial aids). He has two options:
Why would Hamdy go for option 2:
Avoid frustration
MSc is less of a commitment than PhD. It's easier to work on, and takes much less time to get done. However, it gives a clear idea on how Hamdy's life is gonna be as a PhD student. Given that 50% of PhD students in some fields drop out before completing their degrees, this becomes a significant consideration. Hamdy prefers to go for the less risky degree (ie. MSc) and then decides whether he should continue for a PhD or get a good job in the industry with his MSc degree, from a good university in US/Canada. I know one person who left PhD for the industry, and many PhD students who consider doing the same.
Chances of acceptance
MSc is less of a commitment than PhD, this holds true even for the admission committee of the university he applies for. Several persons I know applied for a PhD and were offered only an MSc. So, applying for an MSc would increase Hamdy's chances of getting admitted for graudate education.
Improve credentials
What if Hamdy wants to get his PhD from the reputable university A, while his credentials qualify him only for the less-reputable university B. He can first apply for an MSc with B and get the MSc degree to improve his credentials, then apply for a PhD in A. He can then transfer his MSc credits from B to A (this is possible for many A-B universities pairs in US/Canada). Note that -if this is what Hamdy plans to do- he shouldn't apply for a PhD in the less reputable university (B), because his supervisor will be grooming and expecting him to work for him for ~5 years, and then Hamdy will let him down and -moreover- ask him for a recommendation letter to the more reputable university (Hamdy can't go to A without a recommendation letter from his supervisor at B). I'm not sure what the supervisor will write in the recommendation letter then about Hamdy's commitment.
Freedom
Younos Aboulnaga was the first to introduce me to the concept of "taking a break while studying". In his undergraduate study in Egypt, Younus paused before last year, spent a year working in Brazil, and then went back to earn his BSc degree. Almost all PhD students get fed up after a few years of working for it. They wish they could "take a break" just like Younus did. However, they can't just apply for any job and spend a year or two, then come back to continue the PhD. They have to find an internship inline with their research, competing with many PhD students for a limited number of internships, probably with low pays. If Hamdy goes for option 2, he could pause for as long as he wishes, then gets back to continue his graduate education when he feels he's ready to continue.
Why would Hamdy refrain from option 2:
Time
Option 2 usually takes more time, even though he will probably take the MSc in option 1 as well.
Commitment to research
Most of the rationales for taking option 2 assumes it's likely for the student to drop out. If Hamdy knows somehow he's comfortable with doing research and will withstand the pain it takes to get a PhD, these rationales weight nothing for him.
Over qualified
Some universities (e.g. UCSB) won't admit you for a masters program if you already have had a masters degree in the same disciple from another university.
Request: If you know something that contradicts with what I'm stating here, or complements it somehow, please do comment on the post or drop me an email at ammar DOT w AT acm DOT org, and I will be happy to update the original post reflecting your valuable point of view.
- Apply for a PhD.
- Apply for an MSc. And after getting the MSc degree, he applies for a PhD.
Why would Hamdy go for option 2:
Avoid frustration
MSc is less of a commitment than PhD. It's easier to work on, and takes much less time to get done. However, it gives a clear idea on how Hamdy's life is gonna be as a PhD student. Given that 50% of PhD students in some fields drop out before completing their degrees, this becomes a significant consideration. Hamdy prefers to go for the less risky degree (ie. MSc) and then decides whether he should continue for a PhD or get a good job in the industry with his MSc degree, from a good university in US/Canada. I know one person who left PhD for the industry, and many PhD students who consider doing the same.
Chances of acceptance
MSc is less of a commitment than PhD, this holds true even for the admission committee of the university he applies for. Several persons I know applied for a PhD and were offered only an MSc. So, applying for an MSc would increase Hamdy's chances of getting admitted for graudate education.
Improve credentials
What if Hamdy wants to get his PhD from the reputable university A, while his credentials qualify him only for the less-reputable university B. He can first apply for an MSc with B and get the MSc degree to improve his credentials, then apply for a PhD in A. He can then transfer his MSc credits from B to A (this is possible for many A-B universities pairs in US/Canada). Note that -if this is what Hamdy plans to do- he shouldn't apply for a PhD in the less reputable university (B), because his supervisor will be grooming and expecting him to work for him for ~5 years, and then Hamdy will let him down and -moreover- ask him for a recommendation letter to the more reputable university (Hamdy can't go to A without a recommendation letter from his supervisor at B). I'm not sure what the supervisor will write in the recommendation letter then about Hamdy's commitment.
Freedom
Younos Aboulnaga was the first to introduce me to the concept of "taking a break while studying". In his undergraduate study in Egypt, Younus paused before last year, spent a year working in Brazil, and then went back to earn his BSc degree. Almost all PhD students get fed up after a few years of working for it. They wish they could "take a break" just like Younus did. However, they can't just apply for any job and spend a year or two, then come back to continue the PhD. They have to find an internship inline with their research, competing with many PhD students for a limited number of internships, probably with low pays. If Hamdy goes for option 2, he could pause for as long as he wishes, then gets back to continue his graduate education when he feels he's ready to continue.
Why would Hamdy refrain from option 2:
Time
Option 2 usually takes more time, even though he will probably take the MSc in option 1 as well.
Commitment to research
Most of the rationales for taking option 2 assumes it's likely for the student to drop out. If Hamdy knows somehow he's comfortable with doing research and will withstand the pain it takes to get a PhD, these rationales weight nothing for him.
Over qualified
Some universities (e.g. UCSB) won't admit you for a masters program if you already have had a masters degree in the same disciple from another university.
Request: If you know something that contradicts with what I'm stating here, or complements it somehow, please do comment on the post or drop me an email at ammar DOT w AT acm DOT org, and I will be happy to update the original post reflecting your valuable point of view.
Monday, October 5, 2009
How to enhance runtime performance?
Since we do computer science research, we typically implement our explorations and research advances as computer programs. Many research fields have to deal with an immense amount of data (e.g. information retrieval, natural language processing, data mining), adding scalability as a major requirement when you develop a prototype/an exploration.
This post is all about how to enhance runtime performance of your program. It summarizes a discussion I had with some colleagues in this regard:
1. "Premature optimization is the root of all evil (or at least most of it) in programming", says Donald Knuth. Instead, use a profiler to identify which pieces of the code need your attention.
2. Optimize the algorithm first, not the code. Sometimes we think a problem is too trivial to analyze its algorithm, but it makes much sense to reconsider the 'trivial' algorithm when it runs millions of times. For example, this code
Assuming 'calculateMetric2' is an expensive procedure, refactoring the code as follows will significantly enhance performance:
3. Concentrate on high level optimizations. Most popular compilers do a lot of optimization on your behalf. For example, Microsoft's Visual C compiler will replace the following code with "x = 27000000":
4. Consider changing the data structure that hosts your data (e.g. a hashmap instead of an array).
5. Caching. If there’s an expensive operation with inputs that are likely to repeat, it might be worth caching. Note that a cache with low hit-ratio might degrade overall performance.
6. Distribute the load on the multiple cores of your processor, or on multiple machines.
7. Get rid of redundant calls. For example, when the code aggressively uses case-insensitive string comparisons, lowercase your strings only once.
8. Sometimes, memory allocation is very demanding. The solution in these cases is usually to create your own memory allocator or use memory pools for certain objects.
9. Sometimes, initializing/resetting arrays is very costly. It’s not always necessary to initialize/reset an array before using/reusing it. For example, to compute the Levenshtein distance between two words, there’s a dynamic programming algorithm which uses a 2D array. Even though the same array is used for different word pairs, no need to zero the array since it’s built in a bottom-up fashion.
I'd like to acknowledge my friends/colleagues (Ahmed El Deeb, Ahmed Sabry & Diaa Samy) for the constructive discussion we had around this topic.
This post is all about how to enhance runtime performance of your program. It summarizes a discussion I had with some colleagues in this regard:
1. "Premature optimization is the root of all evil (or at least most of it) in programming", says Donald Knuth. Instead, use a profiler to identify which pieces of the code need your attention.
2. Optimize the algorithm first, not the code. Sometimes we think a problem is too trivial to analyze its algorithm, but it makes much sense to reconsider the 'trivial' algorithm when it runs millions of times. For example, this code
double metric1 = calculateMetric1(input);
double metric2 = calculateMetric2(input);
if(metric1 > threshold1 && metric2 > threshod2)
return true;
else
return false;
Assuming 'calculateMetric2' is an expensive procedure, refactoring the code as follows will significantly enhance performance:
double metric1 = calculateMetric1(input);
if(metric1 <= threshold1)
return false;
double metric2 = calculateMetric2(input);
if(metric2 <= threshold2)
return false;
else
return true;
3. Concentrate on high level optimizations. Most popular compilers do a lot of optimization on your behalf. For example, Microsoft's Visual C compiler will replace the following code with "x = 27000000":
x = 0;
for(int i=0;i<300;i++)
for(int j=0;j<300;j++)
for(int k=0;k<300;k++)
x++;
4. Consider changing the data structure that hosts your data (e.g. a hashmap instead of an array).
5. Caching. If there’s an expensive operation with inputs that are likely to repeat, it might be worth caching. Note that a cache with low hit-ratio might degrade overall performance.
6. Distribute the load on the multiple cores of your processor, or on multiple machines.
7. Get rid of redundant calls. For example, when the code aggressively uses case-insensitive string comparisons, lowercase your strings only once.
8. Sometimes, memory allocation is very demanding. The solution in these cases is usually to create your own memory allocator or use memory pools for certain objects.
9. Sometimes, initializing/resetting arrays is very costly. It’s not always necessary to initialize/reset an array before using/reusing it. For example, to compute the Levenshtein distance between two words, there’s a dynamic programming algorithm which uses a 2D array. Even though the same array is used for different word pairs, no need to zero the array since it’s built in a bottom-up fashion.
I'd like to acknowledge my friends/colleagues (Ahmed El Deeb, Ahmed Sabry & Diaa Samy) for the constructive discussion we had around this topic.
Monday, September 7, 2009
Life after the PhD
This post is quoted from a document written by Mor Harchol-Balter advising people applying to PhD programs in computer science or related areas. Mor has been in the committee of PhD admissions at CMU, Berkeley and MIT. I found the whole document very informative, but too large to include in a single post.
"When making a decision about the next 6 years of your life, it’s good to stop and think about what you might do when you finish. Most students upon completing a PhD either go into academia (research university or teaching school) and become a professor, or they go to a research lab. Some people never do research again after completing a PhD. For such people, the PhD was largely a waste of time.
I'm going to publish other parts of Mor's talk, discussing specific aspects related to PhD, in subsequent posts on this blog. So, keep watching.
"When making a decision about the next 6 years of your life, it’s good to stop and think about what you might do when you finish. Most students upon completing a PhD either go into academia (research university or teaching school) and become a professor, or they go to a research lab. Some people never do research again after completing a PhD. For such people, the PhD was largely a waste of time.
- If you choose to be a professor at a research university, your life will consist of the following tasks: (i) doing research on anything you like, (ii) working with graduate students, (iii) teaching classes, (iv) applying for grants, (v) flying around to work with other researchers and to give talks on your research, (vi) doing service for your department and school (like giving this talk). Note that I say “your life” rather than your job, because for new faculty, your life becomes your job. It’s a fantastic job/life for me because I love these activities, so I’m happy to work hard at all of them, but it’s not right for everyone.
- If you choose to be a professor at a teaching college, your job will consist of the following: (i) teaching lots of classes, (ii) doing service for your department or school, (iii) occasionally advising undergraduates on undergraduate research, or doing a little of your own research.
- If you choose to go to a research lab, your job will consist of the following: (i) doing research (half will be on whatever you want, half will be on whatever the company wants you to do), (ii) working with other people in the company, (iii) traveling around a little to give talks and work with others."
I'm going to publish other parts of Mor's talk, discussing specific aspects related to PhD, in subsequent posts on this blog. So, keep watching.
Subscribe to:
Posts (Atom)