Meeting the Tech Team: David Iglesias

Posted on 4/17/2013 by Eng Outreach Committee

David Iglesias, with a Computer Science degree from the University of Oviedo, finished his studies in 2006 and has worked in web development ever since. He came to Madrid from Asturias in 2009, when he was hired to work at Tuenti. He began on the Product Team, and since the beginning of 2012, he has been a part of the Frontend Framework Team who writes the base code used by the rest of Tuenti’s Frontend programmers.

We’ve put together some videos to help you get to know the Tuenti Tech Team a little better. Meet David here, in our first video ;)

#TuentiChallenge3. Working at Tuenti, a Real Opportunity (Part 3)

Posted on 4/12/2013 by Eng Outreach Committee

The last, but not least, the conclusion of our interviews with previous winners is wrapped up with Oleg Zaystev. He was born in the Ukraine and came to Spain with his family when he was 14. He finished school here and did a Mathematics degree at UCM, which he finished while working at Tuenti.

How did you find out about the Contest? What made you sign up?
I saw an ad on Tuenti, and I love programming so it was an easy decision. To be honest, I had  been counting down the days to start the contest.

What Programming language did you use?
I used Python for all my problems. It’s my favorite programming language and it’s fast enough to solve all problems in a reasonable amount time. The ability to handle very large numbers without doing any extras was another positive point for Python.

Did you expect to be finalist?
Well, I wanted to be more than I expected I would be until the last day. I got stuck on the 8th problem for 2 days, and when I reached the 20th, I almost gave up on it. The inspiration came to me on the last evening and I was finally able to solve them all.

What is the best  thing about being part of Tuenti?
You learn a lot every day. Every day you can develop yourself professionally and personally, there’s always somebody to help, and there’s always somebody who appreciates your help.

Who would you encourage to participate?
Anybody who likes programming should participate, even if s/he doesn’t want to work with us. I had a very good time solving the challenges and it didn’t take me a lot of time. In fact, I did most of the challenges at night - early morning, when I was coming back home after playing video games with my friends all night.

Do you remember your favorite challenge? How did you solve it?
It was the 19th challenge. I had to paint the binary code in different colors to find the pattern. It took me a lot of time and I had to tweak the algorithm because I’d never seen it before.

Do you remember the most difficult? How did you solve it?
The most difficult was the funniest one and my favorite! It couldn’t have been any other way.

Don’t forget to sign up! Registration is still open, so hurry up! At Tuenti, we’re already gearing up to start the challenge of the year! Are you ready? ;)

#TuentiChallenge3. Working at Tuenti, a Real Opportunity (Part 2)

Posted on 4/10/2013 by Eng Outreach Committee

Time flies and #TuentiChallenge3 is only two weeks away (remember, registration is still open so hurry and sign up!). We know waiting is hard, so let’s learn some more about the winners of previous editions... If you are one of the 2,600 registered participants, Daniel Rey’s experiences will be really useful. He’s one of the youngest members of our team (only 22) and was finishing up his studies in computer Engineering at Oviedo University when joined Tuenti.

How did you find out about the Contest? What made you sign up?
I signed up for the second edition after an email was sent directly to me. I don’t remember how I found out about the contest the year before... I think I saw an ad on Tuenti. I signed up because I like challenges, especially those about logic and programming.

What Programming language did you use?
I used Python, but for some problems I used C++ for a little extra speed. For these kinds of challenges, the language speed is usually not nearly as important as the algorithm used, so I think the best language to use is the one that you are most comfortable with.

Did you expect to be finalist?
In the previous edition, I solved 18 of the 20 problems, so I was pretty confident that this time, if I didn’t get stuck with one of the difficult problems, I could be at least near the top.

What is the best of being part of Tuenti?
There are incredible people here, and you have the opportunity to learn something new everyday... the kinds of things you normally don’t learn during your studies.

Who would you encourage to participate?
Everyone with notions of programming who is looking for an intellectual challenge. The prizes are good, the possibility of being recruited by Tuenti is even better, and even if you don’t make it into the finals, a week of continuous challenge and fun is still worthwhile.

Do you remember your favorite challenge? How did you solve it?
It was the 19th. I felt ultra-powerful when I discovered a pattern in the numbers after hours of staring at them.

Do you remember the most difficult? How did you solve it?
The most difficult one for me was the last one. I spent almost a week trying to solve it, and the last night I left my laptop trying to solve by brute-force with every possible solution that my (tired) mind could think of. When I woke up, I was ready to give up, but the program had found the solution! A few hours later, and just in time, I submitted the complete solution to the problem :)

#TuentiChallenge3. Working at Tuenti, a Real Opportunity (Part 1)

Posted on 4/08/2013 by Eng Outreach Committee

As we promised in the previous blog post about TuentiChallenge, we’re pleased to introduce you to some of the winners from previous editions so they can tell you, from their personal experience, what the Challenge consists of and the most exciting thing about working at Tuenti. Let’s start with Pedro Pardal, 23, a Computer Engineer from Málaga that has been working at Tuenti for almost a year.

How did you find out about the Contest and what made you sign up?
I heard about the first challenge from a friend at my university. Since I wasn’t lucky the first time, I decided to try again last year when I received the reminder from Tuenti. For me, aside from wanting to participate in the competition itself, it was a way for me to put my knowledge and skills into practice and an opportunity to learn new stuff.

What Programming language did you use?
Java as the main language, since at that time, it was the one that I felt the most comfortable with, C# being my favorite, and C when I needed super-high-performance. I also tried LISP for one problem, as I like to play and experiment, but to no avail :(

Did you expect to be finalist? 
I didn't expect it at all because the first time I participated, I didn't even make it as a finalist, and last year’s challenges were way harder than the first time. However, it is surprising to see how you can improve in just a year :)

What is the best of being part of Tuenti? 
There are a lot of things that make working here an incredible experience. You have to face new challenges every day, so you can grow as a professional and learn new things all the time. Being surrounded by people that are really passionate about what they do is also incredible!

Who would you encourage to participate?
If you love programming, hacking and solving puzzles and are looking for a way to prove that you have knowledge and skills, then there's no doubt you should take part.

Do you remember your favorite challenge? How did you solve it?
For me it was the 19th. It took me almost two days of trying crazy ideas to realise that the transformations were applied in binary. Once I figured it out, it was just a matter of time before I was able find the pattern.

Do you remember the most difficult? 
My favorite one (19th) was, of course, the most difficult!

This year's Tuenti Challenge will take place April 29 - May 6. Remember, registration is still open so hurry and sign up!

The Epic Tale of Moving to HipHop

Posted on 3/05/2013 by By: Daniel Paneda (Senior Engineer) and Jaime Medrano (Principal Engineer)

This article will not explain what HipHop itself is (if you are not familiar with this software, you can read about it here). What we’d like to share are the main changes we had to make within our codebase to get things working in HipHop and evaluate if –performance wise– it was worth it.

TL;DR: it was very much worth it. Performance improvements have been significant. It was not easy to do the migration, and it took us about a year to make our full code base HipHop compliant. We had to make many changes on our side so about a million of lines of code would be compiled on HipHop but that wasn’t it- we also needed to make several changes to HipHop itself...but back to our epic tale!

While the driving motivator to move to HipHop was performance (we expected a much lower usage of CPU and memory and somewhat lower latencies), there were also added benefits to having our code base compiled on HipHop. An important one is that HipHop can be used to do static analysis.

 

Changes to PHP code

If your codebase is on the bigger side, be prepared to invest a lot of effort in getting something that can run on HipHop. The more extensions you use, the greater the chances are that you’ll have to invest in some major refactoring. Unit and integration tests are your friends. Our browser tests were almost useless in helping us find issues mostly because, when compared to unit and integration tests, they had a stronger non-deterministic behaviour. However, without unit tests, our refactoring efforts would have taken a lot longer.

The most important changes we had to make to the code were the following:

  • Get rid of all PHP > 5.3 functionality
  • Remove all uses of eval and dynamic defines.
  • A lot of work regarding having files physically on disk. When possible, we tried to remove instances of those files from PHP code. When that wasn’t an option, we had to get creative. Since HipHop keeps an internal cache of files in order to resolve PHP requires, we hooked up to this functionality to resolve our own files that, in some cases, were not PHP files.
  • Moved configuration from PHP code to json files.
  • Refactor some non-supported features:

    • Removed any uses of ArrayObject since it is not implemented on HipHop (ArrayObject is not your friend, don’t use it).
    • Remove ftp_* functions using curl extension.
    • The only stream wrappers supported are http, zlib, and some php ones (memory, temp, input, output and stderr).

HipHop improvements

Sometimes, refactoring the PHP code to make it HipHop compliant  was not an option or even the best option. In some cases, it was very difficult to remove the dependency on some PHP extensions we were using. In others, we discovered a difference in behaviour between PHP and HipHop that we needed to fix. The code quality of HipHop is pretty good, so fixing things is not a big problem. The problem is finding the exact behaviour difference that exists between PHP and HipHop that produces any given bug.  Again, unit tests to the rescue here.

The most important changes that we had to make to HipHop code were the following:

  • Migration to libevent2 (the stock version is quite old and has some memory leaks)
  • Create a proper build script on top of CMake for debian packages
  • Many, many modifications to match PHP behavior.
  • Some stability fixes in HipHop code regarding non-thread safe PHP libraries we were using. For example, we moved the locale implementation from libc  to boost (thread-safe implementation)
  • Addition of new extensions:

    • MemcachePool fully compatible with PHP one (also involves large changes on libmemcache to fully support UDP).
    • Configuration handling
    • Filter extension
    • Geoip extension
    • GMagick extension
    • Some internal extensions
  • Summary of total changes, excluding autogenerated files
666 files changed, 61990 insertions(+), 35065 deletions(-)
So, in the end, there are major differences between the vanilla HipHop and the one we are using. Of the changes we made, the ones we thought everyone could use are now pull requests to HipHop.
 

Environment changes

Moving over to HipHop wasn’t all about code changes. There were big changes needed in our development environment.  For example, we run HipHop on interpreted mode in development and we only fully compile in later testing phases. Changes to the development environment and the code affected a lot of teams- from devops, to backend engineers to QA. Our main concern was to make the migration as transparent as possible when it came to the development environment. 

Main changes made in this area were the following:

  • Moving development machines to use HipHop instead of php-fpm.
  • Migrate the base debian distro we are using on live and in development.
  • Create a compilation farm with distcc to be able to compile our source code faster.
  • Create new deployment tools to distribute and run HipHop binary balls.

Wrap Up

Moving to HipHop took a huge effort. In our case, it took two people working full time for over a year to complete the migration. On the way, not only did we improve the quality of our codebase but also our tools for building and deployment.

While it was a very long development effort, the reward was excellent to say the least. Since we migrated our fleet to HipHop, we’ve dropped our response times (measured from server side) a whooping 45%.  We use 2-3x less CPU and 10x less memory.

Pages

Follow us