Commit Graph

10189 Commits

Author SHA1 Message Date
Jun Wu
7341c4af7e commandserver: clear progress explicitly before os._exit
Summary:
`os._exit` bypasses all clean-up logic, including `IO::drop` in `hgmain` which
cleans up the progress bars. So let's explicitly clean up the progress bars
before `os._exit`.

Reviewed By: kulshrax

Differential Revision: D27744944

fbshipit-source-id: 5cd50b283728fd4e3b559142f7f61fc6672492e9
2021-04-13 12:35:13 -07:00
Jun Wu
4974d08e92 revisionstore: avoid copying slice in indexedlogdatastore
Summary:
I encountered crashes like `memory allocation of 999401 bytes failed` when
checking out commits on Windows. I almost cannot checkout anything.

Looking at the minidumps, the problem is that indexedlogdatastore tries
to copy the slice (copy_from_slice).

That's suboptimal, since indexedlog can provide zero-copy slice access
for on-disk entries. Use zero-copy APIs instead.

Minidump trace:

    [Inline Frame] hg.real.exe!std::sys::windows::abort_internal() Line 261	Unknown
    [Inline Frame] hg.real.exe!std::process::abort() Line 1784	Unknown
    hg.real.exe!std::alloc::rust_oom() Line 330	Unknown
    hg.real.exe!alloc::alloc::__alloc_error_handler::__rg_oom() Line 397	Unknown
    hg.real.exe!alloc::alloc::handle_alloc_error() Line 366	Unknown
    [Inline Frame] hg.real.exe!alloc::raw_vec::RawVec<u8, alloc::alloc::Global>::allocate_in(unsigned __int64 capacity, alloc::raw_vec::AllocInit init, alloc::alloc::Global) Line 193	Unknown
    [Inline Frame] hg.real.exe!alloc::raw_vec::RawVec<u8, alloc::alloc::Global>::with_capacity_in(unsigned __int64 capacity, alloc::alloc::Global) Line 129	Unknown
    [Inline Frame] hg.real.exe!alloc::vec::Vec<u8, alloc::alloc::Global>::with_capacity_in(unsigned __int64 capacity, alloc::alloc::Global) Line 498	Unknown
    [Inline Frame] hg.real.exe!alloc::slice::hack::{{impl}}::to_vec(slice<u8> s, alloc::alloc::Global) Line 207	Unknown
    [Inline Frame] hg.real.exe!alloc::slice::hack::to_vec(slice<u8> s, alloc::alloc::Global) Line 159	Unknown
    [Inline Frame] hg.real.exe!alloc::slice::{{impl}}::to_vec_in(slice<u8> self, alloc::alloc::Global) Line 472	Unknown
    [Inline Frame] hg.real.exe!alloc::slice::{{impl}}::to_vec(slice<u8> self) Line 449	Unknown
    [Inline Frame] hg.real.exe!minibytes::bytes::{{impl}}::to_owned(slice<u8> self) Line 231	Unknown
    [Inline Frame] hg.real.exe!minibytes::bytes::AbstractBytes<slice<u8>>::copy_from_slice(slice<u8> data) Line 152	Unknown
    hg.real.exe!revisionstore::indexedlogdatastore::Entry::from_slice(slice<u8> data) Line 120	Unknown
    hg.real.exe!revisionstore::indexedlogdatastore::Entry::from_log(revisionstore::indexedlogutil::Store * key) Line 133	Unknown
    [Inline Frame] hg.real.exe!revisionstore::indexedlogdatastore::{{impl}}::get_missing::{{closure}}(revisionstore::indexedlogdatastore::{{impl}}::get_missing::closure-0 *) Line 359	Unknown
    [Inline Frame] hg.real.exe!core::ops::function::impls::{{impl}}::call_mut(revisionstore::indexedlogdatastore::{{impl}}::get_missing::closure-0 * * self, revisionstore::types::StoreKey * * args) Line 269	Unknown
    [Inline Frame] hg.real.exe!core::slice::iter::{{impl}}::find(core::slice::iter::Iter<revisionstore::types::StoreKey> * self, revisionstore::indexedlogdatastore::{{impl}}::get_missing::closure-0 * predicate) Line 251	Unknown
    [Inline Frame] hg.real.exe!core::iter::adapters::filter::{{impl}}::next(core::iter::adapters::filter::Filter<core::slice::iter::Iter<revisionstore::types::StoreKey>, closure-0> * self) Line 55	Unknown
    [Inline Frame] hg.real.exe!core::iter::adapters::cloned::{{impl}}::next(core::iter::adapters::cloned::Cloned<core::iter::adapters::filter::Filter<core::slice::iter::Iter<revisionstore::types::StoreKey>, closure-0>> * self) Line 38	Unknown
    [Inline Frame] hg.real.exe!alloc::vec::Vec<revisionstore::types::StoreKey, alloc::alloc::Global>::extend_desugared(core::iter::adapters::cloned::Cloned<core::iter::adapters::filter::Filter<core::slice::iter::Iter<revisionstore::types::StoreKey>, closure-0>> self) Line 2621	Unknown
    [Inline Frame] hg.real.exe!alloc::vec::{{impl}}::spec_extend(alloc::vec::Vec<revisionstore::types::StoreKey, alloc::alloc::Global> * self, core::iter::adapters::cloned::Cloned<core::iter::adapters::filter::Filter<core::slice::iter::Iter<revisionstore::types::StoreKey>, closure-0>>) Line 2544	Unknown
    [Inline Frame] hg.real.exe!alloc::vec::{{impl}}::from_iter(core::iter::adapters::cloned::Cloned<core::iter::adapters::filter::Filter<core::slice::iter::Iter<revisionstore::types::StoreKey>, closure-0>> iterator) Line 2320	Unknown
    hg.real.exe!alloc::vec::{{impl}}::from_iter<revisionstore::types::StoreKey,core::iter::adapters::cloned::Cloned<core::iter::adapters::filter::Filter<core::slice::iter::Iter<revisionstore::types::StoreKey>, closure-0>>>(core::iter::adapters::cloned::Cloned<core::iter::adapters::filter::Filter<core::slice::iter::Iter<revisionstore::types::StoreKey>, closure-0>> iterator) Line 2346	Unknown
    [Inline Frame] hg.real.exe!alloc::vec::{{impl}}::from_iter(core::iter::adapters::cloned::Cloned<core::iter::adapters::filter::Filter<core::slice::iter::Iter<revisionstore::types::StoreKey>, closure-0>>) Line 2181	Unknown
    [Inline Frame] hg.real.exe!core::iter::traits::iterator::Iterator::collect(core::iter::adapters::cloned::Cloned<core::iter::adapters::filter::Filter<core::slice::iter::Iter<revisionstore::types::StoreKey>, closure-0>> self) Line 1670	Unknown
    hg.real.exe!revisionstore::indexedlogdatastore::{{impl}}::get_missing(revisionstore::indexedlogdatastore::IndexedLogHgIdDataStore * self, slice<revisionstore::types::StoreKey> keys) Line 356	Unknown
    [Inline Frame] hg.real.exe!revisionstore::localstore::{{impl}}::get_missing(alloc::sync::Arc<HgIdDataStore> * self, slice<revisionstore::types::StoreKey> keys) Line 46	Unknown
    [Inline Frame] hg.real.exe!revisionstore::unionstore::{{impl}}::get_missing::{{closure}}(revisionstore::unionstore::{{impl}}::get_missing::closure-0 *, core::result::Result<alloc::vec::Vec<revisionstore::types::StoreKey, alloc::alloc::Global>, anyhow::Error> store, alloc::sync::Arc<HgIdDataStore> *) Line 37	Unknown
    [Inline Frame] hg.real.exe!core::iter::traits::iterator::Iterator::fold(core::slice::iter::Iter<alloc::sync::Arc<HgIdDataStore>> self, core::result::Result<alloc::vec::Vec<revisionstore::types::StoreKey, alloc::alloc::Global>, anyhow::Error>) Line 2023	Unknown
    hg.real.exe!revisionstore::unionstore::{{impl}}::get_missing<alloc::sync::Arc<HgIdDataStore>>(revisionstore::unionstore::UnionStore<alloc::sync::Arc<HgIdDataStore>> * self, slice<revisionstore::types::StoreKey> keys) Line 35	Unknown
    [Inline Frame] hg.real.exe!revisionstore::contentstore::{{impl}}::get_missing::{{closure}}(revisionstore::contentstore::{{impl}}::get_missing::closure-0) Line 200	Unknown
    [Inline Frame] hg.real.exe!tracing::span::Span::in_scope(revisionstore::contentstore::{{impl}}::get_missing::closure-0 self) Line 800	Unknown
    hg.real.exe!revisionstore::contentstore::{{impl}}::get_missing(revisionstore::contentstore::ContentStore * self, slice<revisionstore::types::StoreKey> keys) Line 200	Unknown
    hg.real.exe!revisionstore::contentstore::{{impl}}::prefetch(revisionstore::contentstore::ContentStore * self, slice<revisionstore::types::StoreKey> keys) Line 176	Unknown
    [Inline Frame] hg.real.exe!revisionstore::datastore::{{impl}}::prefetch(alloc::sync::Arc<revisionstore::contentstore::ContentStore> * self, slice<revisionstore::types::StoreKey> keys) Line 139	Unknown
    [Inline Frame] hg.real.exe!pyrevisionstore::datastorepyext::{{impl}}::prefetch_py::{{closure}}(pyrevisionstore::datastorepyext::{{impl}}::prefetch_py::closure-1) Line 297	Unknown
    [Inline Frame] hg.real.exe!cpython::python::Python::allow_threads(cpython::python::Python f, pyrevisionstore::datastorepyext::{{impl}}::prefetch_py::closure-1) Line 249	Unknown
    hg.real.exe!pyrevisionstore::datastorepyext::{{impl}}::prefetch_py<alloc::sync::Arc<revisionstore::contentstore::ContentStore>>(alloc::sync::Arc<revisionstore::contentstore::ContentStore> * self, cpython::python::Python py, cpython::objects::list::PyList keys) Line 297	Unknown
    hg.real.exe!pyrevisionstore::{{impl}}::create_instance::init::wrap_instance_method::{{closure}}(pyrevisionstore::{{impl}}::create_instance::init::wrap_instance_method::closure-0) Line 99	Unknown
    [Inline Frame] hg.real.exe!cpython::function::handle_callback::{{closure}}(cpython::function::handle_callback::closure-0) Line 218	Unknown
    [Inline Frame] hg.real.exe!std::panicking::try::do_call(unsigned char * data) Line 379	Unknown
    hg.real.exe!std::panicking::try<mut python27_sys::object::PyObject*,closure-0>(cpython::function::handle_callback::closure-0 f) Line 343	Unknown
    [Inline Frame] hg.real.exe!std::panic::catch_unwind(cpython::function::handle_callback::closure-0) Line 396	Unknown
    hg.real.exe!cpython::function::handle_callback<closure-0,cpython::objects::object::PyObject,cpython::function::PyObjectCallbackConverter>(str _location, cpython::function::PyObjectCallbackConverter f, pyrevisionstore::{{impl}}::create_instance::init::wrap_instance_method::closure-0) Line 227	Unknown
    hg.real.exe!pyrevisionstore::{{impl}}::create_instance::init::wrap_instance_method(python27_sys::object::PyObject * slf, python27_sys::object::PyObject * args, python27_sys::object::PyObject * kwargs) Line 103	Unknown
    [External Code]
    [Inline Frame] hg.real.exe!cpython::objectprotocol::ObjectProtocol::call::{{closure}}(cpython::objectprotocol::ObjectProtocol::call::closure-0 args, python27_sys::object::PyObject *) Line 218	Unknown
    [Inline Frame] hg.real.exe!cpython::objects::tuple::{{impl}}::with_borrowed_ptr(cpython::objects::tuple::PyTuple * self, cpython::python::Python f, cpython::objectprotocol::ObjectProtocol::call::closure-0) Line 177	Unknown
    [Inline Frame] hg.real.exe!cpython::conversion::{{impl}}::with_borrowed_ptr(cpython::objects::tuple::PyTuple * * f, cpython::python::Python) Line 193	Unknown
    [Inline Frame] hg.real.exe!cpython::objectprotocol::ObjectProtocol::call(cpython::objects::object::PyObject * self, cpython::python::Python args, cpython::objects::tuple::PyTuple * kwargs, core::option::Option<cpython::objects::dict::PyDict*>) Line 217	Unknown
    hg.real.exe!pytracing::wrapfunc::__call__(cpython::python::Python args, cpython::objects::tuple::PyTuple * kwargs, core::option::Option<cpython::objects::dict::PyDict*>) Line 319	Unknown
    hg.real.exe!pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::{{closure}}(pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::closure-0) Line 685	Unknown
    [Inline Frame] hg.real.exe!cpython::function::handle_callback::{{closure}}(cpython::function::handle_callback::closure-0) Line 218	Unknown
    [Inline Frame] hg.real.exe!std::panicking::try::do_call(unsigned char * data) Line 379	Unknown
    hg.real.exe!std::panicking::try<mut python27_sys::object::PyObject*,closure-0>(cpython::function::handle_callback::closure-0 f) Line 343	Unknown
    [Inline Frame] hg.real.exe!std::panic::catch_unwind(cpython::function::handle_callback::closure-0) Line 396	Unknown
    hg.real.exe!cpython::function::handle_callback<closure-0,cpython::objects::object::PyObject,cpython::function::PyObjectCallbackConverter>(str _location, cpython::function::PyObjectCallbackConverter f, pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::closure-0) Line 227	Unknown
    hg.real.exe!pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call(python27_sys::object::PyObject * slf, python27_sys::object::PyObject * args, python27_sys::object::PyObject * kwargs) Line 689	Unknown
    [External Code]
    [Inline Frame] hg.real.exe!cpython::objectprotocol::ObjectProtocol::call::{{closure}}(cpython::objectprotocol::ObjectProtocol::call::closure-0 args, python27_sys::object::PyObject *) Line 218	Unknown
    [Inline Frame] hg.real.exe!cpython::objects::tuple::{{impl}}::with_borrowed_ptr(cpython::objects::tuple::PyTuple * self, cpython::python::Python f, cpython::objectprotocol::ObjectProtocol::call::closure-0) Line 177	Unknown
    [Inline Frame] hg.real.exe!cpython::conversion::{{impl}}::with_borrowed_ptr(cpython::objects::tuple::PyTuple * * f, cpython::python::Python) Line 193	Unknown
    [Inline Frame] hg.real.exe!cpython::objectprotocol::ObjectProtocol::call(cpython::objects::object::PyObject * self, cpython::python::Python args, cpython::objects::tuple::PyTuple * kwargs, core::option::Option<cpython::objects::dict::PyDict*>) Line 217	Unknown
    hg.real.exe!pytracing::wrapfunc::__call__(cpython::python::Python args, cpython::objects::tuple::PyTuple * kwargs, core::option::Option<cpython::objects::dict::PyDict*>) Line 319	Unknown
    hg.real.exe!pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::{{closure}}(pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::closure-0) Line 685	Unknown
    [Inline Frame] hg.real.exe!cpython::function::handle_callback::{{closure}}(cpython::function::handle_callback::closure-0) Line 218	Unknown
    [Inline Frame] hg.real.exe!std::panicking::try::do_call(unsigned char * data) Line 379	Unknown
    hg.real.exe!std::panicking::try<mut python27_sys::object::PyObject*,closure-0>(cpython::function::handle_callback::closure-0 f) Line 343	Unknown
    [Inline Frame] hg.real.exe!std::panic::catch_unwind(cpython::function::handle_callback::closure-0) Line 396	Unknown
    hg.real.exe!cpython::function::handle_callback<closure-0,cpython::objects::object::PyObject,cpython::function::PyObjectCallbackConverter>(str _location, cpython::function::PyObjectCallbackConverter f, pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::closure-0) Line 227	Unknown
    hg.real.exe!pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call(python27_sys::object::PyObject * slf, python27_sys::object::PyObject * args, python27_sys::object::PyObject * kwargs) Line 689	Unknown
    [External Code]
    [Inline Frame] hg.real.exe!cpython::objectprotocol::ObjectProtocol::call::{{closure}}(cpython::objectprotocol::ObjectProtocol::call::closure-0 args, python27_sys::object::PyObject *) Line 218	Unknown
    [Inline Frame] hg.real.exe!cpython::objects::tuple::{{impl}}::with_borrowed_ptr(cpython::objects::tuple::PyTuple * self, cpython::python::Python f, cpython::objectprotocol::ObjectProtocol::call::closure-0) Line 177	Unknown
    [Inline Frame] hg.real.exe!cpython::conversion::{{impl}}::with_borrowed_ptr(cpython::objects::tuple::PyTuple * * f, cpython::python::Python) Line 193	Unknown
    [Inline Frame] hg.real.exe!cpython::objectprotocol::ObjectProtocol::call(cpython::objects::object::PyObject * self, cpython::python::Python args, cpython::objects::tuple::PyTuple * kwargs, core::option::Option<cpython::objects::dict::PyDict*>) Line 217	Unknown
    hg.real.exe!pytracing::wrapfunc::__call__(cpython::python::Python args, cpython::objects::tuple::PyTuple * kwargs, core::option::Option<cpython::objects::dict::PyDict*>) Line 319	Unknown
    hg.real.exe!pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::{{closure}}(pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::closure-0) Line 685	Unknown
    [Inline Frame] hg.real.exe!cpython::function::handle_callback::{{closure}}(cpython::function::handle_callback::closure-0) Line 218	Unknown
    [Inline Frame] hg.real.exe!std::panicking::try::do_call(unsigned char * data) Line 379	Unknown
    hg.real.exe!std::panicking::try<mut python27_sys::object::PyObject*,closure-0>(cpython::function::handle_callback::closure-0 f) Line 343	Unknown
    [Inline Frame] hg.real.exe!std::panic::catch_unwind(cpython::function::handle_callback::closure-0) Line 396	Unknown
    hg.real.exe!cpython::function::handle_callback<closure-0,cpython::objects::object::PyObject,cpython::function::PyObjectCallbackConverter>(str _location, cpython::function::PyObjectCallbackConverter f, pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::closure-0) Line 227	Unknown
    hg.real.exe!pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call(python27_sys::object::PyObject * slf, python27_sys::object::PyObject * args, python27_sys::object::PyObject * kwargs) Line 689	Unknown
    [External Code]
    [Inline Frame] hg.real.exe!cpython::objectprotocol::ObjectProtocol::call::{{closure}}(cpython::objectprotocol::ObjectProtocol::call::closure-0 args, python27_sys::object::PyObject *) Line 218	Unknown
    [Inline Frame] hg.real.exe!cpython::objects::tuple::{{impl}}::with_borrowed_ptr(cpython::objects::tuple::PyTuple * self, cpython::python::Python f, cpython::objectprotocol::ObjectProtocol::call::closure-0) Line 177	Unknown
    [Inline Frame] hg.real.exe!cpython::conversion::{{impl}}::with_borrowed_ptr(cpython::objects::tuple::PyTuple * * f, cpython::python::Python) Line 193	Unknown
    [Inline Frame] hg.real.exe!cpython::objectprotocol::ObjectProtocol::call(cpython::objects::object::PyObject * self, cpython::python::Python args, cpython::objects::tuple::PyTuple * kwargs, core::option::Option<cpython::objects::dict::PyDict*>) Line 217	Unknown
    hg.real.exe!pytracing::wrapfunc::__call__(cpython::python::Python args, cpython::objects::tuple::PyTuple * kwargs, core::option::Option<cpython::objects::dict::PyDict*>) Line 319	Unknown
    hg.real.exe!pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::{{closure}}(pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::closure-0) Line 685	Unknown
    [Inline Frame] hg.real.exe!cpython::function::handle_callback::{{closure}}(cpython::function::handle_callback::closure-0) Line 218	Unknown
    [Inline Frame] hg.real.exe!std::panicking::try::do_call(unsigned char * data) Line 379	Unknown
    hg.real.exe!std::panicking::try<mut python27_sys::object::PyObject*,closure-0>(cpython::function::handle_callback::closure-0 f) Line 343	Unknown
    [Inline Frame] hg.real.exe!std::panic::catch_unwind(cpython::function::handle_callback::closure-0) Line 396	Unknown
    hg.real.exe!cpython::function::handle_callback<closure-0,cpython::objects::object::PyObject,cpython::function::PyObjectCallbackConverter>(str _location, cpython::function::PyObjectCallbackConverter f, pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call::closure-0) Line 227	Unknown
    hg.real.exe!pytracing::{{impl}}::create_instance::TYPE_OBJECT::wrap_call(python27_sys::object::PyObject * slf, python27_sys::object::PyObject * args, python27_sys::object::PyObject * kwargs) Line 689	Unknown
    [External Code]
    [Inline Frame] hg.real.exe!cpython::objectprotocol::ObjectProtocol::call::{{closure}}(cpython::objectprotocol::ObjectProtocol::call::closure-0 args, python27_sys::object::PyObject *) Line 218	Unknown
    [Inline Frame] hg.real.exe!cpython::objects::tuple::{{impl}}::with_borrowed_ptr(cpython::objects::tuple::PyTuple * self, cpython::python::Python f, cpython::objectprotocol::ObjectProtocol::call::closure-0) Line 177	Unknown
    [Inline Frame] hg.real.exe!cpython::objectprotocol::ObjectProtocol::call(cpython::objects::object::PyObject * self, cpython::python::Python args, cpython::objects::tuple::PyTuple kwargs, core::option::Option<cpython::objects::dict::PyDict*>) Line 217	Unknown
    hg.real.exe!cpython::objects::module::PyModule::call<cpython::objects::tuple::PyTuple>(cpython::python::Python self, str name, cpython::objects::tuple::PyTuple args, core::option::Option<cpython::objects::dict::PyDict*> kwargs) Line 136	Unknown
    [Inline Frame] hg.real.exe!hgcommands::hgpython::HgPython::run_hg_py(cpython::python::Python self, alloc::vec::Vec<alloc::string::String, alloc::alloc::Global> py, io::IO * args) Line 98	Unknown
    hg.real.exe!hgcommands::hgpython::HgPython::run_hg(alloc::vec::Vec<alloc::string::String, alloc::alloc::Global> self, io::IO * args) Line 106	Unknown
    hg.real.exe!hgcommands::run::run_command(alloc::vec::Vec<alloc::string::String, alloc::alloc::Global> args, io::IO * io) Line 148	Unknown
    hg.real.exe!hgmain::main() Line 82	Unknown
    [Inline Frame] hg.real.exe!core::ops::function::FnOnce::call_once(void(*)()) Line 227	Unknown
    hg.real.exe!std::sys_common::backtrace::__rust_begin_short_backtrace<fn(),tuple<>>(void(*)() f) Line 125	Unknown
    hg.real.exe!std::rt::lang_start::{{closure}}<tuple<>>(std::rt::lang_start::closure-0 *) Line 66	Unknown
    [Inline Frame] hg.real.exe!core::ops::function::impls::{{impl}}::call_once() Line 280	Unknown
    [Inline Frame] hg.real.exe!std::panicking::try::do_call() Line 379	Unknown
    [Inline Frame] hg.real.exe!std::panicking::try() Line 343	Unknown
    [Inline Frame] hg.real.exe!std::panic::catch_unwind() Line 396	Unknown
    hg.real.exe!std::rt::lang_start_internal() Line 51	Unknown

Reviewed By: kulshrax

Differential Revision: D27724330

fbshipit-source-id: 2a016ddb76607c5f636b834dbac6e7d4443d8f40
2021-04-13 12:32:26 -07:00
Jun Wu
b0e6b21fc5 indexedlog: add RotateLog::slice_to_bytes
Summary: This will make RotateLog achieve zero-copy reading more easily.

Reviewed By: kulshrax

Differential Revision: D27724331

fbshipit-source-id: 57915516dc6bd1935838bd099a60c104f0bdef3d
2021-04-13 12:32:25 -07:00
Jun Wu
b895c335bd indexedlog: make RotateLog::iter_dirty not take mut self
Summary: This makes it more flexible.

Reviewed By: kulshrax

Differential Revision: D27724332

fbshipit-source-id: 43ad670519f0617a97e0b7d38b374f497e9c01af
2021-04-13 12:32:25 -07:00
Jun Wu
5c3d6d152f io: add config for pager wrapping mode
Summary:
This allows setting the wrapping mode. For example:

   lhg log -pv
   # copy paste long lines works.

   lhg log -pv --config pager.wrapping-mode=unwrapped
   # lines are not wrapped, ">" is shown for long lines.

   lhg log -pv --config pager.wrapping-mode=word
   # long lines wrapped at word level.

The default value matches "less" behavior.

Reviewed By: DurhamG

Differential Revision: D27720767

fbshipit-source-id: e29d6b13656407c0a1e63287fb96e2f8d914cfc8
2021-04-13 12:15:16 -07:00
Andrey Chursin
f2d873d77c checkout: check unknown files during native checkout
Summary: This is needed to prevent situation when we try writing into file that is untracked by hg

Reviewed By: DurhamG

Differential Revision: D27667152

fbshipit-source-id: 31bb9e30bd6b58e80ba96d280ff6ca1842c8caf6
2021-04-13 11:47:54 -07:00
Andrey Chursin
36b6bb98d3 checkout: bindings for check_unknown_files
Reviewed By: DurhamG

Differential Revision: D27667154

fbshipit-source-id: 0bdfb74761b01c1fe41ca8fd519c065a28381e74
2021-04-13 11:47:54 -07:00
Andrey Chursin
95e84b7302 checkout: introduce CheckoutPlan::check_unknown_files
Summary: This method checks if any of files that checkout writes is not tracked in hg and exists on disk

Reviewed By: DurhamG

Differential Revision: D27667153

fbshipit-source-id: 4ad8bc08520678ea0b51008ed14fb51ca4a98f76
2021-04-13 11:47:54 -07:00
Stanislau Hlebik
0450243694 mononoke: fix sql query for streaming changelog
Summary:
Previously this query failed because it tried to convert bytes to int, and our
mysql wrapper doesn't support that.
Let's cast it instead

