1. 25 1月, 2014 3 次提交
    • K
      Some refactorings on plain table · 4b51dffc
      Kai Liu 提交于
      Summary:
      Plain table has been working well and this is just a nit-picking patch,
      which is generated during my coding reading. No real functional changes.
      only some changes regarding:
      
      * Improve some comments from the perspective a "new" code reader.
      * Change some magic number to constant, which can help us to parameterize them
        in the future.
      * Did some style, naming, C++ convention changes.
      * Fix warnings from new "arc lint"
      
      Test Plan: make check
      
      Reviewers: sdong, haobo
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15429
      4b51dffc
    • K
      Re-org the table tests · 0ab76613
      Kai Liu 提交于
      Summary:
      We'll divide the table tests into 3 buckets, plain table test, block-based table test and general table feature test.
      This diff does no real change and only does the rename and reorg.
      
      Test Plan: run table_test
      
      Reviewers: sdong, haobo, igor, dhruba
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15417
      0ab76613
    • K
      Some small refactorings on table_test · 7d991be4
      Kai Liu 提交于
      Summary:
      
      Just revise some hard-to-read or unnecessarily verbose code.
      
      Test Plan:
      
      make check
      7d991be4
  2. 24 1月, 2014 5 次提交
    • K
      Remove an unused `GetLengthPrefixedSlice` · eda924a0
      kailiu 提交于
      Summary: We have 3 versions of GetLengthPrefixedSlice() and one of them is no longer in use.
      
      Test Plan: make
      
      Reviewers: sdong, igor, haobo, dhruba
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15399
      eda924a0
    • K
      Merge branch 'master' into performance · 054c5dda
      Kai Liu 提交于
      Conflicts:
      	db/db_impl.cc
      	db/db_test.cc
      	db/memtable.cc
      	db/version_set.cc
      	include/rocksdb/statistics.h
      	util/statistics_imp.h
      054c5dda
    • I
      Fix performance regression in statistics · 4e91f27c
      Igor Canadi 提交于
      Summary:
      For some reason, D15099 caused a big performance regression: https://fburl.com/16059000
      
      After digging a bit, I figured out that the reason was that std::atomic_uint_fast64_t was allocated in an array. When I switched from an array to vector, the QPS returned to the previous level. I'm not sure why this is happening, but this diff seems to fix the performance regression.
      
      Test Plan: I ran the regression script, observed the performance going back to normal
      
      Reviewers: tnovak, kailiu, haobo
      
      Reviewed By: kailiu
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15375
      4e91f27c
    • K
      Aggressively inlining the short functions in coding.cc · bb19b530
      Kai Liu 提交于
      Summary:
      This diff takes an even more aggressive way to inline the functions. A decent rule that I followed is "not inline a function if it is more than 10 lines long."
      
      Normally optimizing code by inline is ugly and hard to control, but since one of our usecase has significant amount of CPU used in functions from coding.cc, I'd like to try this diff out.
      
      Test Plan:
      1. the size for some .o file increased a little bit, but most less than 1%. So I think the negative impact of inline is negligible.
      2. As the regression test shows (ran for 10 times and I calculated the average number)
      
          Metrics                                         Befor    After
          ========================================================================
          rocksdb.build.fillseq.qps                       426595   444515    (+4.6%)
          rocksdb.build.memtablefillrandom.qps            121739   123110
          rocksdb.build.memtablereadrandom.qps            1285103  1280520
          rocksdb.build.overwrite.qps                     125816   135570    (+9%)
          rocksdb.build.readrandom_fillunique_random.qps  285995   296863
          rocksdb.build.readrandom_memtable_sst.qps       1027132  1027279
          rocksdb.build.readrandom.qps                    1041427  1054665
          rocksdb.build.readrandom_smallblockcache.qps    1028631  1038433
          rocksdb.build.readwhilewriting.qps              918352   914629
      
      Reviewers: haobo, sdong, igor
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15291
      bb19b530
    • K
      Add google-style checker to "arc lint" · d0458469
      kailiu 提交于
      Summary:
      After we reached a consensus on code format, which follows exactly
      Google's coding style, a natural follow-up is to have a style checker
      that can handle stuffs beyond format.
      
      Google already has a powerful style checker "cpplint.py" and,
      luckily, phabricator already provides the built-in linter for it!
      Next time with "arc lint" most style inconsistency will be detected
      (but will not be fixed).
      
      Also I copied cpplint.py to linters directory, which is mostly
      because we may need the flexibility to make some modifications on
      it for our own need.
      
      Test Plan:
      ran arc lint table/block_based_table_builder.cc to see the amazing
      results.
      
      Reviewers: haobo, sdong, igor, dhruba
      
      Reviewed By: haobo
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15369
      d0458469
  3. 23 1月, 2014 2 次提交
    • I
      Unfriending classes · fb01755a
      Igor Canadi 提交于
      Summary:
      In this diff I made some effort to reduce usage of friending. To do that, I had to expose Compaction::inputs_ through a method inputs(). Not sure if this is a good idea, there is a trade-off. I think it's less confusing than having lots of friends.
      
      I also thought about other friendship relationships, but they are too much tangled at this point. Once you friend two classes, it's very hard to unfriend them :)
      
      Test Plan: make check
      
      Reviewers: haobo, kailiu, sdong, dhruba
      
      Reviewed By: kailiu
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15267
      fb01755a
    • I
      Refactor Recover() code · 6fe9b577
      Igor Canadi 提交于
      Summary:
      This diff does two things:
      * Rethinks how we call Recover() with read_only option. Before, we call it with pointer to memtable where we'd like to apply those changes to. This memtable is set in db_impl_readonly.cc and it's actually DBImpl::mem_. Why don't we just apply updates to mem_ right away? It seems more intuitive.
      * Changes when we apply updates to manifest. Before, the process is to recover all the logs, flush it to sst files and then do one giant commit that atomically adds all recovered sst files and sets the next log number. This works good enough, but causes some small troubles for my column family approach, since I can't have one VersionEdit apply to more than single column family[1]. The change here is to commit the files recovered from logs right away. Here is the state of the world before the change:
      1. Recover log 5, add new sst files to edit
      2. Recover log 7, add new sst files to edit
      3. Recover log 8, add new sst files to edit
      4. Commit all added sst files to manifest and mark log files 5, 7 and 8 as recoverd (via SetLogNumber(9) function)
      After the change, we'll do:
      1. Recover log 5, commit the new sst files and set log 5 as recovered
      2. Recover log 7, commit the new sst files and set log 7 as recovered
      3. Recover log 8, commit the new sst files and set log 8 as recovered
      
      The added (small) benefit is that if we fail after (2), the new recovery will only have to recover log 8. In previous case, we'll have to restart the recovery from the beginning. The bigger benefit will be to enable easier integration of multiple column families in Recovery code path.
      
      [1] I'm happy to dicuss this decison, but I believe this is the cleanest way to go. It also makes backward compatibility much easier. We don't have a requirement of adding multiple column families atomically.
      
      Test Plan: make check
      
      Reviewers: dhruba, haobo, kailiu, sdong
      
      Reviewed By: kailiu
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15237
      6fe9b577
  4. 22 1月, 2014 2 次提交
  5. 18 1月, 2014 6 次提交
    • M
      Boost access before mutex is unlocked · 4e8321bf
      Mark Callaghan 提交于
      Summary:
      This moves the use of versions_ to before the mutex is unlocked
      to avoid a possible race.
      
      Task ID: #
      
      Blame Rev:
      
      Test Plan:
      make check
      
      Revert Plan:
      
      Database Impact:
      
      Memcache Impact:
      
      Other Notes:
      
      EImportant:
      
      - begin *PUBLIC* platform impact section -
      Bugzilla: #
      - end platform impact -
      
      Reviewers: haobo, dhruba
      
      Reviewed By: dhruba
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15279
      4e8321bf
    • K
      Misc cleanup on performance branch · ef602f62
      Kai Liu 提交于
      Summary:
      
      Did some trivial stuffs:
      
      * Add more comments;
      * fix compiler's warning messages (uninitialized variables).
      * etc
      
      Test Plan:
      
      make check
      ef602f62
    • I
      Statistics code cleanup · 83681bf9
      Igor Canadi 提交于
      Summary: I'm separating code-cleanup part of https://reviews.facebook.net/D14517. This will make D14517 easier to understand and this diff easier to review.
      
      Test Plan: make check
      
      Reviewers: haobo, kailiu, sdong, dhruba, tnovak
      
      Reviewed By: tnovak
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15099
      83681bf9
    • I
      Merge branch 'master' into performance · 8079dd5d
      Igor Canadi 提交于
      8079dd5d
    • I
      Fix SIGSEGV in compaction picker · 0f4a75b7
      Igor Canadi 提交于
      Summary:
      The SIGSEGV was introduced by https://reviews.facebook.net/D15171
      
      I also fixed ExpandWhileOverlapping() which returned the failure by setting it's own stack variable to nullptr (!). This bug is present in 2.6 release, so I guess ExpandWhileOverlapping never fails :)
      
      Test Plan: `make check`. Also MarkCallaghan confirmed it fixed the SIGSEGV he reported.
      
      Reviewers: MarkCallaghan, kailiu, sdong, dhruba, haobo
      
      Reviewed By: kailiu
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15261
      0f4a75b7
    • M
      Fix SlowdownAmount · 439e36db
      Mark Callaghan 提交于
      Summary:
      This had a few bugs.
      1) bottom and top were reversed. top is for the max value but the callers were passing the max
      value to bottom. The result is that the max sleep is used when n >= bottom.
      2) one of the callers passed values with type double and these values are frequently between
      1.0 and 2.0 so rounding will do some bad things
      3) sometimes the function returned 0 when there should be a stall
      
      With this change and one other diff (out for review soon) there are slightly fewer stalls on one workload.
      
      With the fix.
      Stalls(secs): 160.166 level0_slowdown, 0.000 level0_numfiles, 0.000 memtable_compaction, 58.495 leveln_slowdown
      Stalls(count): 910261 level0_slowdown, 0 level0_numfiles, 0 memtable_compaction, 54526 leveln_slowdown
      
      Without the fix.
      Stalls(secs): 172.227 level0_slowdown, 0.000 level0_numfiles, 0.000 memtable_compaction, 56.538 leveln_slowdown
      Stalls(count): 160831 level0_slowdown, 0 level0_numfiles, 0 memtable_compaction, 52845 leveln_slowdown
      
      Task ID: #
      
      Blame Rev:
      
      Test Plan:
      run db_bench for --benchmarks=overwrite with IO-bound database
      
      Revert Plan:
      
      Database Impact:
      
      Memcache Impact:
      
      Other Notes:
      
      EImportant:
      
      - begin *PUBLIC* platform impact section -
      Bugzilla: #
      - end platform impact -
      
      Reviewers: haobo
      
      Reviewed By: haobo
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15243
      439e36db
  6. 17 1月, 2014 6 次提交
    • K
      Remove the extra line in "make release" · 23576d77
      Kai Liu 提交于
      Summary:
      
      that line was introduced during merge.
      23576d77
    • N
      Allow callback to change size of existing value. Change return type of the... · 1447bb59
      Naman Gupta 提交于
      Allow callback to change size of existing value. Change return type of the callback function to an enum status to handle 3 cases.
      
      Summary:
      This diff fixes 2 hacks:
      * The callback function can modify the existing value inplace, if the merged value fits within the existing buffer size. But currently the existing buffer size is not being modified. Now the callback recieves a int* allowing the size to be modified. Since size is encoded as a varint in the internal key for memtable. It might happen that the entire value might have be copied to the new location if the new size varint is smaller than the existing size varint.
      * The callback function has 3 functionalities
          1. Modify existing buffer inplace, and update size correspondingly. Now to indicate that, Returns 1.
          2. Generate a new buffer indicating merged value. Returns 2.
          3. Fails to do either of above, based on whatever application logic. Returns 0.
      
      Test Plan: Just make all for now. I'm adding another unit test to test each scenario.
      
      Reviewers: dhruba, haobo
      
      Reviewed By: haobo
      
      CC: leveldb, sdong, kailiu, xinyaohu, sumeet, danguo
      
      Differential Revision: https://reviews.facebook.net/D15195
      1447bb59
    • K
      Merge branch 'master' into performance · d4f65f16
      Kai Liu 提交于
      This patch merges master's changes on build_tools/format-diff.sh.
      Conflicts:
      	db/version_edit.cc
      d4f65f16
    • K
      Fix some "make format" issue · e19bad9b
      Kai Liu 提交于
      Summary:
      * make sure when some pre-check fails, the script won't halt immediately.
      * change fburl to google's short url.
      * Fix a bug in this script: now it checks the uncommitted code only.
      
      Test Plan: Ran the script under differnet environments.
      
      Reviewers: igor
      
      Reviewed By: igor
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15231
      e19bad9b
    • I
      Remove compaction pointers · 6d6fb709
      Igor Canadi 提交于
      Summary: The only thing we do with compaction pointers is set them to some values, we never actually read them. I don't know what we used them for, but it doesn't look like we use them anymore.
      
      Test Plan: make check
      
      Reviewers: dhruba, haobo, kailiu, sdong
      
      Reviewed By: kailiu
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15225
      6d6fb709
    • I
      CompactionPicker · c699c84a
      Igor Canadi 提交于
      Summary:
      This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
      
      To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
      
      In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
      
      This diff depends on D15171, D15183, D15189 and D15201
      
      Test Plan: `make check`
      
      Reviewers: kailiu, sdong, dhruba, haobo
      
      Reviewed By: kailiu
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15207
      c699c84a
  7. 16 1月, 2014 6 次提交
    • K
      Merge branch 'master' into performance · 1304d8c8
      kailiu 提交于
      Conflicts:
      	Makefile
      	db/db_impl.cc
      	db/db_impl.h
      	db/db_test.cc
      	db/memtable.cc
      	db/memtable.h
      	db/version_edit.h
      	db/version_set.cc
      	include/rocksdb/options.h
      	util/hash_skiplist_rep.cc
      	util/options.cc
      1304d8c8
    • K
      Remove the unnecessary use of shared_ptr · eae1804f
      kailiu 提交于
      Summary:
      shared_ptr is slower than unique_ptr (which literally comes with no performance cost compare with raw pointers).
      In memtable and memtable rep, we use shared_ptr when we'd actually should use unique_ptr.
      
      According to igor's previous work, we are likely to make quite some performance gain from this diff.
      
      Test Plan: make check
      
      Reviewers: dhruba, igor, sdong, haobo
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15213
      eae1804f
    • I
      Move more functions from VersionSet to Version · 787f11bb
      Igor Canadi 提交于
      Summary:
      This moves functions:
      * VersionSet::Finalize() -> Version::UpdateCompactionStats()
      * VersionSet::UpdateFilesBySize() -> Version::UpdateFilesBySize()
      
      The diff depends on D15189, D15183 and D15171
      
      Test Plan: make check
      
      Reviewers: kailiu, sdong, haobo, dhruba
      
      Reviewed By: sdong
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15201
      787f11bb
    • I
      Moving Compaction class to separate header file · 615d1ea2
      Igor Canadi 提交于
      Summary:
      I'm sure we'll all agree that version_set.cc needs simplifying. This diff moves Compaction class to a separate file.
      
      The diff depends on D15171 and D15183
      
      Test Plan: make check
      
      Reviewers: dhruba, haobo, kailiu, sdong
      
      Reviewed By: kailiu
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15189
      615d1ea2
    • I
      Move functions from VersionSet to Version · 2f4eda78
      Igor Canadi 提交于
      Summary:
      There were some functions in VersionSet that had no reason to be there instead of Version. Moving them to Version will make column families implementation easier.
      
      The functions moved are:
      * NumLevelBytes
      * LevelSummary
      * LevelFileSummary
      * MaxNextLevelOverlappingBytes
      * AddLiveFiles (previously AddLiveFilesCurrentVersion())
      * NeedSlowdownForNumLevel0Files
      
      The diff continues on (and depends on) D15171
      
      Test Plan: make check
      
      Reviewers: dhruba, haobo, kailiu, sdong, emayanke
      
      Reviewed By: sdong
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15183
      2f4eda78
    • I
      Decrease reliance on VersionSet::NumberLevels() · 65a8a52b
      Igor Canadi 提交于
      Summary:
      With column families VersionSet will not have a constant number of levels (each CF can have different options), so we'll need to eliminate call to VersionSet::NumberLevels()
      
      This diff decreases number of callsites, but we're not there yet. It associates number of levels with Version (each version is associated with single CF) instead of VersionSet.
      
      I have also slightly changed how VersionSet keeps track of manifest size.
      
      This diff also modifies constructor of Compaction such that it takes input_version and automatically Ref()s it. Before this was done outside of constructor.
      
      In next diffs I will continue to decrease number of callsites of VersionSet::NumberLevels() and also references to current_
      
      Test Plan: make check
      
      Reviewers: haobo, dhruba, kailiu, sdong
      
      Reviewed By: sdong
      
      Differential Revision: https://reviews.facebook.net/D15171
      65a8a52b
  8. 15 1月, 2014 10 次提交
    • K
      Optimize MayContainHash() · cd535c22
      Kai Liu 提交于
      Summary:
      In latest leaf's, MayContainHash() consistently consumes 5%~7% CPU usage.
      
      I checked the code and did an experiment with/without inlining this method.
      
      In release mode, with `1024 * 1024 * 256` bits and `1024 * 512` entries, both call 2^30 MayContainHash() with distinctive parameters.
      
      As the result showed, this patch reduced the running time from 9.127 sec to 7.891 sec.
      
      Test Plan: make check
      
      Reviewers: sdong, haobo
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15177
      cd535c22
    • K
      Fix the return type of WriteBatch::Data(). · c8f16221
      kailiu 提交于
      Summary: Quick fix for https://reviews.facebook.net/D15123
      
      Test Plan: Make check
      
      Reviewers: sdong, vkrest
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15165
      c8f16221
    • S
      [RocksDB Performance Branch] DBImpl.NewInternalIterator() to reduce works inside mutex · 9b51af5a
      Siying Dong 提交于
      Summary: To reduce mutex contention caused by DBImpl.NewInternalIterator(), in this function, move all the iteration creation works out of mutex, only leaving object ref and get.
      
      Test Plan:
      make all check
      will run db_stress for a while too to make sure no problem.
      
      Reviewers: haobo, dhruba, kailiu
      
      Reviewed By: haobo
      
      CC: igor, leveldb
      
      Differential Revision: https://reviews.facebook.net/D14589
      
      Conflicts:
      	db/db_impl.cc
      9b51af5a
    • I
      Fix CompactRange to apply filter to every key · d9cd7a06
      Igor Canadi 提交于
      Summary:
      When doing CompactRange(), we should first flush the memtable and then calculate max_level_with_files. Also, we want to compact all the levels that have files, including level `max_level_with_files`.
      
      This patch fixed the unit test.
      
      Test Plan: Added a failing unit test and a fix, so it's not failing anymore.
      
      Reviewers: dhruba, haobo, sdong
      
      Reviewed By: haobo
      
      CC: leveldb, xjin
      
      Differential Revision: https://reviews.facebook.net/D14421
      d9cd7a06
    • I
      1ed2404f
    • I
      Fix test · 62910202
      Igor Canadi 提交于
      62910202
    • I
      Fix memtable construction in tests · 7f3e417f
      Igor Canadi 提交于
      7f3e417f
    • I
      VersionEdit not to take NumLevels() · 055e6df4
      Igor Canadi 提交于
      Summary:
      I will submit a sequence of diffs that are preparing master branch for column families. There are a lot of implicit assumptions in the code that are making column family implementation hard. If I make the change only in column family branch, it will make merging back to master impossible.
      
      Most of the diffs will be simple code refactorings, so I hope we can have fast turnaround time. Feel free to grab me in person to discuss any of them.
      
      This diff removes number of level check from VersionEdit. It is used only when VersionEdit is read, not written, but has to be set when it is written. I believe it is a right thing to make VersionEdit dumb and check consistency on the caller side. This will also make it much easier to implement Column Families, since different column families can have different number of levels.
      
      Test Plan: make check
      
      Reviewers: dhruba, haobo, sdong, kailiu
      
      Reviewed By: kailiu
      
      CC: leveldb
      
      Differential Revision: https://reviews.facebook.net/D15159
      055e6df4
    • I
      BuildBatchGroup -- memcpy outside of lock · 7d9f21cf
      Igor Canadi 提交于
      Summary: When building batch group, don't actually build a new batch since it requires heavy-weight mem copy and malloc. Only store references to the batches and build the batch group without lock held.
      
      Test Plan:
      `make check`
      
      I am also planning to run performance tests. The workload that will benefit from this change is readwhilewriting. I will post the results once I have them.
      
      Reviewers: dhruba, haobo, kailiu
      
      Reviewed By: haobo
      
      CC: leveldb, xjin
      
      Differential Revision: https://reviews.facebook.net/D15063
      7d9f21cf
    • K
      Move the compilation of the shared libraries to "make release" · 481c77e5
      kailiu 提交于
      Compiling the shared libraries took a long time. Thus to speed up the development speed, it still makes sense to be separated from regular compilation.
      481c77e5