Thursday, July 21, 2016

AdBlock - The browser killer

TLDR; This is not an anti-adblock post. The AdBlock extension is a proved CPU eater and it is proved that the AdBlock extension slows down your browsing experiences. I and many other devs suggest you "Ublock Origin" extension. Ublock Origin is fast and it has less bugs.


We had a CPU usage issue for a while ago with AdBlock users on onedio.com reported by some of our users.

At first we thought that this CPU problem is about user's system resources and we didn't mind too much.
After a while we started to get too many complaints about same issue. We dig into this then we saw that this is a problem about AdBlock extension. Yes the most popular ad-blocker extension in Webstore.

Here is a profile result for onedio.com with a Chrome browser + Adblock extension



The CPU killer function named addElemHideSelectors is a core function of Adblock. We searched about this function and we saw that this issue has been already reported on AdblockPlus Trac (not Adblock, AdBlock Plus) [1] [2] has been already fixed this by a very few code changes. [3]

So I reported the same issue on https://help.getadblock.com/support/tickets (which is a closed ticket system, where no one sees your ticket or process of the fix.) [4]



Then for long time we got no response. Even an automated response. We dig again and reviewed the Adblock source code. We focused on the problematic function and it's calls. [5]


We saw that there is too many array operations while collecting "something" with string match "source" and "track", and we have too many "data-track" and data-tracksource" and "data-source" attributes on our website. So we replaced these attributes with abbreviations  like data-trck or data-trcksrc. After this change immediately AdBlock problematic function's CPU usage decreased from %60 to %30.  See it from my second CPU profiling result


But we still didn't solve the CPU issue. We just relaxed our users a little.
It is sad that we should be Adblock compatible.

We then applied the patch that AdblockPlus have made to Adblock. Ad here is the result. The only problem is that Adblock iterating 172K size array without grouping and immediately.

Iterating array with groups and using slice instead of splice solves this problem. 


"The problem seems to be caused by ​the while loop inside addElemHideSelectors somehow." noted on AdBlock Plus trac page 
As a result we are struggling with AdBlock issues because they have very slow development processes or they develop nothing. If you really want an adblocker extension try Ublock Origin. It is fast. If you want an adblock extension that has "adblock" in it's name try Adblock Plus. But don't use  "AdBlock".  Popular doesn't mean it's the best.


1. Adblock and AdblockPlus is different projects but they share common libraries. 
2. The issue reported on AdblockPlus https://issues.adblockplus.org/ticket/4036#no1
3. Fix for the issue on AdblockPlus repo https://hg.adblockplus.org/adblockpluschrome/rev/9f451f809d40
4. AdBlock ticket system https://help.getadblock.com/support/tickets
5. The js file of AdbBlock that we analyzed https://gist.github.com/hasantayyar/6c5b6139316a9c5e24675bfa89980c4c


Update from my mentions to @getadblocker





Update #2
After Adblock released it's 3.1 version our pains are gone.



Sunday, July 3, 2016

How we make decisions at Onedio?

At Onedio.com while we are making decisions we are using natural and primitive methods like our communication that I've mentioned here.

Short answer: We talk, like all we are team leaders. We decide all together. There is no long answer for this. And this is not magic. Try it.  It is like deciding what to eat all together. Just make a free and natural office environment that everybody can talk.   

If you want some diagram for our decision steps here is an unnecessary diagram.





Other "How we do X at Onedio" posts 
- How we overcome monday morning syndrome at Onedio http://tayyar-code.blogspot.com/2016/06/overcome-monday-syndrome-onedio.html

Thursday, June 30, 2016

How we overcome monday morning syndrome at Onedio?

Actually not all of us but some of our fellas found a great way. During the whole Game of Thrones season they schedule a Game of Thrones hour in our office and yes at day time.  Now they will start for another TV series.

@cettox said "Every Sunday evening I  can't wait for the Monday morning!"

This method is proven and working. Arrange some mutual fun in office at day time for every Monday mornings. It works!

Tuesday, June 28, 2016

Hello Crystal


Crystal Language Goals
  • Ruby-inspired syntax.
  • Statically type-checked but without having to specify the type of variables or method arguments.
  • Be able to call C code by writing bindings to it in Crystal.
  • Have compile-time evaluation and generation of code, to avoid boilerplate code.
  • Compile to efficient native code.


I've started a project with crystal, but I did not contribute for a while.  



Just have a look at Crystal. You may like it. Also it has a friendly community. 

Progressive Slack Usage at Onedio

TLDR; Slack is just a tool. But it's a great tool. And it is working.

There are too many thoughts about Slack. Some of them are positive [1], some of them are too way negative [2]

At Onedio.com we are a team of hundreds of people. And we are all communicating with Slack. Some of our colleagues use only Slack to do their jobs. We have many webhooks and custom channels, like #daily-reporting-of-somethin, #comment-moderation-channel or #server-status-reports-channel.

We are communicating only with slack. Some of our friends haven't even opened their email inbox.

We have some private channels and we are talking about almost anything in these private channels (side projects, fashion, football, politics, gags, gifs, food, party, gossip, news etc). We have also too many  public channels that are open to all users. We like open communication in our company.




Our slack usage increases by time. 




We are not just posting we are also reading messages. Our slack messages are not just noises. We use mentions and magic mentions (@here @group )  wisely.






Slack is super fast while transferring files. 




Slack is just a tool. But it's a great tool. And it is working. Again but you will use this tool, and you may use it wrong. Maybe It's all about your communication problem. If your boss sucks at communication, sorry but Slack won't help your communication.

We are using slack as a natural way of communication. Our users are not always online. And sometimes they set their status don't disturb mode. In that case we are using different types of communication methods just like SMS or phone call (Btw slack also has an audio call feature). This is just a simple flow. If you don't like realtime notifications of everything then please use slack channel settings to turn on/off. If you like weekly/daily reports of messages then again use your slack preferences and make your settings with this way. Slack will help you to find your way on natural communication.

Slack works. Slack has a great dev team and all applications are just works without bugs (yes maybe with not very often crashes or UX fails)

Slack has many plugins. You can also write your own service or webhook for slack easily.

I am a fan of IRC and mail lists. But this is different. If your team is very young, dynamic and your project is fast growing, you will need a fast, clean and working method to communicate. Slack is a very advanced version of IRC.


1. Wht Slack Works? https://medium.com/@noelsequeira/slacktivism-cb384450e99e#.k5l2tsagb
2. Slack, I’m Breaking Up with You : https://medium.com/better-people/slack-i-m-breaking-up-with-you-54600ace03ea#.nd5hb27ci

Sunday, January 17, 2016

Multi-threading in JavaScript with ParallelJS


Parallel.js is a simple library for parallel computing in Javascript (in node.js or in the modern web browsers). Paralleljs takes advantage of Web Workers for the web, and child processes for Node.

What is web workers

Web Workers are a mechanism by which a script operation can be made to run in a background thread separate from the main execution thread of a web application. The advantage of this is that laborious processing can be performed in a separate thread, allowing the main (usually the UI) thread to run without being blocked/slowed down.
- https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API 


Multi-Threading in JavaScript

JavaScript is executed in a single thread by an event loop. With the Worker interface, a solution to this single-thread limitation problem has been found. With web workers Messages Api is used to communicate.

Note that, multi-threaded programming is parallel, but parallel programming is not necessarily multi-threaded. Unless the multi-threading occurs on a single core, in which case it is only concurrent.

Parallel.js

ParallelJS  provides a great easy to useAPI for web workers with many helpers. A sample usage :

var p = new Parallel([1, 2, 3, 4, 5]);console.log(p.data)


The instance p contains a set of helper methods, for example spawn, map, reduce.
Here is a simple example of map function usage. It returns a Promise with the result. This is not the right solution for multi-threading with parallel.js but only a simple example. 

p.map(function (number) {
 return number * number;
}).then(function (data) {
 console.log(data);
});

Tuesday, January 12, 2016

Install Caffe with GPU support without pain

This is my cheatsheet to install caffe with gpu support on an ubuntu machine.
https://gist.github.com/hasantayyar/1023dbdb01647b0c9559


apt-get update && apt-get install -q -y \
  wget \
  build-essential \
  module-init-tools

cd /opt && \
  wget http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run && \
  chmod +x *.run && \
  mkdir nvidia_installers && \
  ./cuda_7.0.28_linux.run -extract=`pwd`/nvidia_installers && \
  cd nvidia_installers && \
  ./NVIDIA-Linux-x86_64-346.46.run -s -N --no-kernel-module && \
  ./cuda-linux64-rel-7.0.28-19326674.run -noprompt

#ENV LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-7.0/lib64

#ENV PYTHONPATH=/opt/caffe/python

#ENV PATH $PATH:/opt/caffe/.build_release/tools

apt-get update && apt-get install -y \
  bc cmake curl git
  gcc-4.6 g++-4.6 gcc-4.6-multilib g++-4.6-multilib \
  gfortran unzip wget \
  libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev \
  libboost-all-dev \
  libhdf5-serial-dev \
  liblmdb-dev libjpeg62 libfreeimage-dev libatlas-base-dev \
  pkgconf protobuf-compiler \
  python-dev python-pip python-yaml python-numpy

# you may not need to change your gcc version
# update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-4.6 30 && \
  update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-4.6 30 && \
  update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 30 && \
  update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 30

# Allow it to find CUDA libs
echo "/usr/local/cuda/lib64" > /etc/ld.so.conf.d/cuda.conf && \
ldconfig
# Clone caffe
cd /opt && git clone https://github.com/BVLC/caffe.git

# you may not need to install glog. but caffe will log warnings until you've glog installed.
cd /opt && wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz && \
  tar zxvf glog-0.3.3.tar.gz && \
  cd /opt/glog-0.3.3 && \
  ./configure && \
  make && \
  make install

ldconfig

cd /opt && \
  wget https://github.com/schuhschuh/gflags/archive/master.zip && \
  unzip master.zip && \
  cd /opt/gflags-master && \
  mkdir build && \
  cd /opt/gflags-master/build && \
  export CXXFLAGS="-fPIC" && \
  cmake .. && \
  make VERBOSE=1 && make && make install

cd /opt/caffe && \
  cp Makefile.config.example Makefile.config

# echo "CXX := /usr/bin/g++-4.6" >> Makefile.config && sed -i 's/CXX :=/CXX ?=/' Makefile && \
make all -j8

# link caffe-ld-so.conf under /etc/ld.so.conf.d/

ldconfig

# you can install pillow from apt python-pil
easy_install pillow 

# You can find apt alternatives for these python deps.
cd /opt/caffe/python ; \
      for req in $(cat requirements.txt); do pip install $req; done

cd /opt/caffe && make py

# Done

Monday, January 11, 2016

If You are Dealing with Data, You will Like Anaconda

With Python at its core, Anaconda is a platform for connecting your expertise and curiosity with data to explore and deploy innovative analytic apps that solve challenging problems with ease and agility. Processing multi-workload data analytics – from batch through interactive to real-time – the platform is used for both ad hoc and production deployments. Anaconda is tuned to take advantage of modern computing environments – everything from multi-core servers, to Spark and Hadoop, to GPUs – delivering flexibility and allowing you to maximize your infrastructure investment. All of this plus the key capabilities required of an open source modern analytics platform – spanning advanced analytics, interactive visualizations, governance, security and operational support.


 https://www.continuum.io/



    Anaconda Stack

    APP

  • Notebooks 
  • Embeddable Dashboards 
  • Data Services 
  • Visual Apps 
  • VIZ 
  • Plots
  • Interactive Viz
  • Big Data
  • Maps & GIS
  • 3D
  • Streaming
  • Graphs 

      STORYBOARD

  • Notebooks
  • Interactive Exploration
  • Visual Programming
  • Data IDEs 

      ANALYTICS

  • DataPrep
  • Stats
  • ML & Ensembles
  • Deep Learning
  • Simulation & Optimization
  • Geospatial
  • Text & NLP
  • Video/Image/Audio Mining
  • Graph & Network 

      DATA

  • Hadoop & Hive
  • Spark
  • NoSQL
  • DW & SOL
  • Files & Web Services

      HARDWARE

  • Servers
  • Clusters
  • GPUs & High End Workstations