Reviewed By: krallin

Differential Revision: D27736863

fbshipit-source-id: 66a7cb33c0f623614f292511e18eb62e31ea582f
2021-04-13 11:15:00 -07:00
Stefan Filip
d54706d339 dynamicconfig: add hostcaps for determining Domain
Summary:
`hostcaps` abstracts the logic for determining whether we have a prod or corp
environment.

Reviewed By: DurhamG

Differential Revision: D27684641

fbshipit-source-id: 50df9a60b6a613b4cb5c9aed6cad2844aae85a6f
2021-04-13 10:42:45 -07:00
Stefan Filip
6e262c3b79 lib: hoist hostcaps to the top level of the lib directory
Summary:
We want to use it in Mercurial and the directory structure was playing bad
with Mononoke's OSS build.

Reviewed By: xavierd

Differential Revision: D27684642

fbshipit-source-id: 8827645eee58fa671f9c9e1964a34c34e3a8eeb6
2021-04-13 10:42:45 -07:00
Katie Mancini
bcf6aa465c teach edenfs to signal itself on MacOS nfs
Summary:
MacOS does not have the device field like linux that we can use to mark edenfs
nfs mounts. But there is the `f_mntfromname` field. This field more typically
might have the path which this nfs mount is mirrored from, but it should be fine
to hyjack as the edenfs indicator field.

Reviewed By: xavierd

Differential Revision: D27717945

fbshipit-source-id: 056fb39dc3273b68d79c26487fd045f4e7f93b7b
2021-04-13 09:09:02 -07:00
Katie Mancini
ccb76f1187 make device type for nfs similar to fuse
Summary:
With fuse we report "edenfs:" as the device, let's do the same thing with nfs
so watchman can recognize edenfs nfs mounts similarly.

I think its fine to use the standard "edenfs" as the server name in the mount
call rather than the address, from looking at:
https://www.systutorials.com/docs/linux/man/8-mount.nfs/

Reviewed By: xavierd

Differential Revision: D27630764

fbshipit-source-id: 9e476c90ece90e758b98d140c6bf4067dbca3661
2021-04-13 09:09:02 -07:00
Simon Farnsworth
0f817c72fb Provide an admin command for blobstore unlink
Summary: Currently just does XDB Blobstore, because the work to do other types and/or go via Packblob is significant.

Reviewed By: markbt

Differential Revision: D27735093

fbshipit-source-id: d3797017a2e0ff7c60525d1f4d4ee3e63b519d49
2021-04-13 08:38:29 -07:00
Jan Mazur
4cb7732dae remove deprecated --readonly-storage cmdline arg
Summary: We have deprecated it in favor of argument that takes a boolean value.

Reviewed By: farnz

Differential Revision: D27709429

fbshipit-source-id: 45e9569188f2e9d017f1c5bf61f7c61bc0e5318a
2021-04-13 07:09:35 -07:00
Thomas Orozco
3c88bd8832 mononoke/timeseries: track count of valid buckets
Summary:
It's useful when operating with timeseries to know what range of data has been
populated. This diff adds support for this in mononoke/timeseries, by tracking
the number of buckets that fall within intervals where data was provided.

Reviewed By: mitrandir77

Differential Revision: D27734229

fbshipit-source-id: 3058a7ce4da67666e8ce8a46e34e277b69153ea4
2021-04-13 06:24:37 -07:00
Mark Juggurnauth-Thomas
a9b1b36721 admin: set background session class for skiplist build
Summary:
When building skiplists, set the session class to `Background`.  This ensures
that the blobstore writes for the new skiplist have completed fully.

Reviewed By: StanislavGlebik

Differential Revision: D27735411

fbshipit-source-id: 4ba8e8b91dafbb1aa258d15b26e7d773f63b5812
2021-04-13 06:12:20 -07:00
Thomas Orozco
a0a7091517 mononoke/lfs_server: reject Range requests that are out of bounds
Summary:
If the caller asks us for a range that extends past the end of our file, we'd
rather give them an error instead of silently returning the file.

This actually revealed one of the tests needed work :)

Note that right now we'll just end up categorizing this as 500. I'd like to
rework the errors we emit in the Filestore, but that's a somewhat bigger
undertaking so I'd like to do it separately.

Reviewed By: quark-zju

Differential Revision: D27193353

fbshipit-source-id: 922d68859401eb343cffd201057ad06e4b653aad
2021-04-13 05:10:00 -07:00
Mark Juggurnauth-Thomas
876f812e4b commitcloud: do not send backup bookmarks part
Summary:
The backupbookmarks part was used for infinitepush backup bookmarks, which were
deprecated.  Now stop sending the part entirely unless
`commitcloud.pushbackupbookmarks` is set.

Reviewed By: StanislavGlebik

Differential Revision: D27710099

fbshipit-source-id: 1eb404f106f5a8d9df6d73e11f60f89c1fa10400
2021-04-13 03:07:50 -07:00
Thomas Orozco
87aed04d37 mononoke/sql_ext: publish SQL max open connections stat
Summary:
Like it says in the title, this adds support for publishing our max open
connections to ODS. Note that this is a little more involved than I would like
for it to be, but there is no way to get direct access to this information.

This means, we need to:

- Expose how many open connections we have in flight (this is done earlier in
  this stack in the Rust MySQL bindings).
- Periodically get this information out out for MySQL, put it in a timeseries.
- Get the max out of said timeseries and publish it to a counter so that it can
  be fetched in ODS.

This is what this diff does. Note that I've only done this for read pools,
largely because I think they're the ones we tend to exhaust the most and I'd
like to see if there is value in exposing those counters before I use them.

We do the aggregation on a dedicated thread here. I contemplated making this a
Tokio task, but I figured making it a thread would make it easier to see if
it's misbehaving in any way (also: note that the SQL client allocates a bunch
of threads already anyway).

Reviewed By: HarveyHunt

Differential Revision: D27678955

fbshipit-source-id: c7b386f3a182bae787d77e997d108d8a74a6402b
2021-04-13 03:05:23 -07:00
Andrey Chursin
80adbe385c rename ephemeralcommit->hiddencommit
Summary: This name is more reasonable, since this commit is not actually ephemeral

Reviewed By: quark-zju

Differential Revision: D27722921

fbshipit-source-id: e2c0243d41a73341f9d0afdc79696ea37b34b8c7
2021-04-12 20:13:11 -07:00
Andres Suarez
6ccdc46775 third-party: update tracing-subscriber from 0.2.15 to 0.2.17
Reviewed By: dtolnay

Differential Revision: D27721151

fbshipit-source-id: 08a367662d506a48e0d639115c06cd4e714717b9
2021-04-12 19:24:10 -07:00
Xavier Deguillard
db2c912111 store: re-enable store tests under tsan
Summary: Running these with tsan appears to run properly, let's try to re-enable them.

Reviewed By: genevievehelsel

Differential Revision: D27723525

fbshipit-source-id: 42e61d26cf478cbe808698a6a0615015832180fa
2021-04-12 18:46:26 -07:00
Jun Wu
2480bfcef5 discovery: remove unused discovery logic
Summary:
We have `experimental.findcommonheadsnew` set to True in all tests, and
Rust commit backends force the `findcommonheadsnew` paths, which is
pretty much everywhere except hgsql repos. Remove `_findcommonheadsold`.

The fast discovery is also unnecessary. Remove them too.

Reviewed By: DurhamG

Differential Revision: D27630496

fbshipit-source-id: ab1948f03a8c84e75e3b5c9ff4769e17533447d2
2021-04-12 17:11:37 -07:00
Genevieve Helsel
1776efce9c log file accesses to edenfs_file_stats_accesses
Reviewed By: chadaustin

Differential Revision: D27660120

fbshipit-source-id: 7e8e64e9a8db62d818db5177155db77195870e0a
2021-04-12 16:58:09 -07:00
Andre Kouznetsov
a4ed5fe9c0 place a README file under scratch directory to describe what it is for
Summary: Many users have asked what scratch directory is when they look to free some disk space. Placing a README.txt under the scratch root could be helpful to explain what is in there.

Reviewed By: fanzeyi

Differential Revision: D27710277

fbshipit-source-id: e3ccd92fa1920ac4c791026b8d98aa05a1c8b268
2021-04-12 15:17:33 -07:00
Andrey Chursin
aa86902059 checkout: use scmstore in merge.py during checkout
Summary: This diff uses filescmstore for native checkout when nativecheckout.usescmstore config is set

Reviewed By: DurhamG

Differential Revision: D27658844

fbshipit-source-id: ec3442d677ccb25e8b08cc194e4c8c18c0e01fa1
2021-04-12 14:45:11 -07:00
Andrey Chursin
5cc082a2d4 checkout: py binding for filescmstore
Summary: This introduces apply_scmstore method in pycheckout bindings

Reviewed By: DurhamG

Differential Revision: D27658751

fbshipit-source-id: c09e27483bd4ecbecf9ae7193d8d030702b07315
2021-04-12 14:45:10 -07:00
Andrey Chursin
8b1ab2fc4e checkout: support ReadStore in checkout
Summary:
This diff introduces CheckoutPlan::apply_read_store to apply checkout plan using ReadStore as a data source
This requires some minor changes in apply_stream flow as ReadStore does not guarantee ordering of returned files

Reviewed By: DurhamG

Differential Revision: D27658346

fbshipit-source-id: 5a289554d8dd7b6bb4b5a996659cd0661779ad5f
2021-04-12 14:45:10 -07:00
Jun Wu
06a791384b edenapi: configparser::ConfigSet -> configmodel::Config
Summary: The latter is more lightweight.

Reviewed By: DurhamG

Differential Revision: D27641665

fbshipit-source-id: d46f62f9067eb9cb4c8517a62efa6f663d4b6732
2021-04-12 14:29:45 -07:00
Jun Wu
0d764cf718 auth: configparser::ConfigSet -> configmodel::Config
Summary: The latter is more lightweight.

Reviewed By: DurhamG

Differential Revision: D27641669

fbshipit-source-id: d907407f5a6e868862fe37f1f67fbe99ee378156
2021-04-12 14:29:45 -07:00
Jun Wu
cb58689d67 io: configparser::ConfigSet -> configmodel::Config
Summary: The latter is more lightweight.

Reviewed By: DurhamG

Differential Revision: D27641667

fbshipit-source-id: adce5a39fcb5d8e8d5d989fed46991e20ab3710d
2021-04-12 14:29:45 -07:00
Jun Wu
4d0359740c configparser: integrate with configmodel
Summary: Provides a way to read config with lighter dependencies.

Reviewed By: DurhamG

Differential Revision: D27641668

fbshipit-source-id: fc99a78f5f51e63f61d1b049af74f61f5d1916a3
2021-04-12 14:29:45 -07:00
Jun Wu
a25ec579bf lib: add configmodel
Summary:
The `configparser` is now too heavyweight. Some other crates (ex. io, auth,
revisionstore) just want to extract config values without complicated parsing /
remote hotfix logic.

Add a configmodel crate to satisfy the need.

Reviewed By: DurhamG

Differential Revision: D27641666

fbshipit-source-id: 26bd0b606ae3d286b3ec218927aef726d6802c63
2021-04-12 14:29:45 -07:00
Xavier Deguillard
1aee89eaee store: use NO_PRETTY_VALUES when discovering tests
Summary:
The CMake documentation states:

>By default, the value index of value-parameterized tests is replaced by the
>actual value in the CTest test name. If this behavior is undesirable (e.g.
>because the value strings are unwieldy), this option will suppress this
>behavior.

Which appears to be a decent default, but not when the parameter is a pointer,
in which case the test name will contain some hex values.

Reviewed By: genevievehelsel

Differential Revision: D27713222

fbshipit-source-id: 0f15b24d04817384ff975ad7b07e16b744e1eb2e
2021-04-12 13:43:09 -07:00
Arun Kulshreshtha
f738f65d28 http-client: add verbose option to requests
Summary: Add a new `http.verbose` config option that turns on verbose output for libcurl (similar to the output printed by `curl -v`). This can be very useful for debugging HTTP issues.

Reviewed By: DurhamG

Differential Revision: D27693304

fbshipit-source-id: 2ad7a08889f40ffbcd2f14ac9c21d70433629da4
2021-04-12 12:17:12 -07:00
Arun Kulshreshtha
11697cde4c remotefilelog: cache edenapistore
Summary: Make this method match the behavior of `remotefileslog.memcachestore` and cache the `edenapistore` instead of constructing a new one each time. Right now this doesn't matter too much because we currently only call this once when setting up the Rust `revisionstore`, but it would be good to avoid creating multiple instances if we do start using this elsewhere.

Reviewed By: DurhamG

Differential Revision: D27684210

fbshipit-source-id: 7987f603c79758902b4740dd8b46d26a25baec93
2021-04-12 12:17:12 -07:00
Arun Kulshreshtha
fdfc52775d remotefilelog: disable memcache when cachekey is empty
Summary:
This diff causes memcache to be disabled when `remotefilelog.cachekey` is set to the empty string, thereby allowing memcache to be disabled on the command line with `--config remotefilelog.cachekey=''`. This is useful when testing data-layer changes.

Previously, the only way to do this was to add `%unset cachekey` to the `remotefilelog` section of your `hgrc`, which was a bit tedious compared to just using a `--config` flag.

Reviewed By: DurhamG

Differential Revision: D27683782

fbshipit-source-id: 3e0434e98a32db916a07935e8b26f70317f50286
2021-04-12 12:17:12 -07:00
Stanislau Hlebik
85469374e9 mononoke: add leases to x-repo-sync
Reviewed By: ikostia

Differential Revision: D27677897

fbshipit-source-id: e86220f23f5950130f2f4ead2743f9a9b86abed7
2021-04-12 12:08:34 -07:00
Stefan Filip
b48f998a61 mononokepeer: update handling of pipe read errors
Summary: The error is not going to have a message in many cases leading to crashes.

Reviewed By: quark-zju

Differential Revision: D27637119

fbshipit-source-id: 135b133371916dddf0c47a84f00957a8b8fdfe92
2021-04-12 11:07:55 -07:00
Xavier Deguillard
f641a24ecf doctor: add types to nfs_test
Summary:
It looks like nfs_test is tripping the nightly pyre infer job causing it to not
publish diff that increase our typing coverage. Let's manually type it to
unblock the nightly job.

Reviewed By: genevievehelsel

Differential Revision: D27682093

fbshipit-source-id: a32df9f5b8eeaef2006de7d64f5adadb763402e8
2021-04-12 11:06:28 -07:00
Simon Farnsworth
802c038553 Slow down sqlblob_gc retries to let bad connections leave the pool
Summary:
We hammer MySQL during GC - slow down so that bad connections to
servers that are no longer current are dropped from the pool

https://fb.workplace.com/groups/scm.mononoke/permalink/1407064449656126/?comment_id=1408378062858098 justifies setting the MySQL max ages to 1 second - it works around a MyRouter issue where it *should* reconnect us to a different host, but doesn't.

Reviewed By: krallin

Differential Revision: D27500583

fbshipit-source-id: e900925e1f0d65828613fe3e3d7f4128dc7cde82
2021-04-12 05:55:58 -07:00
Simon Farnsworth
b38e7d3a40 Separate MySQL pool for SQLBlob
Summary: SQLBlob doesn't benefit from sharing a pool with other MySQL users, but does benefit from more aggressive connection timeouts. Give it its own pool, which we can tweak later.

Reviewed By: krallin

Differential Revision: D27651133

fbshipit-source-id: 8f5216ec0506b217f9365babfe1ebac00f68a9a9
2021-04-12 05:25:48 -07:00
Thomas Orozco
d677947066 metagit/hosts-down-tailer: use mononoke/common/timeseries
Summary:
Like it says in the title. This is a place where we use timeseries so we might
as well use that shared crate.

Reviewed By: mzr

Differential Revision: D27678389

fbshipit-source-id: 9b5d4980a1ddb5ce2a01c8ef417c78b1c3da80b7
2021-04-12 05:22:33 -07:00
Thomas Orozco
e64012ad9e mononoke/timeseries: introduce a basic crate for tracking time series
Summary:
I'd like to be able to track time series for access within Mononoke. The
underlying use case here is that I want to be able to track the max count of
connections in our SQL connection pools over time (and possibly other things in
the future).

Now, the obvious question is: why am I rolling my own? Well, as it turns out,
there isn't really an implementation of this that I can reuse:

- You might expect to be able to track the max of a value via fb303, but you
  can't:

https://www.internalfb.com/intern/diffusion/FBS/browse/master/fbcode/fb303/ExportType.h?commit=0405521ec858e012c0692063209f3e13a2671043&lines=26-29

- You might go look in Folly, but you'll find that the time series there only
  supports tracking Sum & Average, but I want my timeseries to track Max (and
  in fact I'd like it to be sufficiently flexible to track anything I want):

https://www.internalfb.com/intern/diffusion/FBS/browse/master/fbcode/folly/stats/BucketedTimeSeries.h

It's not the first time I've ran into a need for something like this. I needed
it in RendezVous to track connections over the last 2 N millisecond intervals,
and we needed it in metagit for host draining as well (note that the
implementation here is somewhat inspired by the implementation there).

Reviewed By: mzr

Differential Revision: D27678388

fbshipit-source-id: ba6d244b8bb848d4e1a12f9c6f54e3aa729f6c9c
2021-04-12 05:22:33 -07:00
Thomas Orozco
5186e6b92f mononoke: fix the build
Summary:
This is breaking with a warning because there's a method called `intersperse`
that might be introduced in the std lib:

```
stderr: error: a method with this name may be added to the standard library in the future
  --> eden/mononoke/hgproto/src/sshproto/response.rs:48:53
   |
48 |             let separated_results = escaped_results.intersperse(separator);
   |                                                     ^^^^^^^^^^^
   |
note: the lint level is defined here
  --> eden/mononoke/hgproto/src/lib.rs:14:9
```

This should fix it.

Reviewed By: ikostia

Differential Revision: D27705212

fbshipit-source-id: 5f2f641ea6561c838288c8b158c6d9e134ec0724
2021-04-12 05:07:48 -07:00
David Tolnay
e5ce96ff83 &ConstCStr -> ConstCStr
Summary:
`const_cstr::ConstCStr` is represented internally as a fat pointer with fixed size: `&'static str`. See https://docs.rs/const-cstr/0.3.0/const_cstr/struct.ConstCStr.html. Notably this is **different** from the representation of `std::ffi::CStr`, which is a dynamically sized type and normally passed around behind a reference, as `&CStr`. Using `&ConstCStr` in signatures, which is effectively like `&'a &'static CStr`, is confusing due to the discrepancy between the two relatedly named types. Additionally having two different lifetimes involved -- the static lifetime of the underlying bytes, and the short lifetime of the fat pointer -- is unnecessarily confusing when async code and a language boundary are involved.

The utf8-cstr crate uses what seems like a better representation to me than the const-cstr crate. See https://docs.rs/utf8-cstr/0.1.6/utf8_cstr/struct.Utf8CStr.html. `Utf8CStr` is the dynamically sized type, just like `CStr`. Then `&'static Utf8CStr` is how it would commonly be passed around, just like `&CStr`.

Reviewed By: krallin

Differential Revision: D27698169

fbshipit-source-id: ffe172c2c2fc77aeab6b0a0a8aed3e3c196098cc
2021-04-12 04:34:09 -07:00
Pyre Bot Jr
2b98b8c93c suppress errors in eden
Differential Revision: D27694246

fbshipit-source-id: c4364aee7fbc83d17c5e2ee3697bf2c29a194de3
2021-04-09 22:21:58 -07:00
Yedidya Feldblum
d5de1b81dd migrate from uint64ToBufferUnsafe
Summary: Migrate the codebase away from the ad-hoc `folly::uint64ToBufferUnsafe` and to `folly::to_ascii_decimal` which is intended for these cases.

Reviewed By: WillerZ

Differential Revision: D27281875

fbshipit-source-id: 0c98749e4aed9c873853eed2221cf54a89279ff4
2021-04-09 21:34:38 -07:00
Stefan Filip
5f78ccb284 edenapi: update hash-to-location to discard unknown hashes
Summary:
The hashes that are passed in as parameters to the hash-to-location function
may not be hashes that actually exist. This change updates the code so that
we don't return an error when an unknown hash is passed in. The unknown
hash will be skipped in the list of results.

Reviewed By: quark-zju

Differential Revision: D27526758

fbshipit-source-id: 8bf9b7a134a6a8a4f78fa0df276f847d922472f5
2021-04-09 17:10:57 -07:00