Speed up JRuby + Rails startup time

first check – https://github.com/jruby/jruby/wiki/Improving-startup-time

Set JRUBY_OPTS for development

~/.rvm/hooks/after_use_jruby_opts
#!/usr/bin/env bash

. "${rvm_path}/scripts/functions/hooks/jruby"

export PROJECT_JRUBY_OPTS="-Xcompile.invokedynamic=false -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -Xcompile.mode=OFF"

if [[ "${rvm_ruby_string}" =~ "jruby" ]]
then
jruby_options_append "${PROJECT_JRUBY_OPTS[@]}"
else
jruby_options_remove "${PROJECT_JRUBY_OPTS[@]}"
jruby_clean_project_options
fi

One by one

-Xcompile.invokedynamic=false optimizations on bytecode instruction level dynamically.

-J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 same effect as client mode on 64bit JVM.

-J-noverify not verifying

-Xcompile.mode=OFF don’t do JIT

Nailgun

“Insanely Fast Java”
Preloads a JVM.

Not that much gain < 1 second

cd ~/.rvm/rubies/jruby-1.7.4/tool/nailgun
./configure
make install
$ time ruby bin/thor list
real 0m1.919s

$ ruby --ng-server &
NGServer started on all interfaces, port 2113.

$ time ruby --ng bin/thor list
real 0m1.331s

Drip

Charles Nutter @headius Nov 20 2012 “Big JRuby startup time improvements using Drip…give it a shot, let us know how it works: https://github.com/flatland/drip&#8221;

export JAVACMD=`which drip`
export DRIP_INIT_CLASS=org.jruby.main.DripMain

dripmain.rb
# org.jruby.main.DripMain
public static final String JRUBY_DRIP_PREBOOT_FILE = "./dripmain.rb";

Unfortunately buggy – https://github.com/flatland/drip/issues/51

All together

BEFORE LAZY REQUIRE (Bundler.require)
$ time ruby bin/rspec spec/models/tag_spec.rb
saved about ~3 secs.

DEFAULT
$ time ruby bin/rspec spec/models/tag_spec.rb

real 0m23.325s

JRUBY_OPTS

$ export JRUBY_OPTS="-Xcompile.invokedynamic=false -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -Xcompile.mode=OFF"
$ time ruby bin/rspec spec/models/tag_spec.rb

real 0m10.726s

JRUBY_OPTS + NAILGUN + SPORK

$ ruby --ng-server &
$ ruby --ng bin/spork
$ time ruby --ng bin/rspec spec/models/tag_spec.rb

real 0m3.453s

Auto enable Nailgun

~/.rvm/hooks/after_use_jruby

#!/usr/bin/env bash

\. "${rvm_path}/scripts/functions/hooks/jruby"

if [[ "${rvm_ruby_string}" =~ "jruby" ]]
then
jruby_ngserver_start
jruby_options_append "--ng" "${PROJECT_JRUBY_OPTS[@]}"
else
jruby_options_remove "--ng" "${PROJECT_JRUBY_OPTS[@]}"
jruby_clean_project_options
fi

Prefer binstub over bundle exec

bundle binstub rspec-core

bundle exec requires the executable script and call exec to replace the process. From the wiki “Avoid spawning sub-rubies”.

Advertisement

Moving to Xiaomi mi2s from iPhone 4.

Build:

  • feels like iPhone 3G – plastic back, thicker than iPhone4 and above.
  • sturdy enough, but I’m worried if its dropped into water. iPhone is better sealed out of the box.
  • sits well on one hand without a case. iPhone built for adding a case.
  • screen – some weird uneven chemical spots, probably need to use a protector.
  • camera produces pretty high quality photos, auto focus could be slow.
  • battery, similar to iPhone4, slightly better.
  • wifi range, similar to iPhone4, not any better.
  • fast CPU, web pages renders pretty quickly.
  • iPod headphones control
  • micro USB harder to plug/unplug in the dark or with one hand.
  • vibration not as strong as iPhone, I would not feel the phone vibration for messages.
  • notification LED is kinda good, you can customize different colors for different notifications. Sometimes depends on the application. Whatsapp has good config, but Google Hangout doesn’t.

VS iPhone:

  • Touch sensitive buttons can cause some problems when trying to operate with one hand.
  • The menu / setting button can be confusing. Some apps modelling from iPhone has a navigation button, but it is not the same as settings. Also the settings button brings up different items on different pages. There are more things to remember and trial/error versus the iOS.
  • Notification on status bar seems good, but flashing light is not intuitive.

MIUI

  • Worst problem “Insufficient storage available” – 4 weeks in I started getting this error alot when I try to install new apps or sometimes even updating apps – http://stackoverflow.com/questions/16818049/. This is due to the stock MIUI not able to install apps on data partition. After manually update the system with development rom, it fixes it self http://en.miui.com/thread-1885-1-1.html. MIUI-V5 also has more nicer features than stock version.
  • a lot of built in service, feels good coming from iOS. Need to learn the shortcuts.
    • works well in English
    • auto back up photos to cloud.
    • messenger, notes, calendar
    • flash light
    • Play store, Google apps, recommended apps.
    • Browser includes reader and add to home screen
  • i.xiaomi.com – MiCloud – free.
    • can locate, play sound, lock and wipe phone. Although Locate didn’t work for me while in the US, play a sound worked.
    • sync contacts, photos, messages and notes.
  • mail app – renders better than gmail, but no priority inbox.
  • Theme – only a few ones are good, most are not well polished, but a lot more fun than iOS.
  • Video player not as consistent as iOS, sometimes crashes, cannot control volume until video starts playing.
  • Video player in Chrome doesn’t auto popup to full screen, need to manually click expand. Doesn’t go back to webpage after video finishes playing, it just stops as the end of the video.
  • Keyboard, default normal is shorter than iPhone. Need to use medium tall.
  • Hard to switch between Chinese and English. Need to use Google Pinyin input, which includes an English keyboard, but English keybaord doesn’t support gestures. The English only keyboard supports gestures but it is hard to switch between inputs.
  • Built in touch pal has quirky layout, hard to get used to.
  • Turn on professional setting for camera app – faster access to advanced features like exposure, white balance, slow motion, time lapse.
  • The settings page, all the items are in text. iOS settings have icons next to each function, that is easier to browse. (This is fixed in MIUI-V5)
  • Since using the phone for 3 weeks, it crashed twice. I do exploit the phone quite a bit, but definitely not as stable as iOS.
  • Security seems good, I’m told by the OS that apps are monitored if they breach permissions.

Android

The good:

  • Allows me to install apps that didn’t normally get approved on apps store or are restricted between regions. e.g. Xiami the Chinese Spotify could not be installed on iPhone.
  • There are innovative apps that would not be possible on the iPhone – e.g. Everything.me
  • Widgets – will be the iOS next feature.
  • Feature – Add contact as an app shortcut on home page.

The bad:

  • Hardware Back Button is good, when I go back to the iPhone, that’s one the feature I missed. It can go back between apps. However when the phone is in landscape mode, it does get confusing where the button should be.
  • No iTunes podcast, iTunes University.
  • Chrome doesn’t seem to come with a “Reader” function. Firefox does.
  • Does not recognize music playing the background while playing games. Maybe it is the game I was playing but iOS was smart enough to not play the music part of the games if I had other music playing.

Apps:

Thoughts on Google I/O 2013

I was fortunate this year to experience Google I/O for the first time. The experience really started from the count down to the morning when registration opened and I managed to get a ticket before it sold out.

After attending the 3 day conference, I can safely say Google I/O is unlike any other conference I’ve been to. This is probably the only one where I felt inspired, had a lot of fun and learned some practical knowledge at the same time. The 5 different tracks were wide enough to cater for a variety of interests. Some tracks even had concurrent sessions. Since all of the sessions were recorded and available on Youtube, I chose to attend the more technical sessions that required more focus. The fireside chat sessions were also interesting as you could ask questions and interact directly with the team behind the scenes. I also enjoyed the office hours in the open expo area in which you could talk closely with Google employees.

I was impressed with the range of technologies put on show by Google. My Google I/O experience can be summarized in three parts – Inspiring, Practical and Fun.

Inspiring 

The impressive visual display of the keynote set a stage for thinking big and seeing the future. What was more inspiring though was hearing Larry Page answer questions in the new Q&A session this year. Larry encouraged everyone to gain a deep understanding of what you are working on in order to think big and solve the real issues. He asked “How far are you off from the raw materials cost?”. He emphasized that it is very important for engineers to stop optimizing at a high level which may only provide incremental improvements. Larry also emphasized that Google has only accomplished 1% of what is possible. Keeping those pieces of advice in mind was an inspirational start to the conference.

The second talk that I found inspiring was “7 Techmakers and a Microphone”.  I didn’t know what to expect at first, but the stories of each woman was truly moving and exciting. There was an air of celebration and appreciation of the early days of computer science, something I haven’t felt myself for a long time. One of the amazing stories in the talk was about the first all-electric computer, the ENIAC, and how the first six women programmers of the ENIAC almost faded into the unknown. Their story will be produced as a documentary very soon – http://eniacprogrammers.org/.

By the end of the conference, I found myself looking forward to owning a pair of Google Glass. Everyone at the conference was optimistic and understood that this is the early experimental stages for wearable technologies. Larry said that they are focused on making users of Glass happy, and getting technology out of the way of people’s lives. I look forward to the possibilities of Glass and wearable technologies.

Practical 

If practicality is what you look for in a conference, Google I/O also had a lot of informational sessions. The sessions on Chrome and App Engine were most relevant to me. The Chrome team focused on performance; the #perfmatters hashtag was everywhere. It was clear that it is in Google’s interest to keep users using the web by making sure they have a fast experience in comparison to native apps. Apart from educating developers, Google also invested a lot in tools and advancing browser capabilities. Chrome had some cool demos with WebRTC & WebGL. They are standardizing ideas from AngularJS as web components. Google created new languages like Dart and Go that promote better engineering practises and performance. The flexibility and performance of Google App Engine was impressive. Last but not least, the new Android studio based on IntelliJ is a long awaited tool for Android developers.

Furthermore, eager attendees could get their hands dirty in code labs which started at 9am on the 3rd day of the conference. The one I recommend is “Whispering Gophers: networking programming in Go”.

For a list of sessions on web performance, check out the perfmatters blog.

Fun 

The after hours party that Google put together on the first night was absolutely tailered for geeks. It was kind of surreal with robots everywhere, a robot bartender mixing custom drinks with real time stats, Billy Idol, DJ Aoki, great food and drinks. I couldn’t think of anything else to ask for other than making the party last longer.

On top of that, this year everybody received a Chromebook Pixel. I’ll admit it is not going to replace my Macbook Pro, but it got me interested in learning more about Chrome OS and what it is capable of.

In closing

There were a couple of things I observed. Google is incredibly fortunate that it can afford to experiment and bet on different technologies. Given they make a majority of their income from ads, Adsense and Adwords were not heavily visible in the conference.

It’ll be interesting to see Chrome as a major platform and see how that will coexist with Android. It is not clear how that will pan out, though I wouldn’t be surprised if Google releases a phone running on Chrome OS.

Finally I’m looking forward to seeing more from Google[x] and Google.org on how to use technology for social impact and improving human life.

 

RailsRumble – StillAlive.com – website monitoring with cucumber syntax

I haven’t blogged for a while, I’ve been writing some notes in Facebook instead and I’ll move some of that back onto my blog later.
I’ve been doing alot of things this year as I always get myself into. Just last weekend I did this 48hrs RailsRumble with 3 other guys in Sydney. We’ve done pretty well considering it’s the first time we worked together, and pretty much just came together on forming a team for the rumble.

This was actually our first idea. Wouldn’t it be cool to use your cucumber test on your live site? Most site monitoring services out there only supports ping or at best some simple text find verification. How do you know your api is authenticating? How can you make sure your search engine daemon is still serving up results while you’re asleep. Ping cannot guarantee the integrity of your website anymore. So we have a solution, our entry – StillAlive, is a new way of monitoring your website. When “Status 200” is not OK, StillAlive lets you use simple English language (cucumber’s gherkin syntax) to interact with your webapps in order to make sure every feature of the site is working.

You can do things like:

When I go to http://tellthemwhen.com/
And I follow “Make a Time!”
Then I should see “Create Notification”
When I fill in “Time” with “Tomorrow”
And I fill in “Title” with “Test Notification”
And I fill in “Message” with “This is the message in the notification”
And I press “Create Notification”
Then I should see “Test Notification”
And I should see “This is the message in the notification”

We’ve gotten pretty good feedbacks so far from users and expert judges. We’ve already made plans to take this forward and make this into an awesome product. Let us know if you’ve anyway suggestions.

There’s only a few Other teams from Australia, they produced pretty cool stuff too.

HereTil by http://railsrumble.com/teams/rocket26
Desks Near Me by
http://railsrumble.com/teams/the-rad-warlike-annex

RedCity by http://railsrumble.com/teams/red-city-crew

There’s also two teams from Hong Kong which I thought did pretty well.

http://kookiebox.r10.railsrumble.com

http://newsprank.r10.railsrumble.com

You can soon vote for us here: Team- The Wizard of Oz

Hong Kong Startup Summary 2009

There’s alot of startup activities in Hong Kong and not many people know about it. Since I didnt have much time myself during the year I’ll try to summarize what I know in one post and also making some predictions for 2010. In 2009 there’s some successes, some fell into the deadpool and I’m sure some companies you have never heard of. Please excuse me if I have missed anyone and I have no intention to exclude anyone for any purpose. However, I do believe HK startups need more press!

Hong Kong Startups 2009

2009 is the year of iPhone and Facebook apps.

With the popularity and coolness of the iPhone, HK has spurred a new industry and group of indie developers. Here’s some indie and startups of note. (My apologies for not having much detailed research on HK iPhone apps market. This is purely as a user point of view)

Bill So: Finger: Turns iPhone/iPod touch into Chinese writing tablet.

Nuthon (Leo To – 杜B): Developed various Location based application like Toilet Rush and 行Guide.

Conceptable.net: HK Weather, Reading.
ThinkBulb: Puri (Photo Sticker app with 580k+ downloads)
Stepcase (Leon Ho): Darkroom, Meeting Time, Lifehack, Enroute.
Crispy Comics: Casey Lau, first publisher for original comics distributed on the iPhone, it kicked off this Summer with “Super Kaiju Hero Force”.

iPhone App generators:
motherapp – A Science Park incubated company released their multiple mobile platform application generator. Some successful application using the technology are OpenRice, TDC. They also won the Bronze prize of HK ICT Innovation and Research award.

Kanchoo – A web application that generates iPhone apps specifically for news publishers. Founded by cubicle muses – Aaron, William and Michael.

aNobii – A book lover social network very popular in Italy released iPhone app that can scan barcode and add to your own virtual book shelf. A Facebook app. The same team also launched a mooshnow.com + iPhone app, which is a movie reviews web site.

Facebook apps
6wave: Ex-Yahoo workers Ng, Cheng, and Lee, a startup that has developed social applications and casual games on the Facebook platform with 32 milion monthly users.

Pencake – A successful DIY e-card web portal. I know the two brother team has recently built some popular facebook applications. Some of you might have used their app without knowing – polling, quizes and 成份分析. They are targeted at the Chinese speaking communities like HK, Taiwan, Singapore and Malaysia. Now they are helping companies promote their facebook fan page. They also moved into HK Science Park in 2009.

Online Video – my area of interest 🙂
Ankoder – Obviously I’m biased here. I believe Ankoder was the first platform as a service based on Amazon’s cloud computing services launched out of HK. Also based in the Science Park, I will definitely have more product news in 2010. So far the clients are coming from US, Europe and Australia.

goyeah – A free online movie portal, basically saves you from buying the old favorite on VCD. I’m not sure what their plans are in 2010. There’s some cool flash interactive video campaigns with HK comedian.

anyplex – Subscription based movie portal that works directly with setup boxes. They actually moved out of Science Park in 2009. They have agreements and partnerships with movie producers in place so they are set for a bright 2010.

vcast.tv – A video portal with some 2nd tier video content going on with advertising model. Still too early days to tell if it’ll work or not. Their core competency is doing event video streaming. Their mobile video portal also won the Gold prize in ICT mobile award 2008.

vcasmo – Synchronize your video with power point presentations. Launched in 2008 have a strong client base in Japan. Similar to Omnisio.com which was acquired by Youtube early 2009.

choochootv – an artists video blog.

Groups and Meetups
Startup networking events were more than ever, too much that I couldn’t attend all of them.

HKSUA – They have held numerous useful workshops that are very informative to startups.

Wordcamp – Matt Mullenweg came over to HK and held a wordpress fan + blogger meetup.

0 to 0.1 – Organised by Greg and Leon, which provided mentorship to a few groups of University students during the summer holidays. The goal was to launch their lean startup in a few months.

Amazon Web Services Evangelist – Jeff Barr visited HK.

Web Wednesday – Napoleon managed to invite Guy Kawasaki (Jackie Chan of VC) along while he was in HK.

Barcamp:
Most notable was probably the presentation by Ko Kin, who is a 100% Hongkonger that started and established a mobile game company in Mainland China. He wrote a book about his 10 years experience and released the PDF version under creative commons license.
Here’s Aaron’s review of the day.

Cyberport Venture Capital Forum (CVCF)
This year’s theme was angel investment. Some well respected celebrity in the VC world made it to HK. – Dave McClure and Aydin Senkut.

Startup Mondays
A group of entrepreneurs formed a regular meetup after seeing the gap from CVCF.
Also a group blog at startupshk.com

Other groups and events of note:

香港青年創業家聯盟
Punchparty Cantonese speaking events with local bloggers and tech enthusiasts.
BloggerCon– Annual Blogger Conference.
Agile HK was pretty much dead in 2009 since the financial crisis and Thoughtworks moved out of HK.
Ruby on Rails HK – Sorry I was supposed to organise this one, my bad.
Cocoahead – Bill has been keeping up with organising this iPhone+Mac developer group while he also helped out with TEDx Taipei.
tweetups, twestival.
iPhanatics – organised by Casey Lau, who also created Popcorn Network – Hong Kong’s first e-commerce blog network featuring the best of fashion, gadgets and wine.

Funding:
Although I didn’t see significant funding activities for HK startups, there’s some good news and groups formed that are showing good signs.

Tolo Harbour Angel Group. I have never joined or invited :P, but there’s definitely some activities there. I could see Dominic from Darkhorse in the pictures and Chinese University and Science Park staff are involved.

Cyberport Creative Micro Fund (CCMF)
YCombinator style – 100K HKD to be awarded to 5 companies. Deadline was late October and granted companies announcement will be on Jan 11 2010.

Zendesk, although a Danish company, one of the partner Michael, was based in HK during the early days and had sponsored some local startup events. They received series A and series B in 2009, now with their headquarters in San Francisco.

Editgrid – the iconic HK Web 2.0 startup had rumored to be acquired by Apple.

Outblaze – Although not really a startup, their messaging service was acquired by IBM.

Deadpool – Social Networks
Unfortunately there’s some companies to be classified into the deadpool, interesting most of them are social network companies.

CityIn – launched in 2008, wanted to be “the” social network for south China.
Thumbdive – iPhone social network, got swamped by more focused applications like twitter, foursquare.
Harbork – Subscription model probably didn’t work.
Another social network you probably haven’t heard of – Missu.
Although Zorpia seems to be doing well, I haven’t talked to the founder myself, at least they didn’t need to fire sell like friendster. Duedee (used to be bullpoo) – A virtual stock trading social network is still hanging in there, although I heard there’s not much new development done to the site.
Another social network focused on entertainment celebrities with a name “AliveNotDead” is still alive not dead and exploring different business models like merchandizing.

More startup companies that are just doing their things.
muecs – Another science park incubatee, launched two products. One is enterprise twitter – Molaboration, similar to Yammer. Another product seems to be their first iteration was a social media market place if I understood it right.

We also have threadless like crowdsourcing designer Tshirt / products websites.
Foncept, dookaz and not so well known comedaily are peacefully propelling the crowdsourcing market in Hong Kong.

Frenzoo – A 3D avatar design your own fashion social network. They are funded by ex-Skype employees and an incuTrain graduate. They launched their virtual items market place in 2009 and have some big plans for 2010.

Sampiplan – Project management tool designed specifically for product design and production.

I know I mentioned alot of Science Park incubatees already, but there’s more.
getogeto – A social events invitation website.
gearapp – Highly customisable CRM that is adaptable to all business needs.
cartforge – Targeted ecommerce and analytics platforms.
Innoverz – Fast RIA store front.
StorBackup – Cloud based backup solution that works over unstable internet connections.
Intuitive Automata – Dr. Cory Kidd from MIT – A Robot coach designed to help people who are trying to lose and keep off weight.

2010 will be Social Media, Cloud Computing and Android
Social media marketing will get serious, especially measuring ROI. There’s a few social media conference in 2009 and more planned in 2010 already, and even Hong Kong Government CIO is on twitter. HKAIM has already organised a few social media related events
in 2009 and more to come in 2010.

There’s 2 companies I know that are in this space.
Admomo – Online Advertising Competitor’s analysis.
kmatrix CI – Social Media Buzz Monitoring system.

Any stealth startups hiding in HK?
Anyone in stealth mode should make yourself known now, because nobody cares about your secrets! But I know there’s some startups to look out for in 2010.

Jeff Lyndon – Experienced online game expert is working on something.

Thomas Pun is working on a project joining the YCombinator.

Kenneth Kwok is writing up some informative posts on web analytics tips and techniques.

Eugene Lam, ex-Googler developing a social software review website.

Vincent Chan, working on backbonehr and writing a nice startup blog at scale.cc

Thats it for 2009, this post has turned out to be much longer than I thought. Hope when I write the 2010 post it will be even longer 🙂

Online Video Platform successes in 2009

reposted from vidcompare.com A short-list of success factors we’ve seen in the Online Video Platform space so far in 2009. Of course it should include Ankoder’s launch:

VMIX raised $2 million in a B-1 round to grow sales and extend reach
Ooyala hired an outside CEO, Jay Fulcher, and raised a $10 million C-round to boost product (monetization) and reach in APAC
Kit-Digital bought competitor The Feedroom
Brightcove extended it’s global reach and announced a 200 strong Partner Alliance
Veeple launched new interPlay product product
Kaltura officially launched its Open Source video platform, and created the Open Video Alliance
Magnify.net introduced the notion of “video curation”, signed new partnerships
PermissionTV rebranded as VisibleGains refocusing on video e-commerce
Sorenson Media dove head first into the OVP game with Sorenson360

Want to put the upcoming HK IT Events to your blog?

Grab this code, I’ve added it to my sidebar.

You can always create one, of course http://twitter.com/goodies/widget_profile
Use the profile: @hkitevents

Who is @hkitevents?
It is not a person, it is a robot. It posts the upcoming event 1 day before hand. It reads the events from the google calendar that I setup over a year ago. http://tinyurl.com/hkitcal. If you would like to contribute, please give me a shout!

The source code of this twitter bot is available on github – http://github.com/rorcraft/ical2tweet

ps. sometimes I tweet about the events not on the calendar by hand.. 😛 so please help!