Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
663 changes: 536 additions & 127 deletions Cargo.lock

Large diffs are not rendered by default.

2,569 changes: 0 additions & 2,569 deletions DEPENDENCIES.md

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions components/places/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ license = "MPL-2.0"
exclude = ["/android", "/ios"]

[features]
default = ["glean-sym"]
# Enable metric recording through glean-sym (Android only)
glean-sym = ["dep:glean-sym"]
# Use Firefox-on-Glean to publish metrics (Desktop)
# Note: if set, we will not use `glean-sym`
glean-fog = ["dep:glean"]

[dependencies]
sync15 = { path = "../sync15" }
Expand All @@ -34,10 +34,8 @@ sync-guid = { path = "../support/guid", features = ["rusqlite_support", "random"
thiserror = "2"
anyhow = "1.0"
uniffi = { version = "0.31" }

# glean-sym is only used on Android and iOS.
[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]
glean-sym = { git = "https://github.com/mozilla/glean", tag = "v68.0.0", optional = true }
glean = { version = "70", optional = true }
glean-sym = "70"

[dev-dependencies]
error-support = { path = "../support/error", features = ["testing"] }
Expand All @@ -46,4 +44,4 @@ sql-support = { path = "../support/sql" }

[build-dependencies]
uniffi = { version = "0.31", features=["build"]}
glean-build = { git = "https://github.com/mozilla/glean", tag = "v68.0.0" }
glean-build = { git = "https://github.com/mozilla/glean", tag = "v70.0.0" }
120 changes: 2 additions & 118 deletions components/places/android/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,124 +2,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# This file defines the metrics that will be gathered for the "places"
# storage component.
# These are emitted for all users of the component. Additional metrics
# specific to the *syncing* of places are defined in a separate "sync_ping"
# package.
#
# Changes to these metrics require data review, which should take into
# consideration
# the following known consumers of the places component Android bindings:
#
# * Fenix for Android
# This file defines the metrics that are recorded by android for the places component.
# It's no longer used, but we still need to keep it around for probe-scraper reasons.
Comment thread
bendk marked this conversation as resolved.

---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0

places_manager:
run_maintenance_time:
type: timing_distribution
description: Time taken to execute `run_maintenance()`
time_unit: millisecond
bugs:
- https://github.com/mozilla/application-services/issues/5115
data_reviews:
- https://github.com/mozilla/application-services/issues/5122
- https://github.com/mozilla/application-services/issues/5387
- https://github.com/mozilla/application-services/issues/5830
notification_emails:
- synced-client-integrations@mozilla.com
- bdk@mozilla.com
expires: "never"
data_sensitivity:
- technical

run_maintenance_prune_time:
type: timing_distribution
description: Time taken to execute `prune_older_visits()` inside
`run_maintenance()`
time_unit: millisecond
bugs:
- https://github.com/mozilla/application-services/issues/5246
data_reviews:
- https://github.com/mozilla/application-services/issues/5247
- https://github.com/mozilla/application-services/issues/5387
- https://github.com/mozilla/application-services/issues/5830
notification_emails:
- synced-client-integrations@mozilla.com
- bdk@mozilla.com
expires: "never"
data_sensitivity:
- technical

run_maintenance_vacuum_time:
type: timing_distribution
description: Time taken to execute `VACUUM` inside `run_maintenance()`
time_unit: millisecond
bugs:
- https://github.com/mozilla/application-services/issues/5246
data_reviews:
- https://github.com/mozilla/application-services/issues/5247
- https://github.com/mozilla/application-services/issues/5387
- https://github.com/mozilla/application-services/issues/5830
notification_emails:
- synced-client-integrations@mozilla.com
- bdk@mozilla.com
expires: "never"
data_sensitivity:
- technical

run_maintenance_optimize_time:
type: timing_distribution
description: Time taken to execute `PRAGMA optimize` inside
`run_maintenance()`
time_unit: millisecond
bugs:
- https://github.com/mozilla/application-services/issues/5246
data_reviews:
- https://github.com/mozilla/application-services/issues/5247
- https://github.com/mozilla/application-services/issues/5387
- https://github.com/mozilla/application-services/issues/5830
notification_emails:
- synced-client-integrations@mozilla.com
- bdk@mozilla.com
expires: "never"
data_sensitivity:
- technical

run_maintenance_chk_pnt_time:
type: timing_distribution
description: Time taken to execute `PRAGMA_CHECKPOINT` inside
`run_maintenance()`
time_unit: millisecond
bugs:
- https://github.com/mozilla/application-services/issues/5246
data_reviews:
- https://github.com/mozilla/application-services/issues/5247
- https://github.com/mozilla/application-services/issues/5387
- https://github.com/mozilla/application-services/issues/5830
notification_emails:
- synced-client-integrations@mozilla.com
- bdk@mozilla.com
expires: "never"
data_sensitivity:
- technical

db_size_after_maintenance:
type: memory_distribution
description: >
Size of the db after executing `run_maintenance()`
memory_unit: kilobyte
bugs:
- https://github.com/mozilla/application-services/issues/5115
data_reviews:
- https://github.com/mozilla/application-services/issues/5122
- https://github.com/mozilla/application-services/issues/5387
- https://github.com/mozilla/application-services/issues/5830
notification_emails:
- synced-client-integrations@mozilla.com
- bdk@mozilla.com
expires: "never"
data_sensitivity:
- technical
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import mozilla.appservices.places.uniffi.InsertableBookmarkItem
import mozilla.appservices.places.uniffi.InsertableBookmarkSeparator
import mozilla.appservices.places.uniffi.NoteHistoryMetadataObservationOptions
import mozilla.appservices.places.uniffi.PlacesApiException
import mozilla.appservices.places.uniffi.RunMaintenanceOptions
import mozilla.appservices.places.uniffi.SearchResult
import mozilla.appservices.places.uniffi.SqlInterruptHandle
import mozilla.appservices.places.uniffi.TopFrecentSiteInfo
Expand All @@ -34,7 +35,6 @@ import mozilla.telemetry.glean.private.LabeledMetricType
import java.lang.ref.WeakReference
import mozilla.appservices.places.uniffi.PlacesApi as UniffiPlacesApi
import mozilla.appservices.places.uniffi.PlacesConnection as UniffiPlacesConnection
import org.mozilla.appservices.places.GleanMetrics.PlacesManager as PlacesManagerMetrics

typealias Url = String
typealias Guid = String
Expand Down Expand Up @@ -284,25 +284,12 @@ class PlacesWriterConnection internal constructor(conn: UniffiPlacesConnection,

@Suppress("MagicNumber")
override fun runMaintenance(dbSizeLimit: UInt) {
val pruneMetrics = PlacesManagerMetrics.runMaintenanceTime.measure {
val pruneMetrics = PlacesManagerMetrics.runMaintenancePruneTime.measure {
this.conn.runMaintenancePrune(dbSizeLimit, 12U)
}

PlacesManagerMetrics.runMaintenanceVacuumTime.measure {
this.conn.runMaintenanceVacuum()
}

PlacesManagerMetrics.runMaintenanceOptimizeTime.measure {
this.conn.runMaintenanceOptimize()
}

PlacesManagerMetrics.runMaintenanceChkPntTime.measure {
this.conn.runMaintenanceCheckpoint()
}
pruneMetrics
}
PlacesManagerMetrics.dbSizeAfterMaintenance.accumulateSamples(listOf(pruneMetrics.dbSizeAfter.toLong() / 1024))
this.conn.runMaintenance(
RunMaintenanceOptions(
dbSizeLimit = dbSizeLimit,
pruneLimit = 12U,
),
)
}

override fun deleteEverything() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import org.junit.rules.TemporaryFolder
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.mozilla.appservices.places.GleanMetrics.PlacesManager as PlacesManagerMetrics

@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE)
Expand Down Expand Up @@ -624,15 +623,6 @@ class PlacesConnectionTest {
}
}

@Test
fun testRunMaintenanceMetrics() {
assertNull(PlacesManagerMetrics.runMaintenanceTime.testGetValue())
assertNull(PlacesManagerMetrics.dbSizeAfterMaintenance.testGetValue())
db.runMaintenance()
assertEquals(1, PlacesManagerMetrics.runMaintenanceTime.testGetValue()!!.values.values.sum())
assertEquals(1, PlacesManagerMetrics.dbSizeAfterMaintenance.testGetValue()!!.values.values.sum())
}

@Test
fun testRegisterWithSyncmanager() {
val syncManager = SyncManager()
Expand Down
26 changes: 14 additions & 12 deletions components/places/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use glean_build::Builder;

fn main() {
uniffi::generate_scaffolding("./src/places.udl").unwrap();
build_metrics();
}

fn build_metrics() {
let format = if cfg!(feature = "glean-fog") {
"rust"
} else {
"rust_sym"
};

if let Ok("android" | "ios") = std::env::var("CARGO_CFG_TARGET_OS")
.as_ref()
.map(String::as_str)
{
Builder::default()
.file("metrics.yaml")
.format("rust_sym")
.generate()
.expect("Error generating Glean Rust bindings");
}
glean_build::Builder::default()
.file("metrics.yaml")
.format(format)
.generate()
.expect("Error generating Glean Rust bindings");
}
Loading
Loading