Skip to content

Profile insert performance #457

Closed
Closed

Description

@coffeemug

1.4. reportedly has an order of magnitude slowdown on inserts. We should figure out what's going on here pre-release, as this is too big a regression to ignore.

Activity

  1. ghost assigned on Mar 12, 2013
  2. ghost assigned on Mar 13, 2013
  3. coffeemug commented on Mar 13, 2013

    @coffeemug
    ContributorAuthor

    @neumino is running some benchmarks now, so assigning to him.

  4. neumino commented on Mar 13, 2013

    @neumino
    Member

    Using one connection, and inserting 100 documents multiple times (using the data explorer)

    r.db('test').table('test').insert([{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]).run()
    

    Results on SSD

    1.4: ~350-400 writes/sec
    1.3.2: ~550-600 writes/sec 
    

    Results on HDD

    1.4 - 12 writes/sec (If I try to execute multiple times the query, the server doesn't respond anymore)
    1.3.2 - 300 writes/sec 
    

    That should provide a rough idea about the loss of performance.

    I'll port my script to 1.3.2 and see what's happening with a more precise workload and multiple connections.
    I'll test reads at the same too.

  5. mlucy commented on Mar 13, 2013

    @mlucy
    Member

    What's the difference between the two "Results on SSD"?

  6. neumino commented on Mar 13, 2013

    @neumino
    Member

    Sorry the second one was on HDD.

    just edited my previous comment.

  7. neumino commented on Mar 13, 2013

    @neumino
    Member

    So the previous tests were run in debug mode. I just tried to build in release mode, and I still get a dozen of write per second on an hdd.

  8. coffeemug commented on Mar 13, 2013

    @coffeemug
    ContributorAuthor

    There is also a question of the web ui being inaccessible during batch inserts. This is a) bad from the UX perspective, b) hints that we block somewhere where we shouldn't, c) might give a hint as to what's wrong.

  9. neumino commented on Mar 13, 2013

    @neumino
    Member

    Running simultaneously 10 times the script /home/michel/rethinkdb/fuzzer/clean/build/fuzzer-write*.js

    1.4
    130 writes/sec
    
    1.3.2
    250 writes/sec
    

    Running simultaneously 10 times the script /home/michel/rethinkdb/fuzzer/clean/build/fuzzer-write*.js
    Both reach the limits of write/sec before the 10th instance.

    1.4
    350 writes/sec
    
    1.3.2
    1200 writes/sec
    
  10. neumino commented on Mar 13, 2013

    @neumino
    Member

    I'll check how many insert were done in my script.
    I'll check the reads too.

  11. neumino commented on Mar 13, 2013

    @neumino
    Member

    The results on the web interface don't seem to be misreported. I checked the time on my script. Here's what I get using the JS driver, one thread, 100 connections.

    For 1.4

    12 Mar 19:31:16 - 77.307s for 10000 inserts (129 writes/sec)
    

    For 1.3

    12 Mar 19:36:38 - 42.966s for 10000 inserts (238 writes/sec)
    
  12. mlucy commented on Mar 13, 2013

    @mlucy
    Member

    It's very, very strange that we only get 12 writes/second (vs. 300/second with the old code) on HDDs. I can't think of what changes to the query language would make HDDs in particular drastically slower. Does anybody have any ideas?

    I have vague memories of hearing the word fsync with regard to changes at some point; could that be related?

  13. neumino commented on Mar 13, 2013

    @neumino
    Member

    I have a table with 10K documents.
    I pull 2000 documents from them, then do some random get, using one thread, 100 connections (using /home/michel/fuzzer/clean/buikd/fuzzer-read*.js

    Here's what I get

    1.4
    260 reads/sec
    
    1.3.2
    680 reads/sec
    

    I'll merge all the files and clean my code. But we have a rough idea of the numbers now.

  14. coffeemug commented on Mar 13, 2013

    @coffeemug
    ContributorAuthor

    Welcome to the wonderful world of performance profiling.

  15. danielmewes commented on Mar 13, 2013

    @danielmewes
    Member

    Is the performance drop only when inserting into a fresh database or does it still remain after a while of inserts?
    The reason this might be important: If fsync is involved, that would presumably stall the serializer thread (which might stall the webserver / web UI too?). However - assuming direct i/o - fsync should (?) only be called when resizing the database files, which will happen quite frequently in the beginning, but rarely once the database has reached a certain size. Correct?

    PS: Here's a change to the syncing. It seems though that the only change on Linux is to now actually check the return code of fsync and to possibly call it again in a loop if it was interrupted.
    6405773#src/arch/io/disk.cc
    Also there is this which I guess should only affect OS X at all: 8facc79#src/arch/io/disk/pool.cc

  16. 3 remaining items

  17. coffeemug commented on Mar 14, 2013

    @coffeemug
    ContributorAuthor

    @srh -- ok, everything else is done. We all depend on you!

  18. danielmewes commented on Mar 14, 2013

    @danielmewes
    Member

    If I look at the number of i/o transactions per second (tps) as reported by iostat, it seems that RethinkDB 1.3.2 uses pretty much exactly 3 transactions for each insert (using a single connection). On my machine, I get a rather stable 25 inserts per second, and iostat shows about 75 tps.

    RethinkDB 1.4 (as compiled from next) on the other hand, achieves roughly 22 inserts per second with a single connection. The i/o transactions apparently required for this are varying between 100 and more than 300, with an average of about 250 tps. This would correspond to roughly 10 tps per insert.

    The write throughputs reported by iostat are on average ~0.3 MB/s for 1.3 and ~1.0 MB/s for 1.4.

    Interestingly, after I inserted a lot of documents into 1.4 (using 128) clients, then shut down the server, and restarted it afterwards, iostat now shows the same 75 tps at 25 inserts per seconds as for 1.3. I couldn't test yet whether this was related to the restart of the server, or the high number of documents inserted earlier.

    Maybe this will help to hunt down the problem...

  19. Tryneus commented on Mar 15, 2013

    @Tryneus
    Member

    So testing on newton (SSD), I don't see any discernable difference in number of writes between versions 1.4 and 1.3.2. Using a fresh data directory each time, I ran the stress client for ~20000 inserts using either one or many clients, then checked the perfmon stats for the RDB serializer. The relevant stats should be serializer_data_blocks_written and serializer_block_writes, which were very close between the two versions for all scenarios I tried. As expected, higher number of clients (higher throughput), resulted in less writes for both versions.

    One unexpected behavior I noticed was that the server would start out with slightly low performance, which would get better after doing some inserts, stopping the stress client and restarting it in a few seconds. This happened on both 1.4 and 1.3.2. This temporary drop in throughput was observed to be caused by garbage collection getting too far being the targeted garbage ratio, and changing garbage collection to high-priority.

  20. danielmewes commented on Mar 15, 2013

    @danielmewes
    Member

    Oops. Looks like I had forgotten to clean the data directory for the 1.3 test. With clean ones, there still seems to be a difference in i/o tps, but only at the beginning (and I have not tested this very thoroughly).Sorry for causing confusion.

  21. mglukhovsky commented on Mar 15, 2013

    @mglukhovsky
    Member

    Moving to 1.5 since this isn't going to make it in.

  22. coffeemug commented on Mar 18, 2013

    @coffeemug
    ContributorAuthor

    Moving to 1.4.x (not that we have 1.4.x for point releases).

  23. srh commented on Mar 18, 2013

    @srh
    Contributor

    Batched inserts implementation is present in branch sam_457_sans_libcxx, with a review in code review 269.

  24. coffeemug commented on Apr 1, 2013

    @coffeemug
    ContributorAuthor

    An update on the state of this issue -- once 1.5-sprint-1 is closed, we'll get on this. It's pretty close to completion.

  25. coffeemug commented on Apr 3, 2013

    @coffeemug
    ContributorAuthor

    This is too big and it's too late for point release. Moving to 1.5-sprint-2.

  26. coffeemug commented on Apr 8, 2013

    @coffeemug
    ContributorAuthor

    @srh -- what's the state of this issue? Will it make it into sprint-2 by Friday? (I know it's on the queue behind #207, but I'd like to know how much is left to do here and make sure we can get it into the sprint)

  27. srh commented on Apr 10, 2013

    @srh
    Contributor

    The state of this bug is unchanged from before. I'd estimate < 1 day of work, which doesn't mean one day of latency as it goes through code review.

  28. srh commented on Apr 11, 2013

    @srh
    Contributor

    The current state of the code is that the review is updated with the new version of the code that holds partial batches in memory for a while the way everybody else wanted. The main question is that of the merge of secondary indexes with batched inserts, and the exact way to write the code which updates secondary indexes. I'll need to talk about that with Joe, and it looks like that could cause about 1-2 hours of programming. I'm fairly confident the code could be done review by the end of Friday, depending on that and anything else that might go wrong.

  29. srh commented on Apr 12, 2013

    @srh
    Contributor

    In next as of dbf2f6a

  30. coffeemug commented on Apr 13, 2013

    @coffeemug
    ContributorAuthor

    FYI, this does indeed appear to speed up batched writes by a huge factor:

    OSX (SSD) 1.4.2: 2.8s
    OSX (SSD) next: 160ms
    

    Not a very rigorous test, but it's a start :) Congrats, @srh and everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions