Clean up RequestContext

Summary: Using a ThreadLocal cleans up the code quite a bit.  Also reuse the shared_ptr in create instead of creating a new one saves an allocation

Test Plan:
fbconfig thrift/lib/cpp/test:RequestContextTest; fbmake runtests

fbconfig common/services/cpp/test:trace_test; fbmake runtests

Reviewed By: hans@fb.com

Subscribers: trunkagent, doug, alandau, bmatheny, njormrod, mshneer, folly-diffs@, vloh

FB internal diff: D1663960

Signature: t1:1663960:1415390250:36d9b772016d2a12d804e98edbc1725af882e507
Add 'none' to the list of Thrift reserved keywords

Summary: None will break Python thrift clients since it is a reserved python keyword.

Test Plan: Build the thrift compiler package.

Reviewed By: haijunz@fb.com

Subscribers: alandau, mshneer

FB internal diff: D1670315

Tasks: 5570728

Signature: t1:1670315:1415649587:67803439f4b1a99b9218f95ecc942c8ce5cc1e16
Reverting the none addition as it caused some problems

Summary: tsia

Test Plan: reverting an added reserved keyword.

Reviewed By: mhx@fb.com

Subscribers: alandau, mshneer

FB internal diff: D1670472

Tasks: 5570728

Signature: t1:1670472:1415651322:088c40c9f7f03b2aeefe7080882e4c94698a8667
Add ProtoBuf benchmarks

Summary:
The benchmarks are the same as used for Thrift, except without
binary, since protobuf lacks this type.

Test Plan:
```
---- Thrift ------    -- ProtoBufs ---   PB faster by
Benchmark                time/iter   iters/s  time/iter  iters/s
==========================================================================
write_Empty               123.64ns    8.09M    26.35ns   37.95M    369.10%
read_Empty                 58.92ns   16.97M    30.65ns   32.63M     92.28%
write_SmallInt            146.19ns    6.84M    40.35ns   24.78M    262.28%
read_SmallInt              78.38ns   12.76M    29.05ns   34.42M    169.75%
write_BigInt              187.36ns    5.34M    50.04ns   19.98M    274.16%
read_BigInt               125.69ns    7.96M    39.35ns   25.41M    219.22%
write_SmallString         158.55ns    6.31M    57.82ns   17.30M    174.17%
read_SmallString          109.20ns    9.16M    85.85ns   11.65M     27.18%
write_BigString           399.54ns    2.50M   550.63ns    1.82M    -27.20%
read_BigString            394.01ns    2.54M   597.21ns    1.67M    -34.25%
write_BigBinary           314.72ns    3.18M
read_BigBinary            223.87ns    4.47M
write_LargeBinary         326.30ns    3.06M
read_LargeBinary          242.07ns    4.13M
write_Mixed               213.45ns    4.69M    67.70ns   14.77M    214.93%
read_Mixed                175.83ns    5.69M   103.90ns    9.63M     69.24%
write_SmallListInt        235.80ns    4.24M    77.20ns   12.95M    205.42%
read_SmallListInt         252.46ns    3.96M   210.33ns    4.75M     19.95%
write_BigListInt          100.26us    9.97K    21.02us   47.58K    377.23%
read_BigListInt           121.96us    8.20K    37.66us   26.55K    223.78%
write_BigListMixed          1.01ms   986.15   363.60us    2.75K    178.86%
read_BigListMixed           1.54ms   649.58     2.37ms   422.59    -34.94%
write_LargeListMixed      114.58ms     8.73    44.60ms    22.42    156.82%
read_LargeListMixed       168.85ms     5.92   251.53ms     3.98    -32.77%
```

Reviewed By: davejwatson@fb.com

Subscribers: alandau, bmatheny, mshneer

FB internal diff: D1666012

Signature: t1:1666012:1415732917:c71938a4f24f522e67ec5beb9d8140500b7bc9b8
Fix -Wconversion

Summary: This snuck in and broke proxygen.

Test Plan: unit tests, compiled

Reviewed By: alandau@fb.com

Subscribers: doug, alandau, bmatheny, mshneer

FB internal diff: D1673339

Signature: t1:1673339:1415734229:009bbbab166d34ebe76e671ca20e8a2bfe149dda
Improve compact protocol deserialization speed

Summary:
Use a simple stack that allocates its storage inline rather
than on the heap. The stack depth equals the number of nested structs,
so a limit of 10 seems more than enough for normal uses cases.
If the depth turns out to be more than that, we fall back to a
heap-allocated stack like before

Test Plan:
```
------ old ------   ------ new ------
Benchmark                                time/iter  iters/s  time/iter  iters/s        win
==========================================================================================
CompactProtocol_read_Empty                 56.56ns   17.68M    22.82ns   43.82M    147.85%
CompactProtocol_read_SmallInt              86.75ns   11.53M    50.71ns   19.72M     71.03%
CompactProtocol_read_BigInt               128.16ns    7.80M    90.37ns   11.07M     41.92%
CompactProtocol_read_SmallString          109.09ns    9.17M    70.06ns   14.27M     55.62%
CompactProtocol_read_BigString            400.68ns    2.50M   349.50ns    2.86M     14.40%
CompactProtocol_read_BigBinary            223.61ns    4.47M   189.33ns    5.28M     18.12%
CompactProtocol_read_LargeBinary          232.81ns    4.30M   200.81ns    4.98M     15.81%
CompactProtocol_read_Mixed                195.15ns    5.12M   149.65ns    6.68M     30.47%
CompactProtocol_read_SmallListInt         251.84ns    3.97M   212.23ns    4.71M     18.64%
CompactProtocol_read_BigListInt           124.96us    8.00K   121.98us    8.20K      2.50%
CompactProtocol_read_BigListMixed           1.74ms   575.23     1.75ms   572.51     -0.47%
CompactProtocol_read_LargeListMixed       189.45ms     5.28   185.30ms     5.40      2.27%
```

Reviewed By: andrewcox@fb.com

Subscribers: trunkagent, alandau, bmatheny, mshneer

FB internal diff: D1672045

Signature: t1:1672045:1415746718:5139e3ad2d3b0052d02b2014bbef86f5f7818a1e
CompactReader: more optimizations

Summary:
* Don't clear a string that is already empty
* Use table lookup in getType rather than a big switch

Test Plan:
```
------ old ------   ------ new ------
Benchmark                               time/iter  iters/s  time/iter  iters/s        win
=========================================================================================
CompactProtocol_read_Empty                20.55ns   48.67M    16.57ns   60.34M     23.98%
CompactProtocol_read_SmallInt             49.47ns   20.21M    42.84ns   23.34M     15.49%
CompactProtocol_read_BigInt               87.21ns   11.47M    83.49ns   11.98M      4.45%
CompactProtocol_read_SmallString          68.99ns   14.50M    67.27ns   14.87M      2.55%
CompactProtocol_read_BigString           347.67ns    2.88M   355.39ns    2.81M     -2.43%
CompactProtocol_read_BigBinary           185.91ns    5.38M   186.96ns    5.35M     -0.56%
CompactProtocol_read_LargeBinary         195.75ns    5.11M   196.12ns    5.10M     -0.20%
CompactProtocol_read_Mixed               150.37ns    6.65M   134.94ns    7.41M     11.43%
CompactProtocol_read_SmallListInt        215.48ns    4.64M   201.02ns    4.97M      7.11%
CompactProtocol_read_BigListInt          120.95us    8.27K   119.33us    8.38K      1.33%
CompactProtocol_read_BigListMixed          1.73ms   578.73     1.60ms   624.87      7.97%
CompactProtocol_read_LargeListMixed      188.31ms     5.31   174.52ms     5.73      7.91%
```

Reviewed By: haijunz@fb.com

Subscribers: trunkagent, alandau, bmatheny, mshneer

FB internal diff: D1675143

Signature: t1:1675143:1415828266:54f21c9eaef8b48ed2b40e503ea975cd70fc27dd
Refactor some tests to use gtest

Summary: This is a prerequisite to move these to folly eventually.

Test Plan: ran the tests

Reviewed By: haijunz@fb.com

Subscribers: trunkagent, doug, alandau, bmatheny, mshneer

FB internal diff: D1677852

Tasks: 5485692

Signature: t1:1677852:1415904378:829620e981848d0359278c53d71b25f7e668cc3d
Thrift/Python3 Python2 Like Behavior

Summary:
Python3 should always decode strings and leave binary as bytes.
This will unifi the behavior across python2/3 for various thrift services
like (SMC)

I included the Binary type hint in the thrift_spec for strings and updated
fastbinary and fastproto to handle this encoding hint

For python3 utf8strings is always on, in python2 utf8strings means you will get unicode objects

Test Plan:
Python3 SMC Thrift Client returned unicode strings instead of bytes,
allowing for the various get_prop helpers to work

Ran unittest for fastproto, not much but it does touch a map with string keys

Inspected generated ttypes.py

Reviewed By: haijunz@fb.com

Subscribers: trunkagent, ruibalp, alandau, bmatheny, mshneer

FB internal diff: D1679712

Signature: t1:1679712:1415913526:87e8338ce0147bc7ab182c5338a0681855b858ce
CompactProtocol: more improvements

Summary:
Add a specialized Cursor method that reads exactly 1 byte, in
addition to the existing one that reads into a buffer. Use it when
reading varints and standalone bytes in a CompactProtocol struct.

Test Plan:
```
------ old ------   ------ new ------
Benchmark                               time/iter  iters/s  time/iter  iters/s        win
=========================================================================================
CompactProtocol_read_Empty                18.68ns   53.54M    13.21ns   75.69M     41.37%
CompactProtocol_read_SmallInt             42.60ns   23.47M    29.95ns   33.39M     42.27%
CompactProtocol_read_BigInt               83.62ns   11.96M    68.40ns   14.62M     22.24%
CompactProtocol_read_SmallString          67.33ns   14.85M    55.62ns   17.98M     21.08%
CompactProtocol_read_BigString           353.83ns    2.83M   330.19ns    3.03M      7.07%
CompactProtocol_read_BigBinary           190.82ns    5.24M   182.90ns    5.47M      4.39%
CompactProtocol_read_LargeBinary         200.95ns    4.98M   187.00ns    5.35M      7.43%
CompactProtocol_read_Mixed               137.42ns    7.28M   102.98ns    9.71M     33.38%
CompactProtocol_read_SmallListInt        203.98ns    4.90M   146.68ns    6.82M     39.18%
CompactProtocol_read_BigListInt          120.50us    8.30K    71.56us   13.97K     68.31%
CompactProtocol_read_BigListMixed          1.62ms   617.07     1.26ms   795.60     28.93%
CompactProtocol_read_LargeListMixed      177.50ms     5.63   140.73ms     7.11     26.29%
```

Reviewed By: haijunz@fb.com

Subscribers: trunkagent, alandau, bmatheny, njormrod, mshneer, folly-diffs@

FB internal diff: D1678077

Signature: t1:1678077:1415923409:22accee6b62b6e2bf471f3758a290f71978a8c4e
Thrift Python Unittests to support new string/bytes behavior

Summary:
JSON in py3 hates bytes
Fix up TApplication so it tries to decode messages so they are not bytes
Remove the decode from the testserver since its already decoded

Test Plan: runtests, they are timing out but I have fixed quite a few

Reviewed By: haijunz@fb.com

Subscribers: configerator-diffs@, trunkagent, ruibalp, alandau, bmatheny, mshneer

FB internal diff: D1681065

Signature: t1:1681065:1415990606:5941ddb3a480edd28e9b2cff576b5abdcaf956be
CompactProtocol: readVarint optimizations

Summary:
* Unroll readVarint() - no loops in the fast path
* Split Cursor::skip() into fast and slow paths

Test Plan:
```
------ old ------   ------ new ------
Benchmark                               time/iter  iters/s  time/iter  iters/s        win
=========================================================================================
CompactProtocol_read_Empty                13.21ns   75.69M    13.21ns   75.71M      0.03%
CompactProtocol_read_SmallInt             29.95ns   33.39M    28.96ns   34.53M      3.41%
CompactProtocol_read_BigInt               67.83ns   14.74M    36.77ns   27.19M     84.46%
CompactProtocol_read_SmallString          55.72ns   17.95M    54.04ns   18.50M      3.06%
CompactProtocol_read_BigString           342.93ns    2.92M   332.18ns    3.01M      3.08%
CompactProtocol_read_BigBinary           186.18ns    5.37M   181.45ns    5.51M      2.61%
CompactProtocol_read_LargeBinary         190.65ns    5.25M   184.85ns    5.41M      3.05%
CompactProtocol_read_Mixed               101.97ns    9.81M    97.06ns   10.30M      4.99%
CompactProtocol_read_SmallListInt        148.09ns    6.75M   139.52ns    7.17M      6.22%
CompactProtocol_read_BigListInt           71.69us   13.95K    63.34us   15.79K     13.19%
CompactProtocol_read_BigListMixed          1.26ms   790.67     1.18ms   845.66      6.95%
CompactProtocol_read_LargeListMixed      139.80ms     7.15   134.68ms     7.42      3.78%
```

Reviewed By: davejwatson@fb.com

Subscribers: trunkagent, alandau, bmatheny, njormrod, mshneer, folly-diffs@

FB internal diff: D1681244

Signature: t1:1681244:1416265579:f630c53f9c31788f847d0af72198bbd9e5ea43f1
Move some tests to folly

Summary:
These lived in fbthrift previously, but they should move with the
main code too.

Test Plan: unit tests

Reviewed By: davejwatson@fb.com

Subscribers: doug, alandau, bmatheny, njormrod, mshneer, folly-diffs@

FB internal diff: D1683229

Signature: t1:1683229:1416010730:36fb7e4c9916ae7a9b5972cd476f82014c5f4c78
handle nulls in SimpleJSONProtocol

Summary:
In a struct serialization like `{"foo": 5, "bar": null}`, we should treat that the same as if the bar member wasn't declared at all (`{"foo": 5}`).

To do this, we peek ahead after reading a field, and see if the value is null.  If it is, we skip over it and read the next field.

Test Plan: g-unittest

Reviewed By: haijunz@fb.com

Subscribers: trunkagent, alandau, bmatheny, mshneer

FB internal diff: D1674617

Signature: t1:1674617:1416332891:bdbc6d04731a6d66de537a60b5a24667878d49d0
overload PriorityThreadManager::getCodel() to accept a PRIORITY

Summary: Get the Codel from the ThreadManager for the specified priority.

Test Plan: Retrieved load for HIGH priority Codel.

Reviewed By: hitesh@fb.com, davejwatson@fb.com

Subscribers: fugalh, alandau, bmatheny, jaredg, mshneer, yguo

FB internal diff: D1688484

Signature: t1:1688484:1416343122:f96eda559f090cd4e91cdea88624d8e27c8d9910
Fix TFileTransportTest

Summary: Missed this in earlier refactors

Test Plan: compile thrift

Reviewed By: woo@fb.com

Subscribers: doug, alandau, bmatheny, mshneer

FB internal diff: D1689840

Signature: t1:1689840:1416362549:d5b628f65a4326c12cbcf40776e62dafbbf71655
CompactProtocol: More int optimizations

Summary:
* Split readVarint into fast, medium and slow path (was fast and slow)
* Inline zigzagToI32/64

Test Plan:
```
------ old ------   ------ new ------
Benchmark                               time/iter  iters/s  time/iter  iters/s        win
=========================================================================================
CompactProtocol_read_Empty                13.21ns   75.71M    13.01ns   76.87M      1.53%
CompactProtocol_read_SmallInt             29.03ns   34.45M    28.13ns   35.55M      3.19%
CompactProtocol_read_BigInt               36.52ns   27.38M    36.17ns   27.65M      0.99%
CompactProtocol_read_SmallString          53.98ns   18.53M    53.56ns   18.67M      0.76%
CompactProtocol_read_BigString           358.11ns    2.79M   332.29ns    3.01M      7.89%
CompactProtocol_read_BigBinary           180.04ns    5.55M   183.32ns    5.45M     -1.80%
CompactProtocol_read_LargeBinary         183.22ns    5.46M   183.14ns    5.46M      0.00%
CompactProtocol_read_Mixed                95.16ns   10.51M    94.56ns   10.58M      0.67%
CompactProtocol_read_SmallListInt        139.39ns    7.17M   122.58ns    8.16M     13.81%
CompactProtocol_read_BigListInt           63.66us   15.71K    46.09us   21.70K     38.13%
CompactProtocol_read_BigListMixed          1.19ms   841.92     1.20ms   832.66     -1.10%
CompactProtocol_read_LargeListMixed      133.46ms     7.49   133.00ms     7.52      0.40%
```

Reviewed By: andrewcox@fb.com

Subscribers: trunkagent, alandau, bmatheny, mshneer

FB internal diff: D1687167

Signature: t1:1687167:1416364134:155d0651e9a24aead54ee4f6712a46cfed5a38f3
Bump version to 14:0