News for hackers. Stuff that matters.
Re:Why We Chose Rails to Build Gitlab by yannovitch on Tuesday January 22, 2019 @05:03PM (#18973026)
"Ruby was optimized for the developer, not for running it in production," says Sid. "For the things that get hit a lot and have to be very performant or that, for example, have to wait very long on a system IO, we rewrite those in Go … We are still trying to make GitLab use less memory"

Honestly, I think that Go is beginning to be where Rails was few years ago, and lots of developer friends want to hop on the Go train because everybody is doing the same.

In the same time, I'm thinking about switching to Gitea or Gogs + Drone.io, because Gitlab takes just too.damn.much.memory ! Seriously, 8GB RAM to even just begin with ? (Because yes, 4GB RAM + 4GB Swap is not viable). Even my biggest website is not consuming as much.

So if I could suggest something, it would be a global rewrite in Go or something like that, to lower the requirements, not just one or two parts (excuse me, microservices ;)).

Just my 2 cents

Re:Why We Chose Rails to Build Gitlab by sytse on Tuesday January 22, 2019 @05:30PM (#18973266)
GitLab is using a lot of memory for various reasons, all of the big ones (like adding multi-threading which I proposed 3 years ago https://gitlab.com/gitlab-org/gitlab-ce/issues/3592 ) can be solved without a rewrite. I've failed to make this a priority within the company. We had people work on it for some time but the day to day of shipping features, keeping GitLab secure, and other tasks took over. I'll advocate for a dedicated performance team to solve this. Until that team is formed people like Stan are making steady progress https://news.ycombinator.com/item?id=18973499
Re:Why We Chose Rails to Build Gitlab by yannovitch on Tuesday January 22, 2019 @05:32PM (#18973297)
Thanks, VERY much appreciated !
Re:Why We Chose Rails to Build Gitlab by rapind on Tuesday January 22, 2019 @05:15PM (#18973149)
Or Elixir, or Rust, or Node. Having spent time with all of these options, Rails is still really really good for a lot of use cases. Go comes nowhere near Ruby's readability for me (but I like the lack of surprise).

Personally I'd love something typed, performant, and as readable as Ruby with a convention focused platform like Rails. Elixir + Phoenix is probably the closest I can find, but not a perfect fit. Maybe close enough though.

Re:Why We Chose Rails to Build Gitlab by Legogris on Tuesday January 22, 2019 @05:31PM (#18973284)
If we're talking memory usage, I don't think Node is necessarily a significant improvement over Ruby.
Re:Why We Chose Rails to Build Gitlab by dmlittle on Tuesday January 22, 2019 @05:22PM (#18973203)
FWIW Elixir isn't necessarily lightweight. Memory will stay pretty flat (even during high workloads) but it's not lightweight.
Re:Why We Chose Rails to Build Gitlab by jamescostian on Tuesday January 22, 2019 @05:43PM (#18973397)
> Go comes nowhere near Ruby's readability for me

I am not fluent in either, and I'm not looking to change that, but I have read code in both. I feel the exact opposite way, and I'm not trying to start a war or anything, but I was wondering if you'd be open to talking about what things in Go you find hard to read (and what things in Ruby you find very easy to read). Or is this about libraries (are Go libraries providing lower-level APIs than Ruby ones?)? Or have you read/written a lot more code in Ruby than Go?

Re:Why We Chose Rails to Build Gitlab by hazz99 on Tuesday January 22, 2019 @07:00PM (#18974217)
I agree - Go has issues, but they're not related to readability. Perhaps if you include "familiarity with the standard interfaces" (like using io.Reader) which is different to other languages, and took a while for me to get used to.
Re:Why We Chose Rails to Build Gitlab by hazz99 on Tuesday January 22, 2019 @05:40PM (#18973369)
Is there a benefit learning Elixir over Erlang? I've working a little bit with Erlang, and I've wondered if its worth the jump.
Re:Why We Chose Rails to Build Gitlab by knrz on Tuesday January 22, 2019 @07:17PM (#18974360)
Completely! With convention and macros, it's a whole new language.
Re:Why We Chose Rails to Build Gitlab by anonyfox on Tuesday January 22, 2019 @05:35PM (#18973316)
Crystal it is. Combined with the amber framework, porting the Ruby Code should be straightforward. Yes stuff isnt even 1.0 yet, but I would seriously bet on it right now.
Re:Why We Chose Rails to Build Gitlab by stanhu on Tuesday January 22, 2019 @05:56PM (#18973499)
I agree that memory requirements are too high, but I think there is a lot of room for improvement without a complete rewrite, which would be very costly. Also keep in mind that a standalone GitLab instance ships with all batteries included: PostgreSQL, Redis, etc., all of which add to the memory requirements. That being said, we are certainly looking at moving performance-critical functions into Go. See the GitLab Workhorse and Gitaly projects as examples.

There are two major ways to look at application memory usage: baseline and runtime usage. Most people pay attention to the first because that's what you see when you first deploy GitLab. However, runtime usage is just as important because a running instance could gobble up gigabytes of RAM.

Baseline memory: We've made some recent progress in reducing baseline memory usage (e.g. cutting 80-100 MB per Unicorn process in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21008). However, our Unicorn workers dominate most of the memory usage, and you can see more analysis of where our memory is going in https://gitlab.com/gitlab-org/gitlab-ce/issues/49702. https://brandur.org/ruby-memory is probably the best explanation I've seen why RAM usage in Unicorn processes often rises and doesn't come down. However, we can reduce baseline usage in a number of ways:

* Removing dependencies from the main application

* Reducing any unnecessary allocations at startup

* Moving to a multi-threaded application server (we've shipped Puma in experimental mode in https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/...)

* Improving Rails memory usage (e.g. ActiveRecord optimizations in https://github.com/rails/rails/pull/34711)

* Improving the Ruby interpreter (e.g. helping ship a compacting garbage collector, see https://gitlab.com/gitlab-org/gitlab-ce/issues/54555).

Runtime memory: Most of our runtime memory problems are often due to memory bloat or unoptimized code paths. For example, we put big dent in some of the most egregious background jobs over the last few months. For example, a change in our merge request processing in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22725... lowered 95% of our runtime usage by gigabytes. Switching to a faster XML processor in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23136 also dropped memory usage in another background job.

Obviously we're still far from where we should be, but we're making progress. If you or know anyone else who might be excited to help us, please let us know! https://about.gitlab.com/jobs/ Thanks for your feedback.

Re:Why We Chose Rails to Build Gitlab by yannovitch on Saturday January 26, 2019 @08:12PM (#19009749)
Very interesting, thanks! One idea I had was to push "plugin-ability", for example not everybody want to have the Gitlab Pages function, or some might want to completely replace Gitlab-CI by Drone or Jenkins, and all that could help lower the memory requirements. Or maybe I'm wrong?
Re:Why We Chose Rails to Build Gitlab by atomi on Tuesday January 22, 2019 @06:57PM (#18974181)
Yes on Gogs + Drone.