Skip to content
This repository has been archived by the owner on Jul 11, 2021. It is now read-only.

cargo build returns error and perf improvement #29

Closed
xin-e-liu opened this issue Apr 16, 2018 · 26 comments
Closed

cargo build returns error and perf improvement #29

xin-e-liu opened this issue Apr 16, 2018 · 26 comments

Comments

@xin-e-liu
Copy link

➜ rediSQL git:(master) cargo build --release
error: failed to load source for a dependency on engine_pro

Caused by:
Unable to update file:///home/tetter/redis/rediSQL/engine_pro

Caused by:
failed to read /home/tetter/redis/rediSQL/engine_pro/Cargo.toml

Caused by:
No such file or directory (os error 2)

Looks like the Cargo.toml file is missing in engine_pro?

Thanks,
Xin

@siscia
Copy link
Collaborator

siscia commented Apr 16, 2018

Thanks for your report.

I will look into it first thing tomorrow!

@siscia
Copy link
Collaborator

siscia commented Apr 17, 2018

We hit a known issue in cargo: rust-lang/cargo#4544

At the moment it seems like there is no way around the problem but removing the dependency.

The last commit 0b65cb2 should make it compile also on your machine.

Can you confirm?

Cheers,

@xin-e-liu
Copy link
Author

It works now! Thanks! on centos libclang version > 3.9 is needed. So had to get that there as the default version is 3.4

I'm trying to run the performance test:

➜ performance git:(master) ✗ python rediSQL_bench.py
Starting performance test
Creating tables
Traceback (most recent call last):
File "rediSQL_bench.py", line 162, in
prepare_tables(redis_pool)
File "rediSQL_bench.py", line 31, in prepare_tables
r.execute_command("REDISQL.EXEC", t)
File "/usr/lib/python2.7/site-packages/redis/client.py", line 668, in execute_command
return self.parse_response(connection, command_name, **options)
File "/usr/lib/python2.7/site-packages/redis/client.py", line 680, in parse_response
response = connection.read_response()
File "/usr/lib/python2.7/site-packages/redis/connection.py", line 629, in read_response
raise response
redis.exceptions.ResponseError: Wrong number of arguments, it accepts 3, you provide 2

The python redis installed is: https://pypi.org/project/redis/ 2.10.6 Looks like there is some protocol/version mismatch. Could you pls also shed some light on this?

Thanks,
Xin

@siscia
Copy link
Collaborator

siscia commented Apr 17, 2018

Hi Xin,

actually it is my fault. The performance test should not be there.

It is quite hard to get out sensible measurement from python script like I tried to do.

If you want to stress test RediSQL the best thing to do is to run redis-benchmark, one or multiple instances.

(I wrote the scripts that follow by heart, there may be some minor mistake)

What I usually do is something like:

Inside redis-cli we create the environment.

> REDISQL.CREATE_DB DB
> REDISQL.EXEC DB "CREATE TABLE test (a INT, b INT);"
> REDISQL.CREATE_STATEMENT DB insert "INSERT INTO test VALUES(?1, ?2)"

Then we stress test it with

redis-benchmark -c $n_clients -n $total_times REDISQL.EXEC_STATEMENT DB insert 1 2

With this test you are inser $total_time (100_000 by default) times the value 1 and 2 into the table using $n_client (50 by default).

What you are really testing here is the number of transaction you are executing. I expect it to be well over 10k/sec but it definitely depends on your machine.

On my machines setting $n_client to ~200 gives the best results.

Again, you are testing the number of write transaction not the number of insert, doing something like this:

> REDISQL.CREATE_STATEMENT DB insert "INSERT INTO test VALUES(?1, ?2), (?2+1, ?1+5), (?1-?2, ?2*?1)"

Will insert 3 times as much data in the same number of transaction so it will be pretty much similar in throughput and latency.

Similarly you could test the reads, but be aware that if you are reading a lot of data you need to consider the time to transfer the data and the time to find the value in the database.

The write transaction is definitely the simplest thing to test.

If you need you could also test multiple databases:

> REDISQL.CREATE_DB DB1
> REDISQL.CREATE_DB DB2
> REDISQL.EXEC DB1 "CREATE TABLE test (a INT, b INT);"
> REDISQL.EXEC DB2 "CREATE TABLE test (a INT, b INT);"
> REDISQL.CREATE_STATEMENT DB1 insert "INSERT INTO test VALUES(?1, ?2)"
> REDISQL.CREATE_STATEMENT DB2 insert "INSERT INTO test VALUES(?1, ?2)"

And then in multiple instances of redis-benchmark

redis-benchmark -c $n_clients -n $total_times REDISQL.EXEC_STATEMENT DB1 insert 1 2
redis-benchmark -c $n_clients -n $total_times REDISQL.EXEC_STATEMENT DB2 insert 1 2

I am expecting this to scale sublinearly to the number of database.

I would love if you could share the result of your benchmarks.

@xin-e-liu
Copy link
Author

Thanks for the detailed response. I'm evaluating redisql for a project, with a lot of writes, and reasonable read. I'll try more and let you know. Thanks!

@siscia
Copy link
Collaborator

siscia commented Apr 17, 2018

I figure out that I should provide at least some form of benchmarking so I get some data.

These measurements are from an AWS EC2 c4.8xlarge which is a beast machine and the module leaves it pretty idle.

After all redis is single thread and SQLite is single thread on writing so getting 180% of cpu was already quite good IMHO.

Anyway here are the raw result: https://gist.github.com/siscia/b8a960a1af68cf3c6d27a2513cd44046

I will write an article in the next few days about them.

Spoiler, I got north of 50k write transaction per second.

I don't see many ways to get orders of magnitude better than this, maybe we can shave something off but nothing too big.

Cheers,

@xin-e-liu
Copy link
Author

Thanks for the results.

Have you tried with bigger text columns? I tried an experiment with like 20 columns, 10 int, 10 text. Each text column like 10k size (yes it's big). So one row around 100k.

Benchmarking shows around 2k requests/s.

With pure redis SET, 100k value size, around 10k request/s. Of course pure set is easy and redisql does a lot of indexing stuff background. This is with redis-benchmark, do you think the bulk input pipe would help? I guess not given redis-benchmark has pipeline. So looks like to get even higher throughput, one has to do sharding...

@siscia
Copy link
Collaborator

siscia commented Apr 18, 2018

Wow, you are really stressing it!

When you talk about 10k you mean 10k bytes?

Do you mind to share your test? I am talking about the table structure and the redis-benchmark command you used.

I haven't thought about such extreme use case, but let's see if we can improve it.

@xin-e-liu
Copy link
Author

Sure.

I'm just doing something like this:
redis-benchmark -c 200 -n 100000 $(cat cmd_short.txt) -P 1000 -q

where cmd_short.txt is like:
REDISQL.EXEC_STATEMENT DB insert 1 2 3 4 5 6 7 8 9 ASDF... ASDF... ASDF... ASDF... ASDF... ASDF... ASDF... ASDF... ASDF... ASDF... ASDF...

Each ASDF... is a big string with size around 10k.

This gives me about 2k requests/s.

I also tried pure SET:
redis-benchmark -t set -n 1000000 -c 200 -d 114000 -P 100
This gives me about 10k requests/s.

So there is about 5 times difference, and I'm assuming this is due to pure SET is really simply and redisql does a lot more stuff.

@siscia
Copy link
Collaborator

siscia commented Apr 18, 2018

Ahahaha, alright was simpler than I though.

Thank you so much!

There are some places where we are doing some allocation and data movement that we should be able to avoid. I guess this is the reason for the huge difference in performance.

I will try some experiment and I will come back to you as soon as possible (it may take some days.)

Or if you know rust and want to take a shot at this I can provide guidance, beware it could become quite complex quite fast since there are going to be quite a bit of lifetime to manage.

@xin-e-liu
Copy link
Author

I don't know rust... but if you could provide a few pointers of where those allocs happen, I can probably take a stab and see how far I can go. Thanks!

@siscia
Copy link
Collaborator

siscia commented Apr 18, 2018

It would be quite complex in rust especially if you don't know the language.

If you are interested in learning it and you want to try I would start looking here: https://github.com/RedBeardLab/rediSQL/blob/master/src/lib.rs#L154 and see if we can remove that .to_vec() then also here we are moving memory: https://github.com/RedBeardLab/rediSQL/blob/master/redisql_lib/src/redis.rs#L428 (we are creating a new vector and we are filling it with strings).

I believe it is not gonna be easy and I am quite sure it is not the most friendly way to learn rust.

Anyway, what I would suggest first is being sure that SQLite can provide better performance.

I run this TCL script

package require sqlite3
sqlite3 db :memory:
db eval { CREATE TABLE test (a INT, b INT, c INT, d INT, e INT, f INT, g INT, h INT, i INT, l INT, aa TEXT, bb TEXT, cc TEXT, dd TEXT, ee TEXT, ff TEXT, gg TEXT, hh TEXT, ii TEXT, ll TEXT); }

set bigstring oTaazFODW6YuU9fvTN6Asz4LQ2Mz3RQsNgvGK7uiTwY1h9fbrdp8tj2q54l2knkM2f2gFs4xz2SAKTlbW0OBfwpavRicWFhycxjuMGmG930TC6Kay90heHBC7HKOTAPw62kPaAiPVRHHBUeC6ZkFdSolT6u58POPPArQTrH65NhSjGRt3pfpfT0HXFjKMbsY5AvrYY67FaCuUnlSYT0X1bLfpX4sh3MV0CkoaUBmOQVYz2ixF1sjD8g493Yk97PszKIvx8AOSxnQ6zDsaZ8DdrSu4PxdJIAoZlWsKKaizbHEFQbzqM6xNd6BmS7vhVE9Ofg7b7hVtmAlQLAlpvjwOdDSr0owflCJipkVIOhJXEDgX9d36Gj1TMUzfwCQ9I0zh6QYzLRTxQFJx3jbJELOfq4sCSiEkNY0XbPRtTPn69v7n9IDjuGEC2J5no8vpkPV7XpL2JxcjdgdUIul3fGuve7t3gP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WcAmbryrLOvEl9bVkXrC70dysTGOvXKzI3RfK9gX0ziXngC4YX8RmkTdpaww1eFkeBQDzUfQIlB6J9it1bdH2e6AOGYo0gbWxOfM1lX1jpJmC3TeLbiUA1kpYATGwBtSl7GG6tvhU5bXWWrgsmVxEeFA1RubRwc5SP7LxO5XvaocjRrdv1mlS6NU6g1Hll6m5qMAccwfZwEsx3ezHpYZETT9cQDSwbZLmrkqUIAYC6uFibVVmmQPfulAtazI0NWWPTGrj2ZOdiNQRn8DOgvI2OluQKEyOyerzF3lSM44gUN5iqjfCENXGmIanAYfEzRRNSGwXPWlT6Da19HZWmvAJaixcwa01lWXgn7d6PEhlD0KFd1OMCw5cBwRK7ridW4pimKKZBIISCzfJGDk9alM2o7qwXcpan3IraNtROOVK1nkqw9r5CcTa8rvl1QwKrnQDlcySbpqTZ0KdY2ONFE8ATPcSFLYbLUtn1gkCvF7NvWpBhPWNYadxG7flExNJLzmzHkyw8GfVzvQUieuewlGRHGEZYltdJN7UNrpljiX77xbYubDupWlrW05Xhvq4JMHnodhjXAA49sEUriI2Q7mqgvYogBvHgloZJUEOioxpGFLK6cripxFzWYG7xeoLfDheVc00YutdrNdzDtg0AdOzoWpVuapVdLFzNyt2gEfrvvlXUKq27JAqavYVvIN5zTsbhYqXS2lm6x7XwKbcYOVqot6ghYE5iWzXggnnftV5aKEbiDQlGMrcn3dlbYQi90KYDaGpVRvBdgLvjiJI2LLPKbFk18H1iLRQU4htxlcWrir38UecJrFfzcl3UhGZ4lzH 

proc insert_n_rows {n} {
  for {set i 0} {$i<$n} {incr i} {
    db eval { INSERT INTO test VALUES(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, $bigstring, $bigstring, $bigstring, $bigstring, $bigstring, $bigstring, $bigstring, $bigstring, $bigstring, $bigstring) }
  }
}

set nStep 100000

for {set i 0} {$i < 100} {incr i} {
  set us [lindex [time { insert_n_rows $nStep }] 0]
  puts "[expr $i*$nStep] [format %.2f [expr (1000000.0 * $nStep) / $us]]/sec"
}

And it seems to have quite reasonable performances, if you could replicate it and confirm that this is what we want it would be great!

@xin-e-liu
Copy link
Author

This is from the same host where I tried redis:

➜ redis tclsh sqlite_test.tcl
0 335889.45/sec
100000 292093.61/sec
200000 331140.08/sec
300000 299299.04/sec
400000 285272.52/sec
500000 314314.18/sec
600000 326883.91/sec
700000 328050.62/sec
800000 282876.63/sec
900000 283617.14/sec
1000000 326392.06/sec
1100000 331548.50/sec
1200000 314786.13/sec
1300000 332517.56/sec
1400000 323021.41/sec
1500000 325151.44/sec
1600000 329544.67/sec
1700000 291952.90/sec
1800000 306515.29/sec
1900000 314255.90/sec
2000000 326737.59/sec
2100000 326872.16/sec
2200000 328044.17/sec
2300000 327582.08/sec
2400000 332852.92/sec
2500000 328659.79/sec
2600000 323537.69/sec
2700000 273305.44/sec
2800000 271109.24/sec
2900000 310736.57/sec
3000000 308788.75/sec
3100000 290409.80/sec
3200000 298979.58/sec
3300000 310722.09/sec
3400000 327442.64/sec
3500000 327104.18/sec
3600000 320485.09/sec
3700000 313140.96/sec
3800000 332447.91/sec
3900000 298129.24/sec

Looks pretty good. Is it 300k rows per second? I see 10m rows added in 30s :--) And each row is like 100k size

@siscia
Copy link
Collaborator

siscia commented Apr 18, 2018

How you can see single thread performance are not the issues.

Unfortunately we will never get to 300k/s since Redis top to 10k/s something more realistic would be 5k/s but also that is not easy...

I will try my best and keep you updated :)

@xin-e-liu
Copy link
Author

Thanks! I have a few quick questions regarding redisql and hope you could help:

  1. look like the combination of redis and sql in redisql context, redis is just a client facing interface, all actual data storage is done by sqlite. There is no redis internal storage/data structure being used.
  2. For a table created, is each column by default indexed in sqlite, or we will have to issue the index sql statement to get that column indexed?

@siscia
Copy link
Collaborator

siscia commented Apr 20, 2018

Sure!

  1. Yes Redis is used only as a layer for connectivity here. It is actually possible to have the data you write in SQLite appear also in Redis but it is not yet possible the other way around (I am sawing some development in this direction in redis, so maybe the next minor release 4.0.10 will provide us with this capability)

  2. Assuming that with index you mean those data structures that makes find a row faster inside a database. No, RediSQL does not create any index for you, they make writes a little slower and are technical choice that the user should do. However SQLite automatically indexes the primary key in your tables.

https://sqlite.org/queryplanner.html
https://sqlite.org/optoverview.html

@siscia
Copy link
Collaborator

siscia commented Apr 22, 2018

Hi Xin,

would you mind to run again your performance tests?

I would like you to compare the result of the master branch with the result from the branch type_refactor

In my test the performance for very heavy insert doubled from one to the other. I would like some indipendent confirmation also from you.

As always you should be able to compile with cargo build --release

Thanks,

Simone

1 similar comment
@siscia
Copy link
Collaborator

siscia commented Apr 22, 2018

Hi Xin,

would you mind to run again your performance tests?

I would like you to compare the result of the master branch with the result from the branch type_refactor

In my test the performance for very heavy insert doubled from one to the other. I would like some indipendent confirmation also from you.

As always you should be able to compile with cargo build --release

Thanks,

Simone

@xin-e-liu
Copy link
Author

Sure. I just pulled it and got a compilation error. Is there something not comitted?

error[E0583]: file not found for module redis_type
--> redisql_lib/src/lib.rs:4:9
|
4 | pub mod redis_type;
| ^^^^^^^^^^
|
= help: name the file either redis_type.rs or redis_type/mod.rs inside the directory "redisql_lib/src"

error: aborting due to previous error

The following warnings were emitted during compilation:

warning: src/CDeps/SQLite/sqlite3.c: In function ‘exprAnalyze’:
warning: src/CDeps/SQLite/sqlite3.c:131527:39: warning: ‘pLeft’ may be used uninitialized in this function [-Wmaybe-uninitialized]
warning: pNewTerm->u.leftColumn = pLeft->iColumn;
warning: ^
warning: src/CDeps/SQLite/sqlite3.c:93128:39: warning: ‘pRight’ may be used uninitialized in this function [-Wmaybe-uninitialized]
warning: return p ? exprDup(db, p, flags, 0) : 0;
warning: ^
warning: src/CDeps/SQLite/sqlite3.c:131506:11: note: ‘pRight’ was declared here
warning: Expr *pRight, *pLeft;
warning: ^
warning: src/CDeps/SQLite/sqlite3.c:131529:28: warning: ‘eOp2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
warning: pNewTerm->eMatchOp = eOp2;
warning: ^

error: Could not compile redisql_lib.

@siscia
Copy link
Collaborator

siscia commented Apr 23, 2018

Sorry,

you should be good now.

Thanks for catching this error up, really appreciated.

@xin-e-liu
Copy link
Author

I get around 8.2k requests/s with around 100k payload :--) Much much better!

@xin-e-liu
Copy link
Author

btw, just tried pure redis set with a few combinations of benchmark arguments. turns out i can get to 27k/s

➜ redis redis-benchmark -t set -n 1000000 -c 1 -d 114000 -P 100
^CT: 26971.79

I'll try out redisql a few different combinations and see how it goes

@xin-e-liu
Copy link
Author

Looks like I can get to a bit more than half of what pure set can get.

14710.21 requests per second

Mon Apr 23 07:15:56 PDT 2018
➜ redis date; redis-benchmark -c 4 -n 100000 $(cat cmd_short.txt) -P 5 -q; date

@siscia
Copy link
Collaborator

siscia commented Apr 23, 2018

Wow, personally I am quite satisfied by 8k request/s (which is the same figure I was getting), if you can get that up to 14k request/s even better.

Do you need it to go even faster? It would require some significant work that I am not even sure what make it slower than pure redis.

Between today and tomorrow I will make an official release with this changes :)

Thanks so much for your feedback, it really helped.

If you are satisfied I would suggest you to close the issue 😃

@xin-e-liu xin-e-liu changed the title cargo build returns error cargo build returns error and perf improvement Apr 23, 2018
@xin-e-liu
Copy link
Author

Edited the title to reflect more of what is discussed, and closing. Thanks! I'll also try with some more indexing with redisql :--) will see. Thanks!

@siscia
Copy link
Collaborator

siscia commented Apr 23, 2018

Wonderful!

Thank you so much that your feedback is been fundamental.

Also, I am looking for beta tester for the PRO version (the one with replication) if you are interested let me know (you should be able to see my email) and I will provide to you the executable.

Thanks again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants