Summary:
Noticed in the previous diff that shift is relatively slow for sorted datasources, the reason is that it needs to do a lot of binary searches, and binary search / sorting a full data set is roughly ~20 times slower than resorting a full set, and we're dropping 10% of the data in our test. So if we are shifting too many items in a sorted set, we instead fall back to a rebuild (for non-sorted, shift is super fast because we only drop a bunch of items from the start).
Also solved some more perf related todo's, or made notes about them.
Reviewed By: nikoant
Differential Revision: D26913144
fbshipit-source-id: ee1c04fda1730653affdede0ad22da795e19c2af