Use mutex library instead of repeatedly chaining promises

Summary:
I noticed that after a long-running flipper session, 11% of the memory was composed of millions of tiny PromiseReaction records (https://github.com/domenic/promises-unwrapping#promisereaction-records).

It seems this method of chaining promises meant that it was forming a linked list of these from the most recent, back to the very first invocation.

Instead of using a home-rolled lock, I'm replacing it with an actual library. Haven't verified the fix, but this seems like a better approach regardless.

Reviewed By: passy

Differential Revision: D15853570

fbshipit-source-id: 1626d9f25cba809794b13ee920bdec2cd1d4b874
This commit is contained in:
John Knox
2019-06-17 09:09:03 -07:00
committed by Facebook Github Bot
parent 347487a328
commit ef1eb41dba
3 changed files with 52 additions and 0 deletions

46
flow-typed/npm/async-mutex_vx.x.x.js vendored Normal file
View File

@@ -0,0 +1,46 @@
// flow-typed signature: 3f26bdb86dbdfe57e7bf6c11d85e98e4
// flow-typed version: <<STUB>>/async-mutex_v0.1.3/flow_v0.100.0
/**
* This is an autogenerated libdef stub for:
*
* 'async-mutex'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'async-mutex' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'async-mutex/lib/index' {
declare module.exports: any;
}
declare module 'async-mutex/lib/Mutex' {
declare module.exports: any;
}
declare module 'async-mutex/lib/MutexInterface' {
declare module.exports: any;
}
// Filename aliases
declare module 'async-mutex/lib/index.js' {
declare module.exports: $Exports<'async-mutex/lib/index'>;
}
declare module 'async-mutex/lib/Mutex.js' {
declare module.exports: $Exports<'async-mutex/lib/Mutex'>;
}
declare module 'async-mutex/lib/MutexInterface.js' {
declare module.exports: $Exports<'async-mutex/lib/MutexInterface'>;
}