Simple-storage limitations and startup performance

Skip to first unread message

David Bruant

Mar 17, 2016, 7:22:51 AM3/17/16

This story begins with an addon I'm working on [1]. Among other things,
the addon stores credentials (... used to and will again soon...) in the
simple-storage. I've had 2 problems being reported to me that seem related:
1) for some people (all on OSX from the reports I received), the addon
acts as if there was no credentials
2) the addon slows Firefox startup down significantly (to the point
where a user decided to uninstall the addon)

Reading the simple-storage code [2], I discovered a few things :
a) File read errors are silently swallowed without even a warning in the
console (there is an interesting comment on that matter)
b) Doing `const storage = require("sdk/simple-storage").storage`
triggers blocking I/O at startup
c) There is a write happening on disk every 5mins (by default) even if
no change occured

The problem 1) that I face is certainly related to a). This, in an of
itself, means that I won't be using simple-storage anymore as my users
face a problem I am unarmed to work against (they cannot even send me a
screenshot of the browser console).

Problem 2) may be related to b). This line of course is super
easy/natural to write and has consequences it probably shouln't have. It
would be possible to rewrite simple-storage as a Proxy [3] and wait to
do the blocking I/O only on first property access (and lazily write only
when a property is changed instead of forcing it every 5 minutes).
However, I also realize that problem 2) may be also related to the
CommonJS loader which, I imagine is doing sequential blocking I/O which
isn't fantastic at startup.

Would you have advice on how to measure the impact of the addon on
startup perf? and advice on how to improve it if loading CommonJS module
indeed does have an impact on performance?



Reply all
Reply to author
0 new messages