Skip to content
This repository has been archived by the owner on May 29, 2021. It is now read-only.

Move all disk I/O off-main #22

Open
garvankeeley opened this issue Oct 4, 2017 · 2 comments
Open

Move all disk I/O off-main #22

garvankeeley opened this issue Oct 4, 2017 · 2 comments

Comments

@garvankeeley
Copy link
Contributor

garvankeeley commented Oct 4, 2017

A single non-concurrent background thread for disk management is a common pattern to use here.
Lends itself well to rate-limiting the I/O.

@garvankeeley
Copy link
Contributor Author

garvankeeley commented Oct 13, 2017

@justindarc I am thinking of working on this next.

It appears straightforward to wrap the entire lib to run on a single concurrent background queue (no big refactor is needed to do this that I can see). I see it as changing the thread it runs on from main to off-main.

The lib only has these public access functions which need to have guarded memory access:

  • Telemetry.default and Telemetry.init() [actually, init functions don't need any changes]
  • Telemetry.add()
  • Telemetry.recordEvent()
  • Telemetry.configuration

Everything else in Telemetry.swift can be internal access level AFAIK.

I don't see any issues with avoiding shared mem access in those functions, add() and recordEvent() could post an immutable object to the background queue. Telemetry.configuration could be changed to a struct and internally accessed only through a getter that returns an immutable copy (and a setter that takes immutable input).

I'll put up a gist to show what I am thinking (and I need to try this hands-on for a bit to better understand this myself).

@justindarc
Copy link
Contributor

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants