Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin: Allow configuring delayPingLifetimeIo in Kotlin #2851

Merged
merged 5 commits into from
May 31, 2024

Conversation

badboy
Copy link
Member

@badboy badboy commented May 30, 2024

For some documentation (also in the commit message):

Persist ping-lifetime data after 1000 writes

We now automatically flush data to disk after 1000 writes into the
in-memory ping-lifetime map.

If delay_ping_lifetime_io is set to true, the data is now flushed to
disk in these cases:

  • When persist_ping_lifetime_data is called by the application.
  • At shutdown (that calls persist_ping_lifetime_data) automatically.
  • Every 1000 writes
    • Calling persist_ping_lifetime_data resets the counter!

The downside with delay_ping_lifetime_io is the increased risk of
small windows of data loss:
Data is only persisted so often, so if the process crashes or is killed
in between the data is not persisted to disk and we will never know about.
We do our best to still persist frequently (after enough writes, on ping
submission, on background) and the application could decide to call
persist_ping_lifetime_data on their own as well, e.g. on idle.

@badboy badboy requested a review from a team as a code owner May 30, 2024 15:20
@badboy badboy requested review from rosahbruno and removed request for a team May 30, 2024 15:20
@badboy badboy force-pushed the kotlin/delay-ping-lifetime-flushing branch from b2f47b0 to b8ac855 Compare May 30, 2024 15:20
@badboy badboy requested a review from travis79 May 30, 2024 15:20
@badboy badboy force-pushed the kotlin/delay-ping-lifetime-flushing branch from b8ac855 to bf06ed3 Compare May 30, 2024 15:23
Copy link
Member

@travis79 travis79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please file a bug to document this in the Glean Book, let's not let that cause us to not be able to move fast here, though. Maybe also a follow-up bug to add the PING_LIFETIME_THRESHOLD value to Nimbus so as to be able to tune it without needing to ship code-changes?

glean-core/src/database/mod.rs Outdated Show resolved Hide resolved
// We need to flush the ping lifetime data before a full shutdown.
glean
.storage_opt()
.map(|storage| storage.persist_ping_lifetime_data())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, wonder if this'll uncover any bugs in Desktop tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only one way to figure that out!

glean-core/src/database/mod.rs Outdated Show resolved Hide resolved
@badboy badboy force-pushed the kotlin/delay-ping-lifetime-flushing branch from bf06ed3 to bcc1733 Compare May 30, 2024 16:28
We now automatically flush data to disk after 1000 writes into the
in-memory ping-lifetime map.

If `delay_ping_lifetime_io` is set to true, the data is now flushed to
disk in these cases:
* When `persist_ping_lifetime_data` is called by the application.
* At shutdown (that calls `persist_ping_lifetime_data`) automatically.
* Every 1000 writes
  * Calling `persist_ping_lifetime_data` resets the counter!

The downside with `delay_ping_lifetime_io` is the increased risk of
small windows of data loss:
Data is only persisted so often, so if the process crashes or is killed
in between the data is not persisted to disk and we will never know about.
We do our best to still persist frequently (after enough writes, on ping
submission, on background) and the application could decide to call
`persist_ping_lifetime_data` on their own as well, e.g. on idle.
@badboy badboy force-pushed the kotlin/delay-ping-lifetime-flushing branch from bcc1733 to 8f3ccdd Compare May 30, 2024 16:30
Copy link

codecov bot commented May 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 18.60%. Comparing base (6fd3947) to head (8f3ccdd).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2851   +/-   ##
=======================================
  Coverage   18.60%   18.60%           
=======================================
  Files           1        1           
  Lines          43       43           
=======================================
  Hits            8        8           
  Misses         35       35           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@badboy badboy merged commit d806948 into main May 31, 2024
34 checks passed
@badboy badboy deleted the kotlin/delay-ping-lifetime-flushing branch May 31, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants