Skip to content

Instantly share code, notes, and snippets.

View dunnock's full-sized avatar
🎯
Focusing

Maxim Vorobjov dunnock

🎯
Focusing
  • I like programs that fulfill business needs
  • Kyiv, Ukraine
  • X @maxsparr0w
View GitHub Profile

Keybase proof

I hereby claim:

  • I am dunnock on github.
  • I am dunnock (https://keybase.io/dunnock) on keybase.
  • I have a public key ASDpWWEX9Xl7bjpVrNJknPepyfdx3jg8hvsAFAobMvTObwo

To claim this, I am signing this object:

@dunnock
dunnock / GetTasksQuery.rs
Created March 1, 2020 11:32
actix-node-benchmark: GetTasksQuery Rust definition
#[derive(Deserialize)]
pub struct GetTasksQuery {
pub summary: Option<String>,
pub assignee_name: Option<String>,
pub limit: Option<u32>,
pub full: Option<bool>
}
@dunnock
dunnock / deadpool-get-tasks.rs
Last active March 1, 2020 11:24
actix-node-benchmark: Rust get-tasks via deadpool
pub async fn get_tasks(pool: Arc<Pool>, query: GetTasksQuery) -> Result<Vec<Task>, BenchError> {
let _stmt = query.get_statement();
let client = pool.get().await?;
let stmt = client.prepare_typed(&_stmt, &[Type::VARCHAR, Type::VARCHAR, Type::OID]).await?;
client.query(
&stmt,
&[ &like(query.assignee_name), &like(query.summary), &query.limit.or(Some(10)) ],
).await?
@dunnock
dunnock / knex-get-tasks.js
Created March 1, 2020 11:19
actix-node-benchmark: JavaScript get-tasks via knex
async function get_tasks(assignee_name, summary, limit, full) {
let query = full ? query_get_tasks_full() : query_get_tasks();
if (!!assignee_name) {
query.where("assignee.name", "LIKE", `%${assignee_name}%`)
}
if (!!summary) {
query.where("summary", "LIKE", `%${summary}%`)
}
query.limit(limit || 10);
@dunnock
dunnock / actix-node-benchmark-load-tasks.csv
Last active March 1, 2020 11:09
actix-node-benchmark: run 2: /tasks?summary=wherever&full=true&limit=10 with concurrency =1..512, pool of 15 connections
Target Concurrency PSQL cpu mem Node cpu mem Actix cpu mem lat ms rps
node 2 1.89 2153 0.12 59 0.00 28 39.89 50
actix 2 1.77 2153 0.00 68 0.20 28 5.77 346
node 4 3.75 2363 0.20 70 0.00 28 42.20 94
actix 4 3.62 2363 0.00 86 0.34 28 5.92 674
node 8 7.59 2829 0.37 84 0.00 28 45.49 175
actix 8 7.20 2828 0.00 87 0.58 28 6.12 1305
node 16 14.63 3668 0.59 93 0.00 28 48.58 328
actix 16 13.50 3668 0.00 88 0.88 29 6.43 2486
node 32 14.62 3669 0.60 89 0.00 29 97.28 328
@dunnock
dunnock / actix-node-benchmark-tasks-4cpu.csv
Last active March 1, 2020 10:28
actix-node-benchmark: run 2: /tasks with concurrency =1..1024, pool of 30 connections and 4 threads
Actix workers Concurrency PSQL cpu mem Actix cpu mem lat ms rps
1 2 0.89 126 0.42 5 0.98 2022
4 2 0.91 380 0.73 6 0.97 2042
1 4 2.01 183 0.80 5 0.88 4520
4 4 1.94 408 1.34 6 0.89 4432
1 8 3.42 298 0.99 6 1.06 7525
4 8 3.83 508 2.15 6 0.95 8300
1 16 3.89 469 1.00 6 1.98 8076
4 16 6.69 708 3.00 7 1.11 14257
1 32 3.61 498 1.00 7 4.01 7963
@dunnock
dunnock / actix-node-benchmark-load-tasks.csv
Last active March 1, 2020 11:17
actix-node-benchmark: run 1: /tasks with concurrency =1..512, pool of 15 connections
Target Concurrency PSQL cpu mem Node cpu mem Actix cpu mem lat ms rps
node 2 0.58 112 0.91 86 0.00 5 2.19 919
actix 2 0.89 126 0.00 86 0.42 5 0.98 2022
node 4 0.68 155 1.02 87 0.00 5 3.58 1123
actix 4 2.01 183 0.00 87 0.80 5 0.88 4520
node 8 0.76 242 1.02 87 0.00 5 6.51 1232
actix 8 3.42 298 0.00 87 0.99 6 1.06 7525
node 16 0.73 395 1.02 87 0.00 6 13.10 1221
actix 16 3.89 469 0.00 87 1.00 6 1.98 8076
node 32 0.75 498 1.02 86 0.00 6 23.83 1342
@dunnock
dunnock / api_pg.js
Created February 25, 2020 14:09
actix-node-benchmark: JavaScript get_tasks handler
async function get_tasks(params, offset, res) {
let conn = (params["full"] == "true")
? db.get_tasks_full()
: db.get_tasks();
let { client, config } = await conn;
let values = [
!!params["assignee_name"] ? `%${params["assignee_name"]}%` : null,
!!params["summary"] ? `%${params["summary"]}%` : null,
@dunnock
dunnock / get_tasks.js
Last active March 1, 2020 11:54
actix-node-benchmark: JavaScript get_tasks handler
router.get('/tasks', (req, res, next) => {
let { assignee_name, summary, limit, full } = req.query;
full = full == "true";
if (!!limit && isNaN(limit)) {
return next(createError({
status: 400,
message: "limit query parameter should be a number"
}));
}
@dunnock
dunnock / actix-node-bench-db-create.sql
Last active February 26, 2020 13:02
actix-node-benchmark: create tables
CREATE TABLE worker (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL,
email varchar(255) NULL,
score integer DEFAULT 0
);
CREATE TABLE task (
id SERIAL PRIMARY KEY,
summary varchar(255) NOT NULL,