From 9888dfdbf9dbcd9c4aaf8e8dadd99546f7d019ee Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Fri, 2 May 2025 09:24:06 +0000 Subject: [PATCH] Bug 1963027 - Update to Glean v64.2.0 r=chutten,supply-chain-reviewers,mach-reviewers,ahochheiden Differential Revision: https://phabricator.services.mozilla.com/D246926 --- Cargo.lock | 12 ++-- Cargo.toml | 4 +- gfx/wr/Cargo.lock | 33 ++++------- gfx/wr/Cargo.toml | 3 +- gfx/wr/servo-tidy.toml | 1 - gradle/libs.versions.toml | 2 +- python/sites/mach.txt | 2 +- supply-chain/imports.lock | 8 +-- .../rust/glean-core/.cargo-checksum.json | 2 +- third_party/rust/glean-core/Cargo.toml | 11 +++- .../rust/glean-core/src/common_metric_data.rs | 9 ++- third_party/rust/glean-core/src/core/mod.rs | 6 +- .../rust/glean-core/src/core_metrics.rs | 3 +- .../rust/glean-core/src/database/mod.rs | 29 ++++++++++ third_party/rust/glean-core/src/debug.rs | 13 +++++ .../rust/glean-core/src/event_database/mod.rs | 14 ++++- .../glean-core/src/histogram/exponential.rs | 3 +- .../glean-core/src/histogram/functional.rs | 3 +- .../rust/glean-core/src/histogram/linear.rs | 3 +- .../rust/glean-core/src/histogram/mod.rs | 5 +- .../rust/glean-core/src/internal_metrics.rs | 10 ++-- .../rust/glean-core/src/internal_pings.rs | 4 +- third_party/rust/glean-core/src/lib.rs | 7 ++- .../rust/glean-core/src/metrics/datetime.rs | 3 +- .../rust/glean-core/src/metrics/labeled.rs | 29 ++++++++++ .../rust/glean-core/src/metrics/mod.rs | 58 +++++++++++++++++++ .../rust/glean-core/src/metrics/ping.rs | 10 ++++ .../src/metrics/recorded_experiment.rs | 3 +- .../src/metrics/remote_settings_config.rs | 3 +- .../rust/glean-core/src/metrics/time_unit.rs | 3 +- .../src/metrics/timing_distribution.rs | 15 ++++- .../rust/glean-core/src/upload/directory.rs | 28 ++++++++- third_party/rust/glean-core/src/upload/mod.rs | 46 ++++++++++++++- .../rust/glean-core/src/upload/policy.rs | 4 +- third_party/rust/glean/.cargo-checksum.json | 2 +- third_party/rust/glean/Cargo.lock | 40 ++++++++++++- third_party/rust/glean/Cargo.toml | 10 +++- third_party/rust/glean/src/private/event.rs | 8 +++ third_party/rust/glean/src/private/object.rs | 8 +++ third_party/rust/glean/src/private/ping.rs | 20 ++++++- 40 files changed, 406 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d58322e8805..6eb1fd3e83e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2641,9 +2641,9 @@ dependencies = [ [[package]] name = "glean" -version = "64.1.1" +version = "64.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95024f4707705270208e36983976cbac235dd7fc33c9f1cb0dee396ec1ce295d" +checksum = "3bbaa151992ac45799a3779a3ff9d9ce1412a91f982b54f95ac85124e96f870c" dependencies = [ "crossbeam-channel", "glean-core", @@ -2651,13 +2651,14 @@ dependencies = [ "log", "once_cell", "whatsys", + "wr_malloc_size_of", ] [[package]] name = "glean-core" -version = "64.1.1" +version = "64.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca0df94fb37669287b77e8aa300913ad1d14426d7f9e443b0ce1185349c817e" +checksum = "ec64dd5ecb37f04def90b179759c8906c95c895c392b444b5b67f868ffa4bedc" dependencies = [ "android_logger", "bincode", @@ -2665,6 +2666,7 @@ dependencies = [ "crossbeam-channel", "flate2", "log", + "malloc_size_of_derive", "once_cell", "oslog", "rkv", @@ -2674,6 +2676,7 @@ dependencies = [ "time 0.1.45", "uniffi", "uuid", + "wr_malloc_size_of", "zeitstempel", ] @@ -7847,6 +7850,7 @@ version = "0.2.0" dependencies = [ "app_units", "euclid", + "once_cell", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8c6b99bc629e..45f415a83c1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ uniffi_bindgen = "0.29.1" # Shared across multiple application-services consumers. rusqlite = "0.33.0" # Shared across multiple glean consumers. -glean = "=64.1.1" +glean = "=64.2.0" # Explicitly specify what our profiles use. The opt-level setting here is # a total fiction; see the setup of MOZ_RUST_DEFAULT_FLAGS for what the @@ -255,6 +255,8 @@ midir = { git = "https://github.com/mozilla/midir.git", rev = "85156e360a37d8517 # Allow webrender to have a versioned dependency on the older crate on crates.io # in order to build standalone. malloc_size_of_derive = { path = "xpcom/rust/malloc_size_of_derive" } +# Use the in-tree code instead of pulling it in. It matches the crates.io version +wr_malloc_size_of = { path = "gfx/wr/wr_malloc_size_of" } # objc 0.2.7 + fa7ca43b862861dd1cd000d7ad01e6e0266cda13 objc = { git = "https://github.com/glandium/rust-objc", rev = "4de89f5aa9851ceca4d40e7ac1e2759410c04324" } diff --git a/gfx/wr/Cargo.lock b/gfx/wr/Cargo.lock index 811c44d0ad1b..6432b2e07aa4 100644 --- a/gfx/wr/Cargo.lock +++ b/gfx/wr/Cargo.lock @@ -982,9 +982,9 @@ dependencies = [ [[package]] name = "glean" -version = "64.1.1" +version = "64.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95024f4707705270208e36983976cbac235dd7fc33c9f1cb0dee396ec1ce295d" +checksum = "3bbaa151992ac45799a3779a3ff9d9ce1412a91f982b54f95ac85124e96f870c" dependencies = [ "crossbeam-channel", "glean-core", @@ -992,13 +992,14 @@ dependencies = [ "log", "once_cell", "whatsys", + "wr_malloc_size_of", ] [[package]] name = "glean-core" -version = "64.1.1" +version = "64.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca0df94fb37669287b77e8aa300913ad1d14426d7f9e443b0ce1185349c817e" +checksum = "ec64dd5ecb37f04def90b179759c8906c95c895c392b444b5b67f868ffa4bedc" dependencies = [ "android_logger", "bincode", @@ -1006,6 +1007,7 @@ dependencies = [ "crossbeam-channel", "flate2", "log", + "malloc_size_of_derive", "once_cell", "oslog", "rkv", @@ -1015,6 +1017,7 @@ dependencies = [ "time", "uniffi", "uuid", + "wr_malloc_size_of", "zeitstempel", ] @@ -1571,13 +1574,13 @@ dependencies = [ [[package]] name = "malloc_size_of_derive" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632647502a8bfa82458c07134791fffa7a719f00427d1afd79c3cb6d4960a982" +checksum = "f44db74bde26fdf427af23f1d146c211aed857c59e3be750cf2617f6b0b05c94" dependencies = [ "proc-macro2", - "syn 1.0.91", - "synstructure 0.12.6", + "syn 2.0.32", + "synstructure", ] [[package]] @@ -1989,7 +1992,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.32", - "synstructure 0.13.1", + "synstructure", ] [[package]] @@ -2643,18 +2646,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.91", - "unicode-xid", -] - [[package]] name = "synstructure" version = "0.13.1" diff --git a/gfx/wr/Cargo.toml b/gfx/wr/Cargo.toml index dbb574a052bd..256ea1d1b49c 100644 --- a/gfx/wr/Cargo.toml +++ b/gfx/wr/Cargo.toml @@ -9,7 +9,7 @@ members = [ resolver = "2" [workspace.dependencies] -glean = "=64.1.1" +glean = "=64.2.0" [profile.release] debug = true @@ -29,3 +29,4 @@ opt-level = 2 firefox-on-glean = { path = "fog" } # use a patched version of glutin that works on android glutin = { version = "0.28", git = "https://github.com/jamienicol/glutin", branch="wr" } +wr_malloc_size_of = { path = "wr_malloc_size_of" } diff --git a/gfx/wr/servo-tidy.toml b/gfx/wr/servo-tidy.toml index 1c9890ede045..de83193b35dc 100644 --- a/gfx/wr/servo-tidy.toml +++ b/gfx/wr/servo-tidy.toml @@ -32,7 +32,6 @@ packages = [ "rustc-hash", # transition to syn 2 is underway. "syn", - "synstructure", # Requires an update to clap v4 "textwrap", # Can be fixed by removing time dependency - see bug 1765324 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4dee53996f82..e1203b7667e1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -80,7 +80,7 @@ serialization = "1.8.1" # Mozilla versions apilint = "0.5.4" -mozilla-glean = "64.1.1" +mozilla-glean = "64.2.0" # Testing versions androidx-test = "1.6.1" diff --git a/python/sites/mach.txt b/python/sites/mach.txt index 61e6c3e36f0a..ee931f61beae 100644 --- a/python/sites/mach.txt +++ b/python/sites/mach.txt @@ -104,7 +104,7 @@ vendored:third_party/python/wheel vendored:third_party/python/zipp # glean-sdk may not be installable if a wheel isn't available # and it has to be built from source. -pypi-optional:glean-sdk==64.1.1:telemetry will not be collected +pypi-optional:glean-sdk==64.2.0:telemetry will not be collected # Mach gracefully handles the case where `psutil` is unavailable. # We aren't (yet) able to pin packages in automation, so we have to # support down to the oldest locally-installed version (5.4.2). diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index fbc393cae59f..e91e91218f94 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -258,15 +258,15 @@ user-login = "jrmuizel" user-name = "Jeff Muizelaar" [[publisher.glean]] -version = "64.1.1" -when = "2025-04-10" +version = "64.2.0" +when = "2025-04-28" user-id = 48 user-login = "badboy" user-name = "Jan-Erik Rediger" [[publisher.glean-core]] -version = "64.1.1" -when = "2025-04-10" +version = "64.2.0" +when = "2025-04-28" user-id = 48 user-login = "badboy" user-name = "Jan-Erik Rediger" diff --git a/third_party/rust/glean-core/.cargo-checksum.json b/third_party/rust/glean-core/.cargo-checksum.json index 146abf79a3d3..5714c19fb8e4 100644 --- a/third_party/rust/glean-core/.cargo-checksum.json +++ b/third_party/rust/glean-core/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"ffc8000a6fb68eb9465dff661e40e43b95fef93cf874a03bc8c4bc9642c6e766","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"026495898699b54608eb4ec16074ffafc57920d80ccb59961c501a1ea28c9985","build.rs":"4857bea99c6b8c08db8818efa9d3738716f52d3acb68159323957ae52892a3eb","src/common_metric_data.rs":"02dd1628fed6587621c089952dd0cb80bed3c352cdacfb33be7e218ad1d847e9","src/core/mod.rs":"e749d51f05fcfc9651e4021cd90682dafc107e58db0083e1b48f8df277d4581c","src/core_metrics.rs":"fb9707a4df04113d84e7608a15a7a4fd6a826a97b9aad73ec3438a8cad92b4b0","src/coverage.rs":"49613fd310bd24d779472720975fbe6c97ec370a95eb55f10afa43f67539c942","src/database/mod.rs":"d9c01ecf92b69a0fe826abf1abf81569ab0dbe61d7f3d8c41201f3a21ac1b13b","src/debug.rs":"7bd9e199d0d5c8170f6dbb9a725a18eaca1df34309d32b02081574962a86816e","src/dispatcher/global.rs":"17493b1a5e926ca1e9c1cda2ee031773402a19183911eb80048630d60266d89e","src/dispatcher/mod.rs":"391310269947452d7e0de24c848c183110c60149d75e345ba6d5d146f222dace","src/error.rs":"b93c7d3e243b21bb9eafc95f17860aba1a942b2f2b0a7f43307690f05fece516","src/error_recording.rs":"32c1f58ff080cb22184bca37e356faadbfe846386880fb0898b773adb3a97d8c","src/event_database/mod.rs":"33519a9f648b6b8a014c23a47c8aa74420511027b9c6984e0c77a4e6192c02c6","src/fd_logger.rs":"0c9def6fa53db1a2ab93c85795f8a7df57797bcfd3978146923e151752e291a6","src/glean.udl":"74a2334177724f571eb6986015aa5514766472fccf1686e888baaa909881d6f2","src/glean_metrics.rs":"9414fb1453d19f6832df33e4c6ef7383d62203e47026bf5bc9552b083101ddd1","src/histogram/exponential.rs":"0f2c0857782d6910754a01438b1b4cd77bf0d3b847fd9ef969ba4da3705c5f5b","src/histogram/functional.rs":"22b2e64c3c1930e055beeebb832e3212e22b65b28e2ebb94c6bb3aff7ca31ba3","src/histogram/linear.rs":"bc33060cbbbb9c777539074cf5f788ab0f1a4ccecce0bf2cae2a697dd5089ea0","src/histogram/mod.rs":"c5eca9f6b0e1e309a7b41c2427d4c1da9c30e832d358d65ba347ba522abfd9c7","src/internal_metrics.rs":"54228cf409b4dd634fe0983f2619d2e0922efdd5fbce0f85a92454488967c854","src/internal_pings.rs":"3957a9fe256977a05d8d9e3beeec4c1fd08029db1c516fec4f6b59888e46ef39","src/lib.rs":"ac31e3136bd0077c33fe32554b39a0528a44396e4bb61d5a38b2978ffa52872b","src/lib_unit_tests.rs":"82ea06a5d6a8894c1670f99d0c236d8fa75eb9947fc8a1a53061a5e4c26b0b1d","src/metrics/boolean.rs":"2b9ef57e3582c9bd8b2cca8ab94c962a4871ecc00e837b913c9b0349ba9dff08","src/metrics/counter.rs":"b4a52a8167fb0edd6354f952525e59f3eadb4261de3483374f03c94449d30b92","src/metrics/custom_distribution.rs":"1ec4fd2ecebf547bef0ed28ae6854f641be447bcbf4066a8580f6af16a23e37f","src/metrics/datetime.rs":"e4405762fc71718299fa1b208e3d5fda654bd1b82fe908c884c284e3530de2ec","src/metrics/denominator.rs":"95e8442f90bad97f80fc74b146782f215344b52c5f3825ae0a8baffdc001a714","src/metrics/event.rs":"cd52e200d313e2e6f31707419d4a7fe1cab34916ee145f8136440d6da34aaad4","src/metrics/experiment.rs":"5f9278cca4e133eb8df33bbfe36d1fe0ef3eade8c09f1b46db3c4d0790515412","src/metrics/labeled.rs":"79acae98b7bd8536edcde5150c1402ed8560a8eb0ad5c04b79b7c67743d0aa71","src/metrics/memory_distribution.rs":"d3f02a6a78ed103024a2479975cd7617153e3f082e20f8f45c8e7afd052cec45","src/metrics/memory_unit.rs":"ee32e020cb303dd631457374048a3ed53a2e7cbacc29c54d17d836fb15507538","src/metrics/mod.rs":"777f89015c1642ed73536b07edc0763d179dbf608e2a0394439fe002cbc2fb53","src/metrics/numerator.rs":"937dfd583b797ac798a525cedca95c5a36262356760a89670d8113983c263154","src/metrics/object.rs":"2a1f1cc31973b576e55ba464b35c41b9420f62471eebba51273bca6856459538","src/metrics/ping.rs":"3b4524e8d17d55fe993746061636fb7d9566b51ac511765e173e7247907f0493","src/metrics/quantity.rs":"1315ae3216ebeec5b5a5baab88d63f88469875f538501e8320716516ef82bddf","src/metrics/rate.rs":"603cc45c149c7a27c93b6a80146bf43f8ce70d9655f905bb5be6bc2c15bcb22b","src/metrics/recorded_experiment.rs":"33958abee79d8b55dec4cb5d20742640423713010f76314075cefde18b5c118a","src/metrics/remote_settings_config.rs":"c85af9f9fef87ddfc578af4f2637c9bdcae18fbc6735ccc87a13a9b0ee0319ab","src/metrics/string.rs":"88beb1a847e5df9898b72ca7ed8ced3b7d2b40d83ff3670baf66f83a3e6cb005","src/metrics/string_list.rs":"ed53a095184c3e8224d0511809b5d7601ba3166505a39b0570f24ebeb0a5b97c","src/metrics/text.rs":"757f6919124d74e0512faa5bb9751a729b6bbc63ebe4d16ca81e9087f5595eaf","src/metrics/time_unit.rs":"4704703e19e799933aec3f39e3d3a125058756d7c7ba04f8729885c7843df447","src/metrics/timespan.rs":"e239c618f459c34f2799c73a4da3e3c6c0b2089ba42d584c2ddd12ed067586e6","src/metrics/timing_distribution.rs":"c61a2cd32a54e018b4b0bb60f030bada40fcbe68d6e6346eac8212cf416e14a3","src/metrics/url.rs":"589ae1f8047367ad8c19b57a48ca8130d5f36cf3ce5954124150f0eb89c620ea","src/metrics/uuid.rs":"cacffd95ab30ed327ec2fa5feaf1359e667706746401f1e2c1195ad9553c4b54","src/ping/mod.rs":"a4cc6b37443392aed79957a1b5d6943307e14bd3ead9fa9880c20aee48472ae2","src/scheduler.rs":"eb8131ed075e2d92bf0dc0a2c2a7e67c73bb61042d574c21965b1699cd1239aa","src/storage/mod.rs":"91f02556f113799e0d88d732ab342bda443f43461369e8b41c424c074d742591","src/system.rs":"e3d1b54e1d39cafe6f4dc7ff5021b08c879733f909951b0e1332b3efa9ed97bd","src/traits/boolean.rs":"be0e130f8043215705becc956d45b126c340568f1b24a396c0af9b4334a41ced","src/traits/counter.rs":"c686d26e131d854cd7a7df83c900ca7c17a03c663a30cf58ab48c7259476ce85","src/traits/custom_distribution.rs":"0bd1d425e4c059cca6af2dfb13c78e5e4c6c07fb46c7e31489ad0c5959854833","src/traits/datetime.rs":"636ac1456b1b042e38cf5ae6193c5b232ea0b80df62f583a2097891baef9641b","src/traits/event.rs":"a02235aae630aba7a45a3166b756927252b397af3ecdfab7236931e62725ac49","src/traits/labeled.rs":"1b2f8eea8d59e1635f64993936d880084a5e3f65cfd7a26ddf6968366890187d","src/traits/memory_distribution.rs":"55bb8f45e948319fbba9d28a50d8742da134b066a42e480887db7c7e435f4096","src/traits/mod.rs":"3560fdf3b81dceabbac9d97b0356aa8f883e477dcb787c81a09529047fda7161","src/traits/numerator.rs":"6e4f236bdc448f1bde7a8c249dcd086204c2c69990d3f444e746290929226ed3","src/traits/object.rs":"c03bad670ec7affbc578247f9e1904e898c1870b9bf25750c5094113f995623f","src/traits/ping.rs":"8831c106c03afeb458b0b028fa1ce61f056ebf8e82bc0a171a1bff255d920748","src/traits/quantity.rs":"6ffe25c913bef4315573d747308c182de740b2a4e02ba22cd21d0c33ba521f31","src/traits/rate.rs":"f000790440e0f389f0b160526a9a9a266e58d1405915ae56ac550f482858222c","src/traits/string.rs":"0c3c88382ff2e8eba89c7cfe129c4b84e31140af717819533c14919541ad790c","src/traits/string_list.rs":"14e56b62c2c2be1dd8013f12001f235b084abd2a0d5aa2f7932843877af49ac0","src/traits/text.rs":"8af7d3a0c87cfd8c6d33d6ad47532b431055bbdd395f9110da5630222c23cf93","src/traits/timespan.rs":"52be325a9c061916f34c5b638a07a93b4a14aa89fe365783103d2e06b998f547","src/traits/timing_distribution.rs":"0d35acddd9e35a7f8859cf007162460b5fd0bf06d205cd195ed1c857bbe58c42","src/traits/url.rs":"c27f7add23214ff051078b65b88120b620560d2841a1056c7214d5237e86b9e4","src/traits/uuid.rs":"81322e71c7e847bacaf827a2cd58f6193bdc208355524207f7f38db039da6aa8","src/upload/directory.rs":"363ddc345845c2d543f833a5a63f1c778455e68b36ac77ffce605cef29f0d5cb","src/upload/mod.rs":"edae31e4c2172fb1e8e8b2c5542812b1e29c3bfa2f1c7b08227cb7cc4260dd48","src/upload/policy.rs":"c250957a37783e74af8002cd80ba06ef9780a389fb0f61b8b665b79688f0a360","src/upload/request.rs":"de5532fc3d18e773330c05fe000643d87b9c4912a2d838099b8783538c5033ed","src/upload/result.rs":"c956266c54595d27d5e8b11abffe28fad5fea82995922618805b66cfdcc21d54","src/util.rs":"ee7500434d9758a320dd410f18d7e18da956591e19d2555db87eef9623e4b916","tests/boolean.rs":"76d6014ff108cb6514d9bceb1b2b14749a55b09921f4595a5e30f1bd3546e9f0","tests/collection_enabled.rs":"85f4b2eb49ac23437ae225ae2c44f354c952c24b7c806e2f2ee5dbe78e02c8db","tests/common/mod.rs":"a8f74c906dccfe747d5cf9dd83dd6e4d1ef25d0402d39a2d74105cddab80e54c","tests/counter.rs":"4c59def10e64de0d7a0241dde0267fd02c828b38be8cc67fba90a76004ca6721","tests/custom_distribution.rs":"41c593a0b4561e21f29d1a5b948de964a866253c58ca76ffefebe370fca150e0","tests/datetime.rs":"ec3c9760e70bb2cbc61ab23281c891bc1ec493c5c545466c29fd13e4f05c2c96","tests/event.rs":"5db675dad1bcbcee0451bfe5e93f05f28d7ef8098d19cd302c8bac262567cf0c","tests/labeled.rs":"3efddb05556e92a372f50a19b025ecf4ccd818c7c477250058db0706eb992079","tests/memory_distribution.rs":"3d9a5b8f99e03f783e3396e4320ee4dc974c895cfef2cec0b14d2a9a9f9b736f","tests/object.rs":"8c35676e04f6ccf54a28764700915e753fc0355bfa5d7804d72caba66fd564cd","tests/ping.rs":"eff68d3b47b04c58d8123214dd66e8d06d11f82ed3fd4f703224f84effb319bb","tests/ping_maker.rs":"64900bb24642127df559fa6ace4c7f0a4a4bf858321874c9b3758039df0ffa04","tests/quantity.rs":"55e7dca346fd1d27f0974b78ca3fb12427cb5da2ee637afc08a54f360f947361","tests/rate.rs":"94a3a7d0ccafea02a991ed9dd038cbfab8a534695b374b1ce6ed81285616e9f6","tests/storage.rs":"990dd1d13b9ffa8af0686977a6ac3502c6befb9eaa83649587e2660f51c596c9","tests/string.rs":"397fcfd27c25f0e81e2a40db3265b0d7dc0dd56b190319c1f86cb1c2c0ed4f9d","tests/string_list.rs":"34efa2afe3e89e6635f21ec9c80650d5816e35e9cb85163d894d600a5b3a4e3a","tests/text.rs":"1d43f6b90a43124311cacf0a6ee16f9e1e9263bcd11fee8b996d6efd81633638","tests/timespan.rs":"3d05739a93f3e0ea7264e8fdea876bd948714e5b44e82b8fd7c0218fdb597bb3","tests/timing_distribution.rs":"072ad950b2162e503150e411119b9a000573538bd2cff93c1c1a3616d1589ef4","tests/uuid.rs":"e0e58614319f5e973126f5b4e68d9289ccd6d65e428aca215bf7dcc8a0504889","uniffi.toml":"6ddc98b686b0925a81abd9d1c769e5c98ac29771b210a1c535931a46dec9a8e3"},"package":"5ca0df94fb37669287b77e8aa300913ad1d14426d7f9e443b0ce1185349c817e"} \ No newline at end of file +{"files":{"Cargo.toml":"6dcbf2812ba090b079911a65e3a8d8396fc4d87f13647b6f7424f51e7d0a22ee","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"026495898699b54608eb4ec16074ffafc57920d80ccb59961c501a1ea28c9985","build.rs":"4857bea99c6b8c08db8818efa9d3738716f52d3acb68159323957ae52892a3eb","src/common_metric_data.rs":"f9dd43dab48c51b1218bb28cf58323593d2bdfacb2e758c34f8f1d6808a38810","src/core/mod.rs":"e9981f211f7d99209709ed443b39021ae32865cbd821dcc840a0b94b8930c800","src/core_metrics.rs":"ddc750e9f4e11f88aee947360897031657aeef74fcf0f3293bd9033b78747354","src/coverage.rs":"49613fd310bd24d779472720975fbe6c97ec370a95eb55f10afa43f67539c942","src/database/mod.rs":"611fc6c772d3f9d946b774d0da98dc04e07ab67f81fad309b6aeb65e4f2507dd","src/debug.rs":"663f77a3335256a562afad031496ea9215e315edd608398452df514dcff0b4af","src/dispatcher/global.rs":"17493b1a5e926ca1e9c1cda2ee031773402a19183911eb80048630d60266d89e","src/dispatcher/mod.rs":"391310269947452d7e0de24c848c183110c60149d75e345ba6d5d146f222dace","src/error.rs":"b93c7d3e243b21bb9eafc95f17860aba1a942b2f2b0a7f43307690f05fece516","src/error_recording.rs":"32c1f58ff080cb22184bca37e356faadbfe846386880fb0898b773adb3a97d8c","src/event_database/mod.rs":"b2f56f50dcbcffcbe06af946764f71e5eb2543747a7983c684c543039d4d4f3c","src/fd_logger.rs":"0c9def6fa53db1a2ab93c85795f8a7df57797bcfd3978146923e151752e291a6","src/glean.udl":"74a2334177724f571eb6986015aa5514766472fccf1686e888baaa909881d6f2","src/glean_metrics.rs":"9414fb1453d19f6832df33e4c6ef7383d62203e47026bf5bc9552b083101ddd1","src/histogram/exponential.rs":"63c81371f3c912f946dd39aea76f6f3f73f35f1526110b7def4c2badab48143d","src/histogram/functional.rs":"fffa12a5b2b376cf9337ee0fdd6ad7961841e441b556a4e9ef29c524f933ea2d","src/histogram/linear.rs":"7531e1515844fca96f7c9dad48f632012d9d2bc002f02c15c82501c74c324e70","src/histogram/mod.rs":"8cc14043ff4ac76509200d4971bfbdaa6693ac6661f8adae337ee4ea994814c6","src/internal_metrics.rs":"536851266d133996346fcffa245a7c3b0b92a0567720037b6d6ca0f11707d105","src/internal_pings.rs":"8869f645251a479a31f4d392ddfe92e86dfeabec8ceb1f7e09f98c3c457949b8","src/lib.rs":"baf45b91fdfb634a2bea1d339cc0be175d566539887b9c67b9cba1237173c70e","src/lib_unit_tests.rs":"82ea06a5d6a8894c1670f99d0c236d8fa75eb9947fc8a1a53061a5e4c26b0b1d","src/metrics/boolean.rs":"2b9ef57e3582c9bd8b2cca8ab94c962a4871ecc00e837b913c9b0349ba9dff08","src/metrics/counter.rs":"b4a52a8167fb0edd6354f952525e59f3eadb4261de3483374f03c94449d30b92","src/metrics/custom_distribution.rs":"1ec4fd2ecebf547bef0ed28ae6854f641be447bcbf4066a8580f6af16a23e37f","src/metrics/datetime.rs":"0bce50e573c179d508a26fdef11cf32f4e4543a47f1fc1bbf078f3e371eb9d52","src/metrics/denominator.rs":"95e8442f90bad97f80fc74b146782f215344b52c5f3825ae0a8baffdc001a714","src/metrics/event.rs":"cd52e200d313e2e6f31707419d4a7fe1cab34916ee145f8136440d6da34aaad4","src/metrics/experiment.rs":"5f9278cca4e133eb8df33bbfe36d1fe0ef3eade8c09f1b46db3c4d0790515412","src/metrics/labeled.rs":"de7ed19a26cdd57eec21c9e3ee27d64c9c7387d762d5e4e48ce2899624ae3757","src/metrics/memory_distribution.rs":"d3f02a6a78ed103024a2479975cd7617153e3f082e20f8f45c8e7afd052cec45","src/metrics/memory_unit.rs":"ee32e020cb303dd631457374048a3ed53a2e7cbacc29c54d17d836fb15507538","src/metrics/mod.rs":"bf24326d3f6f55072d89eb9e9e329b926f7c80c07bf779c788754f56b67c343a","src/metrics/numerator.rs":"937dfd583b797ac798a525cedca95c5a36262356760a89670d8113983c263154","src/metrics/object.rs":"2a1f1cc31973b576e55ba464b35c41b9420f62471eebba51273bca6856459538","src/metrics/ping.rs":"a36ee8f8cf15bb05ca0da9e7b4bf096b85a86744564a7ae5d299803257769b02","src/metrics/quantity.rs":"1315ae3216ebeec5b5a5baab88d63f88469875f538501e8320716516ef82bddf","src/metrics/rate.rs":"603cc45c149c7a27c93b6a80146bf43f8ce70d9655f905bb5be6bc2c15bcb22b","src/metrics/recorded_experiment.rs":"6f089534bb4e1143abf0aa43e813c9fcc864fff128a825e83f09e61e96a1f6ee","src/metrics/remote_settings_config.rs":"3beea00afd2779f1e4d2d88ed43cbce1e5a62286ea74b52f0a62236f3b34c217","src/metrics/string.rs":"88beb1a847e5df9898b72ca7ed8ced3b7d2b40d83ff3670baf66f83a3e6cb005","src/metrics/string_list.rs":"ed53a095184c3e8224d0511809b5d7601ba3166505a39b0570f24ebeb0a5b97c","src/metrics/text.rs":"757f6919124d74e0512faa5bb9751a729b6bbc63ebe4d16ca81e9087f5595eaf","src/metrics/time_unit.rs":"72325065e4ac0f3562f1983bda9fe3c0ab18272011dafe03d67900a3184a8eb6","src/metrics/timespan.rs":"e239c618f459c34f2799c73a4da3e3c6c0b2089ba42d584c2ddd12ed067586e6","src/metrics/timing_distribution.rs":"7a41dbd1a1537b443aa30e34c14685ae1a00f7252ea59f4bba1b0e18ea391a17","src/metrics/url.rs":"589ae1f8047367ad8c19b57a48ca8130d5f36cf3ce5954124150f0eb89c620ea","src/metrics/uuid.rs":"cacffd95ab30ed327ec2fa5feaf1359e667706746401f1e2c1195ad9553c4b54","src/ping/mod.rs":"a4cc6b37443392aed79957a1b5d6943307e14bd3ead9fa9880c20aee48472ae2","src/scheduler.rs":"eb8131ed075e2d92bf0dc0a2c2a7e67c73bb61042d574c21965b1699cd1239aa","src/storage/mod.rs":"91f02556f113799e0d88d732ab342bda443f43461369e8b41c424c074d742591","src/system.rs":"e3d1b54e1d39cafe6f4dc7ff5021b08c879733f909951b0e1332b3efa9ed97bd","src/traits/boolean.rs":"be0e130f8043215705becc956d45b126c340568f1b24a396c0af9b4334a41ced","src/traits/counter.rs":"c686d26e131d854cd7a7df83c900ca7c17a03c663a30cf58ab48c7259476ce85","src/traits/custom_distribution.rs":"0bd1d425e4c059cca6af2dfb13c78e5e4c6c07fb46c7e31489ad0c5959854833","src/traits/datetime.rs":"636ac1456b1b042e38cf5ae6193c5b232ea0b80df62f583a2097891baef9641b","src/traits/event.rs":"a02235aae630aba7a45a3166b756927252b397af3ecdfab7236931e62725ac49","src/traits/labeled.rs":"1b2f8eea8d59e1635f64993936d880084a5e3f65cfd7a26ddf6968366890187d","src/traits/memory_distribution.rs":"55bb8f45e948319fbba9d28a50d8742da134b066a42e480887db7c7e435f4096","src/traits/mod.rs":"3560fdf3b81dceabbac9d97b0356aa8f883e477dcb787c81a09529047fda7161","src/traits/numerator.rs":"6e4f236bdc448f1bde7a8c249dcd086204c2c69990d3f444e746290929226ed3","src/traits/object.rs":"c03bad670ec7affbc578247f9e1904e898c1870b9bf25750c5094113f995623f","src/traits/ping.rs":"8831c106c03afeb458b0b028fa1ce61f056ebf8e82bc0a171a1bff255d920748","src/traits/quantity.rs":"6ffe25c913bef4315573d747308c182de740b2a4e02ba22cd21d0c33ba521f31","src/traits/rate.rs":"f000790440e0f389f0b160526a9a9a266e58d1405915ae56ac550f482858222c","src/traits/string.rs":"0c3c88382ff2e8eba89c7cfe129c4b84e31140af717819533c14919541ad790c","src/traits/string_list.rs":"14e56b62c2c2be1dd8013f12001f235b084abd2a0d5aa2f7932843877af49ac0","src/traits/text.rs":"8af7d3a0c87cfd8c6d33d6ad47532b431055bbdd395f9110da5630222c23cf93","src/traits/timespan.rs":"52be325a9c061916f34c5b638a07a93b4a14aa89fe365783103d2e06b998f547","src/traits/timing_distribution.rs":"0d35acddd9e35a7f8859cf007162460b5fd0bf06d205cd195ed1c857bbe58c42","src/traits/url.rs":"c27f7add23214ff051078b65b88120b620560d2841a1056c7214d5237e86b9e4","src/traits/uuid.rs":"81322e71c7e847bacaf827a2cd58f6193bdc208355524207f7f38db039da6aa8","src/upload/directory.rs":"b676a05ae19a937e81391d749048fd7f544c629999dd71c8198319b5534da956","src/upload/mod.rs":"5ab0225869cc92824b323e0d0a7d8bcd149dc2bc3a7218cbe8e1b648412ff2c8","src/upload/policy.rs":"0f8e50db8942b75ca871764e3a250d3d382925f752b162c8ac160185c5f6a2d7","src/upload/request.rs":"de5532fc3d18e773330c05fe000643d87b9c4912a2d838099b8783538c5033ed","src/upload/result.rs":"c956266c54595d27d5e8b11abffe28fad5fea82995922618805b66cfdcc21d54","src/util.rs":"ee7500434d9758a320dd410f18d7e18da956591e19d2555db87eef9623e4b916","tests/boolean.rs":"76d6014ff108cb6514d9bceb1b2b14749a55b09921f4595a5e30f1bd3546e9f0","tests/collection_enabled.rs":"85f4b2eb49ac23437ae225ae2c44f354c952c24b7c806e2f2ee5dbe78e02c8db","tests/common/mod.rs":"a8f74c906dccfe747d5cf9dd83dd6e4d1ef25d0402d39a2d74105cddab80e54c","tests/counter.rs":"4c59def10e64de0d7a0241dde0267fd02c828b38be8cc67fba90a76004ca6721","tests/custom_distribution.rs":"41c593a0b4561e21f29d1a5b948de964a866253c58ca76ffefebe370fca150e0","tests/datetime.rs":"ec3c9760e70bb2cbc61ab23281c891bc1ec493c5c545466c29fd13e4f05c2c96","tests/event.rs":"5db675dad1bcbcee0451bfe5e93f05f28d7ef8098d19cd302c8bac262567cf0c","tests/labeled.rs":"3efddb05556e92a372f50a19b025ecf4ccd818c7c477250058db0706eb992079","tests/memory_distribution.rs":"3d9a5b8f99e03f783e3396e4320ee4dc974c895cfef2cec0b14d2a9a9f9b736f","tests/object.rs":"8c35676e04f6ccf54a28764700915e753fc0355bfa5d7804d72caba66fd564cd","tests/ping.rs":"eff68d3b47b04c58d8123214dd66e8d06d11f82ed3fd4f703224f84effb319bb","tests/ping_maker.rs":"64900bb24642127df559fa6ace4c7f0a4a4bf858321874c9b3758039df0ffa04","tests/quantity.rs":"55e7dca346fd1d27f0974b78ca3fb12427cb5da2ee637afc08a54f360f947361","tests/rate.rs":"94a3a7d0ccafea02a991ed9dd038cbfab8a534695b374b1ce6ed81285616e9f6","tests/storage.rs":"990dd1d13b9ffa8af0686977a6ac3502c6befb9eaa83649587e2660f51c596c9","tests/string.rs":"397fcfd27c25f0e81e2a40db3265b0d7dc0dd56b190319c1f86cb1c2c0ed4f9d","tests/string_list.rs":"34efa2afe3e89e6635f21ec9c80650d5816e35e9cb85163d894d600a5b3a4e3a","tests/text.rs":"1d43f6b90a43124311cacf0a6ee16f9e1e9263bcd11fee8b996d6efd81633638","tests/timespan.rs":"3d05739a93f3e0ea7264e8fdea876bd948714e5b44e82b8fd7c0218fdb597bb3","tests/timing_distribution.rs":"072ad950b2162e503150e411119b9a000573538bd2cff93c1c1a3616d1589ef4","tests/uuid.rs":"e0e58614319f5e973126f5b4e68d9289ccd6d65e428aca215bf7dcc8a0504889","uniffi.toml":"6ddc98b686b0925a81abd9d1c769e5c98ac29771b210a1c535931a46dec9a8e3"},"package":"ec64dd5ecb37f04def90b179759c8906c95c895c392b444b5b67f868ffa4bedc"} \ No newline at end of file diff --git a/third_party/rust/glean-core/Cargo.toml b/third_party/rust/glean-core/Cargo.toml index 32ff1696c184..d6e394bd44dc 100644 --- a/third_party/rust/glean-core/Cargo.toml +++ b/third_party/rust/glean-core/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.82" name = "glean-core" -version = "64.1.1" +version = "64.2.0" authors = [ "Jan-Erik Rediger ", "The Glean Team ", @@ -147,6 +147,15 @@ version = "1.0.19" [dependencies.log] version = "0.4.8" +[dependencies.malloc_size_of] +version = "0.2.0" +features = ["once_cell"] +default-features = false +package = "wr_malloc_size_of" + +[dependencies.malloc_size_of_derive] +version = "0.1.3" + [dependencies.once_cell] version = "1.18.0" diff --git a/third_party/rust/glean-core/src/common_metric_data.rs b/third_party/rust/glean-core/src/common_metric_data.rs index f5058d995f76..a016939ffb8c 100644 --- a/third_party/rust/glean-core/src/common_metric_data.rs +++ b/third_party/rust/glean-core/src/common_metric_data.rs @@ -4,6 +4,8 @@ use std::sync::atomic::{AtomicU8, Ordering}; +use malloc_size_of_derive::MallocSizeOf; + use crate::error::{Error, ErrorKind}; use crate::metrics::labeled::validate_dynamic_label; use crate::Glean; @@ -12,7 +14,7 @@ use serde::{Deserialize, Serialize}; /// The supported metrics' lifetimes. /// /// A metric's lifetime determines when its stored data gets reset. -#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default, MallocSizeOf)] #[repr(i32)] // Use i32 to be compatible with our JNA definition #[serde(rename_all = "lowercase")] pub enum Lifetime { @@ -50,7 +52,7 @@ impl TryFrom for Lifetime { } /// The common set of data shared across all different metric types. -#[derive(Default, Debug, Clone, Deserialize, Serialize)] +#[derive(Default, Debug, Clone, Deserialize, Serialize, MallocSizeOf)] pub struct CommonMetricData { /// The metric's name. pub name: String, @@ -73,9 +75,10 @@ pub struct CommonMetricData { pub dynamic_label: Option, } -#[derive(Default, Debug)] +#[derive(Default, Debug, MallocSizeOf)] pub struct CommonMetricDataInternal { pub inner: CommonMetricData, + #[ignore_malloc_size_of = "atomic integers never allocate (bug 1960589)"] pub disabled: AtomicU8, } diff --git a/third_party/rust/glean-core/src/core/mod.rs b/third_party/rust/glean-core/src/core/mod.rs index d60af5363dc9..37c80a167c31 100644 --- a/third_party/rust/glean-core/src/core/mod.rs +++ b/third_party/rust/glean-core/src/core/mod.rs @@ -9,6 +9,7 @@ use std::sync::{Arc, Mutex}; use std::time::Duration; use chrono::{DateTime, FixedOffset}; +use malloc_size_of_derive::MallocSizeOf; use once_cell::sync::OnceCell; use crate::database::Database; @@ -147,7 +148,7 @@ where /// /// In specific language bindings, this is usually wrapped in a singleton and all metric recording goes to a single instance of this object. /// In the Rust core, it is possible to create multiple instances, which is used in testing. -#[derive(Debug)] +#[derive(Debug, MallocSizeOf)] pub struct Glean { upload_enabled: bool, pub(crate) data_store: Option, @@ -159,6 +160,7 @@ pub struct Glean { data_path: PathBuf, application_id: String, ping_registry: HashMap, + #[ignore_malloc_size_of = "external non-allocating type"] start_time: DateTime, max_events: u32, is_first_run: bool, @@ -166,7 +168,9 @@ pub struct Glean { debug: DebugOptions, pub(crate) app_build: String, pub(crate) schedule_metrics_pings: bool, + #[ignore_malloc_size_of = "atomic integers never allocate (bug 1960589)"] pub(crate) remote_settings_epoch: AtomicU8, + #[ignore_malloc_size_of = "TODO: Expose Glean's inner memory allocations (bug 1960592)"] pub(crate) remote_settings_config: Arc>, pub(crate) with_timestamps: bool, pub(crate) ping_schedule: HashMap>, diff --git a/third_party/rust/glean-core/src/core_metrics.rs b/third_party/rust/glean-core/src/core_metrics.rs index c3ed9f2ec458..ceb3e2ae9027 100644 --- a/third_party/rust/glean-core/src/core_metrics.rs +++ b/third_party/rust/glean-core/src/core_metrics.rs @@ -7,10 +7,11 @@ use crate::metrics::{ }; use crate::{CommonMetricData, Lifetime}; +use malloc_size_of_derive::MallocSizeOf; use once_cell::sync::Lazy; /// Metrics included in every ping as `client_info`. -#[derive(Debug, Default)] +#[derive(Debug, Default, MallocSizeOf)] pub struct ClientInfoMetrics { /// The build identifier generated by the CI system (e.g. "1234/A"). pub app_build: String, diff --git a/third_party/rust/glean-core/src/database/mod.rs b/third_party/rust/glean-core/src/database/mod.rs index d12d0305f641..f1f29f938ae4 100644 --- a/third_party/rust/glean-core/src/database/mod.rs +++ b/third_party/rust/glean-core/src/database/mod.rs @@ -16,6 +16,7 @@ use std::time::{Duration, Instant}; use crate::ErrorKind; +use malloc_size_of::MallocSizeOf; use rkv::{StoreError, StoreOptions}; /// Unwrap a `Result`s `Ok` value or do the specified action. @@ -143,6 +144,34 @@ pub struct Database { pub(crate) write_timings: RefCell>, } +impl MallocSizeOf for Database { + fn size_of(&self, _ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + // TODO(bug 1960592): Fill in gaps. + + /* + let mut n = 0; + + n += 0; // self.rkv.size_of(ops) -- not implemented. + n += 0; // self.user_store.size_of(ops) -- not implemented. + + n += self + .ping_lifetime_data + .as_ref() + .map(|_data| { + // TODO(bug 1960592): servo's malloc_size_of implements it for BTreeMap. + //let lock = data.read().unwrap(); + //(*lock).size_of(ops) + 0 + }) + .unwrap_or(0); + + n + */ + + 0 + } +} + impl std::fmt::Debug for Database { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { fmt.debug_struct("Database") diff --git a/third_party/rust/glean-core/src/debug.rs b/third_party/rust/glean-core/src/debug.rs index 1fd02a2b7fd8..405ca0b8a982 100644 --- a/third_party/rust/glean-core/src/debug.rs +++ b/third_party/rust/glean-core/src/debug.rs @@ -27,12 +27,16 @@ use std::env; +use malloc_size_of::MallocSizeOf; +use malloc_size_of_derive::MallocSizeOf; + const GLEAN_LOG_PINGS: &str = "GLEAN_LOG_PINGS"; const GLEAN_DEBUG_VIEW_TAG: &str = "GLEAN_DEBUG_VIEW_TAG"; const GLEAN_SOURCE_TAGS: &str = "GLEAN_SOURCE_TAGS"; const GLEAN_MAX_SOURCE_TAGS: usize = 5; /// A representation of all of Glean's debug options. +#[derive(MallocSizeOf)] pub struct DebugOptions { /// Option to log the payload of pings that are successfully assembled into a ping request. pub log_pings: DebugOption, @@ -83,6 +87,15 @@ pub struct DebugOption Option, V = fn(&T) -> bool> { validation: Option, } +impl MallocSizeOf for DebugOption +where + T: MallocSizeOf, +{ + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + self.env.size_of(ops) + self.value.size_of(ops) + } +} + impl DebugOption where T: Clone, diff --git a/third_party/rust/glean-core/src/event_database/mod.rs b/third_party/rust/glean-core/src/event_database/mod.rs index 3c88c0c61956..82116fe75df4 100644 --- a/third_party/rust/glean-core/src/event_database/mod.rs +++ b/third_party/rust/glean-core/src/event_database/mod.rs @@ -14,6 +14,8 @@ use std::sync::{Mutex, RwLock}; use chrono::{DateTime, FixedOffset, Utc}; +use malloc_size_of::MallocSizeOf; +use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; use serde_json::{json, Value as JsonValue}; @@ -28,7 +30,7 @@ use crate::Result; use crate::{CommonMetricData, CounterMetric, Lifetime}; /// Represents the recorded data for a single event. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, MallocSizeOf)] #[cfg_attr(test, derive(Default))] pub struct RecordedEvent { /// The timestamp of when the event was recorded. @@ -54,7 +56,9 @@ pub struct RecordedEvent { } /// Represents the stored data for a single event. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive( + Debug, Clone, Deserialize, Serialize, PartialEq, Eq, malloc_size_of_derive::MallocSizeOf, +)] struct StoredEvent { #[serde(flatten)] event: RecordedEvent, @@ -99,6 +103,12 @@ pub struct EventDatabase { file_lock: Mutex<()>, } +impl MallocSizeOf for EventDatabase { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + self.event_stores.read().unwrap().size_of(ops) + } +} + impl EventDatabase { /// Creates a new event database. /// diff --git a/third_party/rust/glean-core/src/histogram/exponential.rs b/third_party/rust/glean-core/src/histogram/exponential.rs index a058db529f1a..b19218bfcd52 100644 --- a/third_party/rust/glean-core/src/histogram/exponential.rs +++ b/third_party/rust/glean-core/src/histogram/exponential.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; +use malloc_size_of_derive::MallocSizeOf; use once_cell::sync::OnceCell; use serde::{Deserialize, Serialize}; @@ -56,7 +57,7 @@ fn exponential_range(min: u64, max: u64, bucket_count: usize) -> Vec { /// /// Buckets are pre-computed at instantiation with an exponential distribution from `min` to `max` /// and `bucket_count` buckets. -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, MallocSizeOf)] pub struct PrecomputedExponential { // Don't serialize the (potentially large) array of ranges, instead compute them on first // access. diff --git a/third_party/rust/glean-core/src/histogram/functional.rs b/third_party/rust/glean-core/src/histogram/functional.rs index a8ee11b8135e..b43568006780 100644 --- a/third_party/rust/glean-core/src/histogram/functional.rs +++ b/third_party/rust/glean-core/src/histogram/functional.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; +use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; use super::{Bucketing, Histogram}; @@ -18,7 +19,7 @@ use crate::util::floating_point_context::FloatingPointContext; /// i = ⌊n logbase(𝑥)⌋ /// /// In other words, there are n buckets for each power of `base` magnitude. -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, MallocSizeOf)] pub struct Functional { exponent: f64, } diff --git a/third_party/rust/glean-core/src/histogram/linear.rs b/third_party/rust/glean-core/src/histogram/linear.rs index e578b5f343e7..cbc366eebcd6 100644 --- a/third_party/rust/glean-core/src/histogram/linear.rs +++ b/third_party/rust/glean-core/src/histogram/linear.rs @@ -5,6 +5,7 @@ use std::cmp; use std::collections::HashMap; +use malloc_size_of_derive::MallocSizeOf; use once_cell::sync::OnceCell; use serde::{Deserialize, Serialize}; @@ -36,7 +37,7 @@ fn linear_range(min: u64, max: u64, count: usize) -> Vec { /// /// Buckets are pre-computed at instantiation with a linear distribution from `min` to `max` /// and `bucket_count` buckets. -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, MallocSizeOf)] pub struct PrecomputedLinear { // Don't serialize the (potentially large) array of ranges, instead compute them on first // access. diff --git a/third_party/rust/glean-core/src/histogram/mod.rs b/third_party/rust/glean-core/src/histogram/mod.rs index 88a6d2e53019..16e94bc971b7 100644 --- a/third_party/rust/glean-core/src/histogram/mod.rs +++ b/third_party/rust/glean-core/src/histogram/mod.rs @@ -7,6 +7,7 @@ use std::any::TypeId; use std::collections::HashMap; +use malloc_size_of_derive::MallocSizeOf; use once_cell::sync::OnceCell; use serde::{Deserialize, Serialize}; @@ -21,7 +22,7 @@ mod functional; mod linear; /// Different kinds of histograms. -#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Serialize, Deserialize, MallocSizeOf)] #[serde(rename_all = "lowercase")] pub enum HistogramType { /// A histogram with linear distributed buckets. @@ -59,7 +60,7 @@ impl TryFrom for HistogramType { /// assert_eq!(10, hist.count()); /// assert_eq!(55, hist.sum()); /// ``` -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, MallocSizeOf)] pub struct Histogram { /// Mapping bucket's minimum to sample count. values: HashMap, diff --git a/third_party/rust/glean-core/src/internal_metrics.rs b/third_party/rust/glean-core/src/internal_metrics.rs index 372ec32a9ad5..14660a001ad5 100644 --- a/third_party/rust/glean-core/src/internal_metrics.rs +++ b/third_party/rust/glean-core/src/internal_metrics.rs @@ -4,9 +4,11 @@ use std::borrow::Cow; +use malloc_size_of_derive::MallocSizeOf; + use super::{metrics::*, CommonMetricData, LabeledMetricData, Lifetime}; -#[derive(Debug)] +#[derive(Debug, MallocSizeOf)] pub struct CoreMetrics { pub client_id: UuidMetric, pub first_run_date: DatetimeMetric, @@ -19,7 +21,7 @@ pub struct CoreMetrics { pub distribution_name: StringMetric, } -#[derive(Debug)] +#[derive(Debug, MallocSizeOf)] pub struct AdditionalMetrics { /// The number of times we encountered an IO error /// when writing a pending ping to disk. @@ -199,7 +201,7 @@ impl AdditionalMetrics { } } -#[derive(Debug)] +#[derive(Debug, MallocSizeOf)] pub struct UploadMetrics { pub ping_upload_failure: LabeledMetric, pub discarded_exceeding_pings_size: MemoryDistributionMetric, @@ -323,7 +325,7 @@ impl UploadMetrics { } } -#[derive(Debug)] +#[derive(Debug, MallocSizeOf)] pub struct DatabaseMetrics { pub size: MemoryDistributionMetric, diff --git a/third_party/rust/glean-core/src/internal_pings.rs b/third_party/rust/glean-core/src/internal_pings.rs index 89b4b94fb10d..6aded9139ecd 100644 --- a/third_party/rust/glean-core/src/internal_pings.rs +++ b/third_party/rust/glean-core/src/internal_pings.rs @@ -2,6 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. +use malloc_size_of_derive::MallocSizeOf; + use crate::metrics::PingType; /// Glean-provided pings, all enabled by default. @@ -10,7 +12,7 @@ use crate::metrics::PingType; /// This might get auto-generated when the Rust API lands ([Bug 1579146](https://bugzilla.mozilla.org/show_bug.cgi?id=1579146)). /// /// They are parsed and registered by the platform-specific wrappers, but might be used Glean-internal directly. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, MallocSizeOf)] pub struct InternalPings { pub baseline: PingType, pub metrics: PingType, diff --git a/third_party/rust/glean-core/src/lib.rs b/third_party/rust/glean-core/src/lib.rs index 50da8bb8dfaf..d26693d86a7d 100644 --- a/third_party/rust/glean-core/src/lib.rs +++ b/third_party/rust/glean-core/src/lib.rs @@ -26,6 +26,7 @@ use std::time::Duration; use crossbeam_channel::unbounded; use log::LevelFilter; +use malloc_size_of_derive::MallocSizeOf; use once_cell::sync::{Lazy, OnceCell}; use uuid::Uuid; @@ -113,7 +114,7 @@ static INIT_HANDLES: Lazy>>>> = Lazy::new(|| Arc::new(Mutex::new(Vec::new()))); /// Configuration for Glean -#[derive(Debug, Clone)] +#[derive(Debug, Clone, MallocSizeOf)] pub struct InternalConfiguration { /// Whether upload should be enabled. pub upload_enabled: bool, @@ -135,6 +136,8 @@ pub struct InternalConfiguration { /// Whether Glean should, on init, trim its event storage to only the registered pings. pub trim_data_to_registered_pings: bool, /// The internal logging level. + /// ignore + #[ignore_malloc_size_of = "external non-allocating type"] pub log_level: Option, /// The rate at which pings may be uploaded before they are throttled. pub rate_limit: Option, @@ -158,7 +161,7 @@ pub struct InternalConfiguration { } /// How to specify the rate at which pings may be uploaded before they are throttled. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, MallocSizeOf)] pub struct PingRateLimit { /// Length of time in seconds of a ping uploading interval. pub seconds_per_interval: u64, diff --git a/third_party/rust/glean-core/src/metrics/datetime.rs b/third_party/rust/glean-core/src/metrics/datetime.rs index e04f7fc0512c..91a60050dd61 100644 --- a/third_party/rust/glean-core/src/metrics/datetime.rs +++ b/third_party/rust/glean-core/src/metrics/datetime.rs @@ -16,6 +16,7 @@ use crate::CommonMetricData; use crate::Glean; use chrono::{DateTime, Datelike, FixedOffset, TimeZone, Timelike}; +use malloc_size_of_derive::MallocSizeOf; /// A datetime type. /// @@ -23,7 +24,7 @@ use chrono::{DateTime, Datelike, FixedOffset, TimeZone, Timelike}; pub type ChronoDatetime = DateTime; /// Representation of a date, time and timezone. -#[derive(Clone, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq, MallocSizeOf)] pub struct Datetime { /// The year, e.g. 2021. pub year: i32, diff --git a/third_party/rust/glean-core/src/metrics/labeled.rs b/third_party/rust/glean-core/src/metrics/labeled.rs index fd15e4c18b84..7c350dbb99d3 100644 --- a/third_party/rust/glean-core/src/metrics/labeled.rs +++ b/third_party/rust/glean-core/src/metrics/labeled.rs @@ -4,8 +4,11 @@ use std::borrow::Cow; use std::collections::{hash_map::Entry, HashMap}; +use std::mem; use std::sync::{Arc, Mutex}; +use malloc_size_of::MallocSizeOf; + use crate::common_metric_data::{CommonMetricData, CommonMetricDataInternal}; use crate::error_recording::{record_error, test_get_num_recorded_errors, ErrorType}; use crate::histogram::HistogramType; @@ -86,6 +89,32 @@ pub struct LabeledMetric { label_map: Mutex>>, } +impl ::malloc_size_of::MallocSizeOf for LabeledMetric { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + let map = self.label_map.lock().unwrap(); + + // Copy of `MallocShallowSizeOf` implementation for `HashMap` in `wr_malloc_size_of`. + // Note: An instantiated submetric is behind an `Arc`. + // `size_of` should only be called from a single thread to avoid double-counting. + let shallow_size = if ops.has_malloc_enclosing_size_of() { + map.values() + .next() + .map_or(0, |v| unsafe { ops.malloc_enclosing_size_of(v) }) + } else { + map.capacity() + * (mem::size_of::() + mem::size_of::() + mem::size_of::()) + }; + + let mut map_size = shallow_size; + for (k, v) in map.iter() { + map_size += k.size_of(ops); + map_size += v.size_of(ops); + } + + self.labels.size_of(ops) + self.submetric.size_of(ops) + map_size + } +} + /// Sealed traits protect against downstream implementations. /// /// We wrap it in a private module that is inaccessible outside of this module. diff --git a/third_party/rust/glean-core/src/metrics/mod.rs b/third_party/rust/glean-core/src/metrics/mod.rs index 7f512a3fd179..856b2e6f5f63 100644 --- a/third_party/rust/glean-core/src/metrics/mod.rs +++ b/third_party/rust/glean-core/src/metrics/mod.rs @@ -8,6 +8,7 @@ use std::collections::HashMap; use std::sync::atomic::Ordering; use chrono::{DateTime, FixedOffset}; +use malloc_size_of::MallocSizeOf; use serde::{Deserialize, Serialize}; use serde_json::json; pub use serde_json::Value as JsonValue; @@ -152,6 +153,32 @@ pub enum Metric { Object(String), } +impl MallocSizeOf for Metric { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + match self { + Metric::Boolean(m) => m.size_of(ops), + Metric::Counter(m) => m.size_of(ops), + // Custom distributions are in the same section, no matter what bucketing. + Metric::CustomDistributionExponential(m) => m.size_of(ops), + Metric::CustomDistributionLinear(m) => m.size_of(ops), + Metric::Datetime(_a, b) => b.size_of(ops), + Metric::Experiment(m) => m.size_of(ops), + Metric::Quantity(m) => m.size_of(ops), + Metric::Rate(a, b) => a.size_of(ops) + b.size_of(ops), + Metric::String(m) => m.size_of(ops), + Metric::StringList(m) => m.size_of(ops), + Metric::Timespan(a, b) => a.size_of(ops) + b.size_of(ops), + Metric::TimingDistribution(m) => m.size_of(ops), + Metric::Url(m) => m.size_of(ops), + Metric::Uuid(m) => m.size_of(ops), + Metric::MemoryDistribution(m) => m.size_of(ops), + Metric::Jwe(m) => m.size_of(ops), + Metric::Text(m) => m.size_of(ops), + Metric::Object(m) => m.size_of(ops), + } + } +} + /// A [`MetricType`] describes common behavior across all metrics. pub trait MetricType { /// Access the stored metadata @@ -312,3 +339,34 @@ impl Metric { } } } + +macro_rules! impl_malloc_size_of_for_metric { + ($ty:ident) => { + impl ::malloc_size_of::MallocSizeOf for $ty { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + // Note: `meta` is likely s behind an `Arc`. + // `size_of` should only be called from a single thread to avoid double-counting. + self.meta().size_of(ops) + } + } + }; +} + +impl_malloc_size_of_for_metric!(BooleanMetric); +impl_malloc_size_of_for_metric!(CounterMetric); +impl_malloc_size_of_for_metric!(CustomDistributionMetric); +impl_malloc_size_of_for_metric!(DatetimeMetric); +impl_malloc_size_of_for_metric!(DenominatorMetric); +impl_malloc_size_of_for_metric!(EventMetric); +impl_malloc_size_of_for_metric!(ExperimentMetric); +impl_malloc_size_of_for_metric!(MemoryDistributionMetric); +impl_malloc_size_of_for_metric!(NumeratorMetric); +impl_malloc_size_of_for_metric!(ObjectMetric); +impl_malloc_size_of_for_metric!(QuantityMetric); +impl_malloc_size_of_for_metric!(RateMetric); +impl_malloc_size_of_for_metric!(StringMetric); +impl_malloc_size_of_for_metric!(StringListMetric); +impl_malloc_size_of_for_metric!(TextMetric); +impl_malloc_size_of_for_metric!(TimespanMetric); +impl_malloc_size_of_for_metric!(UrlMetric); +impl_malloc_size_of_for_metric!(UuidMetric); diff --git a/third_party/rust/glean-core/src/metrics/ping.rs b/third_party/rust/glean-core/src/metrics/ping.rs index 1b19d9d41d73..42849e6b240c 100644 --- a/third_party/rust/glean-core/src/metrics/ping.rs +++ b/third_party/rust/glean-core/src/metrics/ping.rs @@ -10,6 +10,7 @@ use crate::ping::PingMaker; use crate::upload::PingPayload; use crate::Glean; +use malloc_size_of_derive::MallocSizeOf; use uuid::Uuid; /// Stores information about a ping. @@ -19,6 +20,7 @@ use uuid::Uuid; #[derive(Clone)] pub struct PingType(Arc); +#[derive(MallocSizeOf)] struct InnerPing { /// The name of the ping. pub name: String, @@ -65,6 +67,14 @@ impl fmt::Debug for PingType { } } +impl ::malloc_size_of::MallocSizeOf for PingType { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + // Note: This is behind an `Arc`. + // `size_of` should only be called from a single thread to avoid double-counting. + self.0.size_of(ops) + } +} + // IMPORTANT: // // When changing this implementation, make sure all the operations are diff --git a/third_party/rust/glean-core/src/metrics/recorded_experiment.rs b/third_party/rust/glean-core/src/metrics/recorded_experiment.rs index 8b9dc35d98f9..a0385e212891 100644 --- a/third_party/rust/glean-core/src/metrics/recorded_experiment.rs +++ b/third_party/rust/glean-core/src/metrics/recorded_experiment.rs @@ -4,11 +4,12 @@ use std::collections::HashMap; +use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; use serde_json::{json, Map as JsonMap, Value as JsonValue}; /// Deserialized experiment data. -#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, MallocSizeOf)] pub struct RecordedExperiment { /// The experiment's branch as set through [`set_experiment_active`](crate::glean_set_experiment_active). pub branch: String, diff --git a/third_party/rust/glean-core/src/metrics/remote_settings_config.rs b/third_party/rust/glean-core/src/metrics/remote_settings_config.rs index c671110cfda1..ae0fbca8cce5 100644 --- a/third_party/rust/glean-core/src/metrics/remote_settings_config.rs +++ b/third_party/rust/glean-core/src/metrics/remote_settings_config.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; +use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; /// Represents a list of metrics and an associated boolean property @@ -17,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// "category.metric_name": true /// } /// ``` -#[derive(Serialize, Deserialize, Debug, Clone, Default)] +#[derive(Serialize, Deserialize, Debug, Clone, Default, MallocSizeOf)] pub struct RemoteSettingsConfig { /// This is a `HashMap` consisting of base_identifiers as keys /// and bool values representing an override for the `disabled` diff --git a/third_party/rust/glean-core/src/metrics/time_unit.rs b/third_party/rust/glean-core/src/metrics/time_unit.rs index 6c68d5dff09e..e0c44fd91144 100644 --- a/third_party/rust/glean-core/src/metrics/time_unit.rs +++ b/third_party/rust/glean-core/src/metrics/time_unit.rs @@ -4,13 +4,14 @@ use std::time::Duration; +use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; use crate::error::{Error, ErrorKind}; /// Different resolutions supported by the time related /// metric types (e.g. DatetimeMetric). -#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq, MallocSizeOf)] #[serde(rename_all = "lowercase")] #[repr(i32)] // use i32 to be compatible with our JNA definition pub enum TimeUnit { diff --git a/third_party/rust/glean-core/src/metrics/timing_distribution.rs b/third_party/rust/glean-core/src/metrics/timing_distribution.rs index 71b1b17e6e59..38a077f2d64f 100644 --- a/third_party/rust/glean-core/src/metrics/timing_distribution.rs +++ b/third_party/rust/glean-core/src/metrics/timing_distribution.rs @@ -8,6 +8,8 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Mutex}; use std::time::Duration; +use malloc_size_of_derive::MallocSizeOf; + use crate::common_metric_data::CommonMetricDataInternal; use crate::error_recording::{record_error, test_get_num_recorded_errors, ErrorType}; use crate::histogram::{Functional, Histogram}; @@ -36,7 +38,7 @@ const MAX_SAMPLE_TIME: u64 = 1000 * 1000 * 1000 * 60 * 10; /// /// Its internals are considered private, /// but due to UniFFI's behavior we expose its field for now. -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, MallocSizeOf)] pub struct TimerId { /// This timer's id. pub id: u64, @@ -65,6 +67,17 @@ pub struct TimingDistributionMetric { start_times: Arc>>, } +impl ::malloc_size_of::MallocSizeOf for TimingDistributionMetric { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + // Note: This is behind an `Arc`. + // `size_of` should only be called on the main thread to avoid double-counting. + self.meta.size_of(ops) + + self.time_unit.size_of(ops) + + self.next_id.size_of(ops) + + self.start_times.lock().unwrap().size_of(ops) + } +} + /// Create a snapshot of the histogram with a time unit. /// /// The snapshot can be serialized into the payload format. diff --git a/third_party/rust/glean-core/src/upload/directory.rs b/third_party/rust/glean-core/src/upload/directory.rs index b11561a41979..303b109c3210 100644 --- a/third_party/rust/glean-core/src/upload/directory.rs +++ b/third_party/rust/glean-core/src/upload/directory.rs @@ -9,6 +9,8 @@ use std::fs::{self, File}; use std::io::{BufRead, BufReader}; use std::path::{Path, PathBuf}; +use malloc_size_of::MallocSizeOf; +use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; use uuid::Uuid; @@ -16,7 +18,7 @@ use super::request::HeaderMap; use crate::{DELETION_REQUEST_PINGS_DIRECTORY, PENDING_PINGS_DIRECTORY}; /// A representation of the data extracted from a ping file, -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, MallocSizeOf)] pub struct PingPayload { /// The ping's doc_id. pub document_id: String, @@ -41,6 +43,28 @@ pub struct PingPayloadsByDirectory { pub deletion_request_pings: Vec<(u64, PingPayload)>, } +impl MallocSizeOf for PingPayloadsByDirectory { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + // SAFETY: We own the referenced `Vec`s and can hand out pointers to them + // to an external function. + let shallow_size = unsafe { + ops.malloc_size_of(self.pending_pings.as_ptr()) + + ops.malloc_size_of(self.deletion_request_pings.as_ptr()) + }; + + let mut n = shallow_size; + for elem in self.pending_pings.iter() { + n += elem.0.size_of(ops); + n += elem.1.size_of(ops); + } + for elem in self.deletion_request_pings.iter() { + n += elem.0.size_of(ops); + n += elem.1.size_of(ops); + } + n + } +} + impl PingPayloadsByDirectory { /// Extends the data of this instance of PingPayloadsByDirectory /// with the data from another instance of PingPayloadsByDirectory. @@ -108,7 +132,7 @@ pub fn process_metadata(path: &str, metadata: &str) -> Option { } /// Manages the pings directories. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, MallocSizeOf)] pub struct PingDirectoryManager { /// Path to the pending pings directory. pending_pings_dir: PathBuf, diff --git a/third_party/rust/glean-core/src/upload/mod.rs b/third_party/rust/glean-core/src/upload/mod.rs index 4769aef8286b..c23c59740523 100644 --- a/third_party/rust/glean-core/src/upload/mod.rs +++ b/third_party/rust/glean-core/src/upload/mod.rs @@ -14,6 +14,7 @@ use std::collections::HashMap; use std::collections::VecDeque; +use std::mem; use std::path::PathBuf; use std::sync::atomic::{AtomicBool, AtomicU32, Ordering}; use std::sync::{Arc, RwLock, RwLockWriteGuard}; @@ -21,6 +22,8 @@ use std::thread; use std::time::{Duration, Instant}; use chrono::Utc; +use malloc_size_of::MallocSizeOf; +use malloc_size_of_derive::MallocSizeOf; use crate::error::ErrorKind; use crate::TimerId; @@ -41,7 +44,7 @@ mod result; const WAIT_TIME_FOR_PING_PROCESSING: u64 = 1000; // in milliseconds -#[derive(Debug)] +#[derive(Debug, MallocSizeOf)] struct RateLimiter { /// The instant the current interval has started. started: Option, @@ -216,6 +219,47 @@ pub struct PingUploadManager { in_flight: RwLock>, } +impl MallocSizeOf for PingUploadManager { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + let shallow_size = { + let queue = self.queue.read().unwrap(); + if ops.has_malloc_enclosing_size_of() { + if let Some(front) = queue.front() { + // SAFETY: The front element is a valid interior pointer and thus valid to pass + // to an external function. + unsafe { ops.malloc_enclosing_size_of(front) } + } else { + // This assumes that no memory is allocated when the VecDeque is empty. + 0 + } + } else { + // If `ops` can't estimate the size of a pointer, + // we can estimate the allocation size by the size of each element and the + // allocated capacity. + queue.capacity() * mem::size_of::() + } + }; + + let mut n = shallow_size + + self.directory_manager.size_of(ops) + // SAFETY: We own this arc and can pass a pointer to it to an external function. + + unsafe { ops.malloc_size_of(self.processed_pending_pings.as_ptr()) } + + self.cached_pings.read().unwrap().size_of(ops) + + self.rate_limiter.as_ref().map(|rl| { + let lock = rl.read().unwrap(); + (*lock).size_of(ops) + }).unwrap_or(0) + + self.language_binding_name.size_of(ops) + + self.upload_metrics.size_of(ops) + + self.policy.size_of(ops); + + let in_flight = self.in_flight.read().unwrap(); + n += in_flight.size_of(ops); + + n + } +} + impl PingUploadManager { /// Creates a new PingUploadManager. /// diff --git a/third_party/rust/glean-core/src/upload/policy.rs b/third_party/rust/glean-core/src/upload/policy.rs index 91467ebd8297..6512648ce91a 100644 --- a/third_party/rust/glean-core/src/upload/policy.rs +++ b/third_party/rust/glean-core/src/upload/policy.rs @@ -4,6 +4,8 @@ //! Policies for ping storage, uploading and requests. +use malloc_size_of_derive::MallocSizeOf; + const MAX_RECOVERABLE_FAILURES: u32 = 3; const MAX_WAIT_ATTEMPTS: u32 = 3; const MAX_PING_BODY_SIZE: usize = 1024 * 1024; // 1 MB @@ -18,7 +20,7 @@ const MAX_PENDING_PINGS_DIRECTORY_SIZE: u64 = 10 * 1024 * 1024; // 10MB const MAX_PENDING_PINGS_COUNT: u64 = 250; /// A struct holding the values for all the policies related to ping storage, uploading and requests. -#[derive(Debug)] +#[derive(Debug, MallocSizeOf)] pub struct Policy { /// The maximum recoverable failures allowed per uploading window. /// diff --git a/third_party/rust/glean/.cargo-checksum.json b/third_party/rust/glean/.cargo-checksum.json index ad172ae53bd1..c86f08b87b76 100644 --- a/third_party/rust/glean/.cargo-checksum.json +++ b/third_party/rust/glean/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"add20d32d164cac0a56ddac41468eaf0b23b9616f32e94a8434f5841d14b3a97","Cargo.toml":"99107d6ac4ef4ff33e2d206e8498875df879001e4621ba94e9d4ccf14267f39c","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"c86cccfb7da1506cfed29cb2ee13d839b7ac7cffdfd70793c9665bb44e0b684f","src/configuration.rs":"de65ab99a26b4547be20803bc195cb50a6ab40b1a3f49a2e6230fed5a9d7a8d8","src/core_metrics.rs":"fef8fb4e5fa57c179836c6eb2cf59278fe3b8b036dbe57b0ff02971b4acd822f","src/lib.rs":"998359d04ba0f71aaa360b8999c716f22c9efaf1ff4e1fdce80f1d3af5e584b0","src/net/http_uploader.rs":"0a94ac3cd87cb021529dee46d537765ab8d923e0f4ac7615225e878d3739e6dc","src/net/mod.rs":"09ba010b03d045fd8a2ccbe4f205c5275bb622bceb34cb81a0aa8f7d33804e2e","src/private/event.rs":"f299c79e4e2acb657f06004f3038bd8909e287719458566bc7f96262d8665e62","src/private/mod.rs":"66e90c41de74d1e80c5d3f49b8f1a86b8396be0b8c4a80f1a28903fe6d105ecf","src/private/object.rs":"7f17a7a658e8f7aa19a6bedf70f60f3f42713316d5d60298d682bb045caaafb7","src/private/ping.rs":"d2fb45e9e178ff6b17aa9c1b5258dfcd2ed91a2b43b44dec826de256ef5e8520","src/system.rs":"d602804a72258bfd65e51c571946631732ee27d81342d8aa406e47fdd241bbfa","src/test.rs":"8ff4d5072d23d9fbf5444e474d21b41a31e86a37e2a25fc2f2a92976e7642cbb","tests/collection_enabled.rs":"3327a949dbdeec493d661261abda68ffa71acc50ab24cba4fde5302749e6f16b","tests/collection_enabled_bin.rs":"d3a6458b84012a447e5cb792f2292a06951ed252fad803b9166b437bacba542c","tests/common/mod.rs":"2fd391c5eb45f56fdfa3261dd631406c67ed36b10b0d5432febe2483da5c9d89","tests/custom_distribution_buffered.rs":"47c13d1f39adf3881e10caa19e0c08235f08958809e234bf37a79d37d7322cd5","tests/init_fails.rs":"ca7fa1b3dd6a21a9e005b7a4f0a18664c4bceb952dd463db8316500f72280d5b","tests/interruptible_shutdown.rs":"3d954bbe47d4f5fd103c51a4ff99f151662143c25c826da9734a00cd215909b9","tests/memory_distribution_buffered.rs":"db487475a5cf17a0864ccf150984ebdd28bf616573772cf678246cc1bdbcbc0f","tests/metric_metadata.rs":"05c947d3decf0a3281378dbb108080a05319ad8f130af5b07f9b049b80e5f04f","tests/near-empty-c0ffee-db.safe.bin":"89afb3bb8fc94430fb0ed0fe55f85f3f8bcc8fd0fed69a9df13cc560294ec9f5","tests/never_init.rs":"51fff5618f6603bc0945d70131698d10a1c6275f43bbc22a2de5807f8a79229f","tests/no_time_to_init.rs":"2ede23df6618ff1cb5ae3b7bbf95900ad0fd92072afa2e0319bf147b4f75cefc","tests/overflowing_preinit.rs":"985e140460a100986fd051ce901b787a3a7a9747a856cd06066b740ac7d2381c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"23b49005402b914e55a0c5c155f30c2662c609f79be78d1385ec25b3600b3547","tests/simple.rs":"15c76a1b5a336fd6abfbdebafc971f5c6a9b75107ddbca65f0031cde3e2886da","tests/test-delayed-ping-data.sh":"4a6db98b4df6b77898ace6a8b4e8b4c60d3e5c44873bbf38c62e83583e27a3ff","tests/test-enabled-pings.sh":"06656e38f63e65475006b107dd6bd179b0cbaa1fad1470de38e679e91a9315a3","tests/test-pending-gets-removed.sh":"e335f2f00fa97a61b6d94e0005fb3b9de8c8db8076111a67ca47d85392039ea9","tests/test-ping-lifetime-flush.sh":"e8f118ea2f6fd973809e38d5e828a03cfccfe0b0f497ccde5ec92d6d1380c071","tests/test-shutdown-blocking.sh":"a44d8d4bbe2ee3ede9e48121150ae7a5386025160c5cef2181ca142232c5fb27","tests/test-thread-crashing.sh":"f3cd0cc8a7b4fe82bef0fe6fbfbbe45fbad6da3afe0f82578bc5cfb2d6527ac6","tests/timing_distribution_buffered.rs":"501f7289c0c28f0ab83838c88b058999b19436d0f2b693be0787513d7b67e06d","tests/timing_distribution_single_sample.rs":"4f9498b6ef29913da0356027efe5f572c81d2f426e8538c068b54a1cfa33c1b8","tests/upload_timing.rs":"b3b9db197bc2ec41556388969a6bf289e7ef19e05b9019bc2bd98c823fcf6ea3","tests/uploader_capabilities.rs":"347f19e534a50a211ea179d6818631270d1b4ec468098e6b6abcde1e4a6a9bca"},"package":"95024f4707705270208e36983976cbac235dd7fc33c9f1cb0dee396ec1ce295d"} \ No newline at end of file +{"files":{"Cargo.lock":"49b2fdc584b3bfa871d157e015ff8b476e39b470a6963e72e6a3528885e7214f","Cargo.toml":"c04f3098d1fafab6dd25d1556d68467e968c7eb4228d28922807e67f3d720076","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"c86cccfb7da1506cfed29cb2ee13d839b7ac7cffdfd70793c9665bb44e0b684f","src/configuration.rs":"de65ab99a26b4547be20803bc195cb50a6ab40b1a3f49a2e6230fed5a9d7a8d8","src/core_metrics.rs":"fef8fb4e5fa57c179836c6eb2cf59278fe3b8b036dbe57b0ff02971b4acd822f","src/lib.rs":"998359d04ba0f71aaa360b8999c716f22c9efaf1ff4e1fdce80f1d3af5e584b0","src/net/http_uploader.rs":"0a94ac3cd87cb021529dee46d537765ab8d923e0f4ac7615225e878d3739e6dc","src/net/mod.rs":"09ba010b03d045fd8a2ccbe4f205c5275bb622bceb34cb81a0aa8f7d33804e2e","src/private/event.rs":"9986dd55abc668533fe3a5c510155fde66446bf8829b323043e5b2b9c8864495","src/private/mod.rs":"66e90c41de74d1e80c5d3f49b8f1a86b8396be0b8c4a80f1a28903fe6d105ecf","src/private/object.rs":"5f3e5d065824ea82aa70156e875a82a079656e07753685d732f4d2aa1be1aedb","src/private/ping.rs":"8ec514e88c1fcba13560522c83e39643edf7d74a3dc733e273984c46c781b2d2","src/system.rs":"d602804a72258bfd65e51c571946631732ee27d81342d8aa406e47fdd241bbfa","src/test.rs":"8ff4d5072d23d9fbf5444e474d21b41a31e86a37e2a25fc2f2a92976e7642cbb","tests/collection_enabled.rs":"3327a949dbdeec493d661261abda68ffa71acc50ab24cba4fde5302749e6f16b","tests/collection_enabled_bin.rs":"d3a6458b84012a447e5cb792f2292a06951ed252fad803b9166b437bacba542c","tests/common/mod.rs":"2fd391c5eb45f56fdfa3261dd631406c67ed36b10b0d5432febe2483da5c9d89","tests/custom_distribution_buffered.rs":"47c13d1f39adf3881e10caa19e0c08235f08958809e234bf37a79d37d7322cd5","tests/init_fails.rs":"ca7fa1b3dd6a21a9e005b7a4f0a18664c4bceb952dd463db8316500f72280d5b","tests/interruptible_shutdown.rs":"3d954bbe47d4f5fd103c51a4ff99f151662143c25c826da9734a00cd215909b9","tests/memory_distribution_buffered.rs":"db487475a5cf17a0864ccf150984ebdd28bf616573772cf678246cc1bdbcbc0f","tests/metric_metadata.rs":"05c947d3decf0a3281378dbb108080a05319ad8f130af5b07f9b049b80e5f04f","tests/near-empty-c0ffee-db.safe.bin":"89afb3bb8fc94430fb0ed0fe55f85f3f8bcc8fd0fed69a9df13cc560294ec9f5","tests/never_init.rs":"51fff5618f6603bc0945d70131698d10a1c6275f43bbc22a2de5807f8a79229f","tests/no_time_to_init.rs":"2ede23df6618ff1cb5ae3b7bbf95900ad0fd92072afa2e0319bf147b4f75cefc","tests/overflowing_preinit.rs":"985e140460a100986fd051ce901b787a3a7a9747a856cd06066b740ac7d2381c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"23b49005402b914e55a0c5c155f30c2662c609f79be78d1385ec25b3600b3547","tests/simple.rs":"15c76a1b5a336fd6abfbdebafc971f5c6a9b75107ddbca65f0031cde3e2886da","tests/test-delayed-ping-data.sh":"4a6db98b4df6b77898ace6a8b4e8b4c60d3e5c44873bbf38c62e83583e27a3ff","tests/test-enabled-pings.sh":"06656e38f63e65475006b107dd6bd179b0cbaa1fad1470de38e679e91a9315a3","tests/test-pending-gets-removed.sh":"e335f2f00fa97a61b6d94e0005fb3b9de8c8db8076111a67ca47d85392039ea9","tests/test-ping-lifetime-flush.sh":"e8f118ea2f6fd973809e38d5e828a03cfccfe0b0f497ccde5ec92d6d1380c071","tests/test-shutdown-blocking.sh":"a44d8d4bbe2ee3ede9e48121150ae7a5386025160c5cef2181ca142232c5fb27","tests/test-thread-crashing.sh":"f3cd0cc8a7b4fe82bef0fe6fbfbbe45fbad6da3afe0f82578bc5cfb2d6527ac6","tests/timing_distribution_buffered.rs":"501f7289c0c28f0ab83838c88b058999b19436d0f2b693be0787513d7b67e06d","tests/timing_distribution_single_sample.rs":"4f9498b6ef29913da0356027efe5f572c81d2f426e8538c068b54a1cfa33c1b8","tests/upload_timing.rs":"b3b9db197bc2ec41556388969a6bf289e7ef19e05b9019bc2bd98c823fcf6ea3","tests/uploader_capabilities.rs":"347f19e534a50a211ea179d6818631270d1b4ec468098e6b6abcde1e4a6a9bca"},"package":"3bbaa151992ac45799a3779a3ff9d9ce1412a91f982b54f95ac85124e96f870c"} \ No newline at end of file diff --git a/third_party/rust/glean/Cargo.lock b/third_party/rust/glean/Cargo.lock index 012b87a0b217..c5ee263a1344 100644 --- a/third_party/rust/glean/Cargo.lock +++ b/third_party/rust/glean/Cargo.lock @@ -242,7 +242,7 @@ dependencies = [ [[package]] name = "glean" -version = "64.1.1" +version = "64.2.0" dependencies = [ "crossbeam-channel", "env_logger", @@ -256,13 +256,14 @@ dependencies = [ "serde_json", "tempfile", "whatsys", + "wr_malloc_size_of", ] [[package]] name = "glean-core" -version = "64.1.1" +version = "64.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca0df94fb37669287b77e8aa300913ad1d14426d7f9e443b0ce1185349c817e" +checksum = "ec64dd5ecb37f04def90b179759c8906c95c895c392b444b5b67f868ffa4bedc" dependencies = [ "android_logger", "bincode", @@ -270,6 +271,7 @@ dependencies = [ "crossbeam-channel", "flate2", "log", + "malloc_size_of_derive", "once_cell", "oslog", "rkv", @@ -279,6 +281,7 @@ dependencies = [ "time", "uniffi", "uuid", + "wr_malloc_size_of", "zeitstempel", ] @@ -419,6 +422,17 @@ version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +[[package]] +name = "malloc_size_of_derive" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f44db74bde26fdf427af23f1d146c211aed857c59e3be750cf2617f6b0b05c94" +dependencies = [ + "proc-macro2", + "syn", + "synstructure", +] + [[package]] name = "memchr" version = "2.7.4" @@ -748,6 +762,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tempfile" version = "3.8.0" @@ -1100,6 +1125,15 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "wr_malloc_size_of" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7c9a8bd19d73e907d610b14b3545475c98ad9581e36f1b67044fd209b66c69" +dependencies = [ + "once_cell", +] + [[package]] name = "zeitstempel" version = "0.1.1" diff --git a/third_party/rust/glean/Cargo.toml b/third_party/rust/glean/Cargo.toml index 4af49a88becf..1b45622f0771 100644 --- a/third_party/rust/glean/Cargo.toml +++ b/third_party/rust/glean/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.82" name = "glean" -version = "64.1.1" +version = "64.2.0" authors = [ "Jan-Erik Rediger ", "The Glean Team ", @@ -115,7 +115,7 @@ path = "tests/uploader_capabilities.rs" version = "0.5" [dependencies.glean-core] -version = "64.1.1" +version = "64.2.0" [dependencies.inherent] version = "1" @@ -123,6 +123,12 @@ version = "1" [dependencies.log] version = "0.4.8" +[dependencies.malloc_size_of] +version = "0.2.0" +features = ["once_cell"] +default-features = false +package = "wr_malloc_size_of" + [dependencies.once_cell] version = "1.18.0" diff --git a/third_party/rust/glean/src/private/event.rs b/third_party/rust/glean/src/private/event.rs index ca8487729fa2..93323b8a3e86 100644 --- a/third_party/rust/glean/src/private/event.rs +++ b/third_party/rust/glean/src/private/event.rs @@ -5,6 +5,8 @@ use inherent::inherent; use std::{collections::HashMap, marker::PhantomData}; +use malloc_size_of::MallocSizeOf; + use glean_core::{metrics::MetricIdentifier, traits}; use crate::{ErrorType, RecordedEvent}; @@ -25,6 +27,12 @@ pub struct EventMetric { extra_keys: PhantomData, } +impl MallocSizeOf for EventMetric { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + self.inner.size_of(ops) + } +} + impl<'a, K> MetricIdentifier<'a> for EventMetric { fn get_identifiers(&'a self) -> (&'a str, &'a str, Option<&'a str>) { self.inner.get_identifiers() diff --git a/third_party/rust/glean/src/private/object.rs b/third_party/rust/glean/src/private/object.rs index 9c4806e47502..3fb7e892eb93 100644 --- a/third_party/rust/glean/src/private/object.rs +++ b/third_party/rust/glean/src/private/object.rs @@ -4,6 +4,8 @@ use std::marker::PhantomData; +use malloc_size_of::MallocSizeOf; + use glean_core::metrics::{JsonValue, MetricIdentifier}; use glean_core::traits; @@ -25,6 +27,12 @@ pub struct ObjectMetric { object_type: PhantomData, } +impl MallocSizeOf for ObjectMetric { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + self.inner.size_of(ops) + } +} + impl<'a, K> MetricIdentifier<'a> for ObjectMetric { fn get_identifiers(&'a self) -> (&'a str, &'a str, Option<&'a str>) { self.inner.get_identifiers() diff --git a/third_party/rust/glean/src/private/ping.rs b/third_party/rust/glean/src/private/ping.rs index 4093b6b18d85..28f5dda4abed 100644 --- a/third_party/rust/glean/src/private/ping.rs +++ b/third_party/rust/glean/src/private/ping.rs @@ -2,7 +2,12 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -use std::sync::{Arc, Mutex}; +use std::{ + mem, + sync::{Arc, Mutex}, +}; + +use malloc_size_of::MallocSizeOf; type BoxedCallback = Box) + Send + 'static>; @@ -19,6 +24,19 @@ pub struct PingType { test_callback: Arc>>, } +impl MallocSizeOf for PingType { + fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize { + self.inner.size_of(ops) + + self + .test_callback + .lock() + .unwrap() + .as_ref() + .map(|cb| mem::size_of_val(cb)) + .unwrap_or(0) + } +} + impl PingType { /// Creates a new ping type. ///