Tag Archives: performance

How golang garbage collection works

It is a Mark-and-Sweep GC. Phases Mark Stop-the-World: Set write barrier (to know how much was allocated during maark phase) Concurrent: Mark all memory which is still in use by the app Stop-the-World: Remove write barrier Concurrent: Sweep (it actually happens on new allocations) Details/Algorithm It’s a tri-color process: grey for objects to check, black …

Read more

PgBouncer and prepared statements

In our system, we use connection pooler called PgBouncer as a proxy to PostgreSQL server. PgBouncer has two main modes Session pooling mode This mode is less performant (it’s a default mode). When a client connects, a server connection will be assigned to it for the whole duration it stays connected. So it does not …

Read more

How go code is being compiled to assembler code

https://go.godbolt.org/z/31FyJ3 I was interested in comparing line 15 vs line 17 of the following code: package main import «fmt» type kv struct { key []byte value []byte } type sliceMap []kv func (sm *sliceMap) Add(k, v []byte) { kvs := *sm if cap(kvs) > len(kvs) { kvs = kvs[:len(kvs)+1] } else { kvs = append(kvs, …

Read more

How to analyze the performance of your go application in production

You should definitely use chi’s middleware for running pprof and stuff in your admin panel. That’s the repo — https://github.com/go-chi/chi That’s the profiler — https://github.com/go-chi/chi/blob/master/middleware/profiler.go CPU profiling After that you can run something like this in shell: go tool pprof -png ~/Downloads/profile Or just open it in the browser: go tool pprof -http=:1234 ~/Downloads/profile If …

Read more

PostgreSQL: TOP slow queries

SELECT rolname, calls, total_time, mean_time, max_time, stddev_time, rows, query, regexp_replace(query, ‘[ \t\n]+’, ‘ ‘, ‘g’) AS query_oneline FROM pg_stat_statements JOIN pg_roles r ON r.oid = userid WHERE calls > 100 AND rolname NOT LIKE ‘%backup’ ORDER BY mean_time DESC LIMIT 15;

Simple way to detect browser’s FPS via JS

It’s dumb and dead simple but works. You can even track browser’s metrics with that. (() => { const times = []; let fps; function refreshLoop() { window.requestAnimationFrame(() => { const now = performance.now(); while (times.length > 0 && times[0] {console.log(fps);}, 1000) })();

Performance comparison table for javascript frameworks

http://www.stefankrause.net/js-frameworks-benchmark7/table.html Example results are as follows:

Особенности setInterval на практике

Раньше я был уверен, что в этом случае setInterval ставится на выполнение раз в секунду, что бы ни произошло: setInterval(function () {}, 1000); Но, видимо, это не так. Если в очереди уже есть задача от этого интервала, то новая задача туда не поставится. Вот пример: http://jsbin.com/rifahi/edit?html,js,output Поэтому сам с собой он борьбу за ресурсы не …

Read more

Советы по производительности AngularJS

Это перепечатка статьи Релиз Angular.js 2.0 приближается, а проблемы с производительностью первой версии все еще остаются. Эта статья посвящена оптимизации Angular.js приложений и будет полезна как начинающим, так и тем, кто уже использует этот фреймворк, но еще не сталкивался с проблемами его производительности. Немного простой теории Как известно, Angular.js это декларативный фронт-енд фреймворк, предоставляющий удобный …

Read more

Ошибки при разработке AngularJS-приложения

Старайся содержать контроллеры максимально простыми. Весь повторяющийся код выноси в сервисы. Разделяй объявление методов контроллера и тела функций $scope.click = click; $scope.$watch(‘item’, watchItem); function click(e, item) { … } function watchItem(item) { … } Не полагайся на наследование $scope-ов контроллеров. Этот ад ты потом не сможешь поддерживать. Достаточно будет при редизайне перенести блоки или выделить …

Read more