Skip to content

Commit

Permalink
avoid crashes, faster varint, fewer dependencies
Browse files Browse the repository at this point in the history
Summary:
wdt could corrupt memory on bad input

re speed:  buck build mode/opt and :
  [19:27 devbig650.prn1:fbcode(sg2)]$ ./buck-out/gen/wdt/test_encdeci64_perf
  ============================================================================
  wdt/test/test_encdeci64_perf.cpp                relative  time/iter  iters/s
  ============================================================================
  BM_encodeDecodeI64(0)                                       10.67ns   93.73M
  BM_encodeDecodeI64(m10k)                                     3.67ns  272.66M
  BM_encodeDecodeI64(10000)                                    3.67ns  272.66M
  BM_encodeDecodeI64(m1k)                                      2.67ns  374.93M
  BM_encodeDecodeI64(1000)                                     2.67ns  374.93M
  BM_encodeDecodeI64(m100)                                     2.67ns  374.93M
  BM_encodeDecodeI64(100)                                      2.77ns  360.85M
  BM_encodeDecodeI64(m10)                                      2.05ns  488.55M
  BM_encodeDecodeI64(10)                                       2.05ns  488.34M
  BM_encodeDecodeI64_vi(0)                                    13.56ns   73.73M
  BM_encodeDecodeI64_vi(m10k)                                  7.33ns  136.34M
  BM_encodeDecodeI64_vi(10000)                                 7.33ns  136.34M
  BM_encodeDecodeI64_vi(m1k)                                   5.00ns  199.97M
  BM_encodeDecodeI64_vi(1000)                                  5.00ns  199.97M
  BM_encodeDecodeI64_vi(m100)                                  5.00ns  199.97M
  BM_encodeDecodeI64_vi(100)                                   5.00ns  199.97M
  BM_encodeDecodeI64_vi(m10)                                   2.38ns  420.09M
  BM_encodeDecodeI64_vi(10)                                    2.38ns  420.53M
  BM_encodeDecodeI64_str(0)                                   44.63ns   22.41M
  BM_encodeDecodeI64_str(m10k)                                18.67ns   53.55M
  BM_encodeDecodeI64_str(10000)                               18.69ns   53.50M
  BM_encodeDecodeI64_str(m1k)                                 16.08ns   62.20M
  BM_encodeDecodeI64_str(1000)                                16.08ns   62.19M
  BM_encodeDecodeI64_str(m100)                                16.08ns   62.20M
  BM_encodeDecodeI64_str(100)                                 16.08ns   62.20M
  BM_encodeDecodeI64_str(m10)                                 13.38ns   74.74M
  BM_encodeDecodeI64_str(10)                                  13.38ns   74.73M
  BM_encodeDecodeI64_vi_str(0)                                31.10ns   32.16M
  BM_encodeDecodeI64_vi_str(m10k)                             22.70ns   44.04M
  BM_encodeDecodeI64_vi_str(10000)                            22.72ns   44.02M
  BM_encodeDecodeI64_vi_str(m1k)                              21.37ns   46.80M
  BM_encodeDecodeI64_vi_str(1000)                             21.37ns   46.79M
  BM_encodeDecodeI64_vi_str(m100)                             21.37ns   46.80M
  BM_encodeDecodeI64_vi_str(100)                              21.35ns   46.84M
  BM_encodeDecodeI64_vi_str(m10)                              20.21ns   49.47M
  BM_encodeDecodeI64_vi_str(10)                               20.09ns   49.78M
  ============================================================================

_vi is the folly varint version, without _vi is the new, faster, more compact one

Reviewed By: uddipta

Differential Revision: D4225139

fbshipit-source-id: d85683fe70416738208883e86a6dd5f6db2d05b2
  • Loading branch information
ldemailly authored and Facebook Github Bot committed Nov 30, 2016
1 parent 5db93b8 commit 86c82a5
Show file tree
Hide file tree
Showing 26 changed files with 1,382 additions and 522 deletions.
4 changes: 2 additions & 2 deletions ByteSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ struct SourceMetaData {
/// relative pathname
std::string relPath;
/**
* sequence number associated with the file. Sequence number
* Sequence number associated with the file. Sequence number
* represents the order in which files were first added to the queue.
* This is a file level identifier. It is same for blocks belonging
* to the same file. This is efficient while using in sets. Instead
* of using full path of the file, we can use this to identify the
* file.
* file. First valid sequence id is 1
*/
int64_t seqId{0};
/// size of the entire source
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cmake_minimum_required(VERSION 3.2)
# There is no C per se in WDT but if you use CXX only here many checks fail
# Version is Major.Minor.YYMMDDX for up to 10 releases per day (X from 0 to 9)
# Minor currently is also the protocol version - has to match with Protocol.cpp
project("WDT" LANGUAGES C CXX VERSION 1.26.1611290)
project("WDT" LANGUAGES C CXX VERSION 1.27.1611290)

# On MacOS this requires the latest (master) CMake (and/or CMake 3.1.1/3.2)
# WDT itself works fine with C++11 (gcc 4.8 for instance) but more recent folly
Expand Down Expand Up @@ -343,6 +343,10 @@ if (BUILD_TESTING)
target_link_libraries(protocol_test wdt4tests)
add_test(NAME AllTestsInProtocolTest COMMAND protocol_test)

add_executable(test_encdeci64_func test/test_encdeci64_func.cpp)
target_link_libraries(test_encdeci64_func wdt4tests)
add_test(NAME test_encdeci64_func COMMAND test_encdeci64_func)

add_executable(resource_controller_test test/WdtResourceControllerTest.cpp)
target_link_libraries(resource_controller_test wdt4tests)
add_test(NAME ResourceControllerTests COMMAND resource_controller_test)
Expand Down
Loading

0 comments on commit 86c82a5

Please sign in to comment.