Concurrent Function Upgrade for Enhanced Performance (#4918)

Summary:
Republishing sanjaiyan-dev's PR https://github.com/facebook/flipper/pull/4889 running `git rebase` because of a conflict.

Pull Request resolved: https://github.com/facebook/flipper/pull/4918

Reviewed By: lblasa

Differential Revision: D47294545

Pulled By: passy

fbshipit-source-id: 74904ec6179ed5a3bab6f9b701c3cd769ecad3bf
This commit is contained in:
Sanjaiyan Parthipan
2023-07-17 04:43:14 -07:00
committed by Facebook GitHub Bot
parent c8776175c3
commit 7cef8286f9
10 changed files with 54 additions and 26 deletions

View File

@@ -29,8 +29,10 @@ export async function initializeElectron(
flipperServerConfig: FlipperServerConfig,
electronIpcClient: ElectronIpcClientRenderer,
) {
const electronProcess = await electronIpcClient.send('getProcess');
const electronTheme = await electronIpcClient.send('getNativeTheme');
const [electronProcess, electronTheme] = await Promise.all([
electronIpcClient.send('getProcess'),
electronIpcClient.send('getNativeTheme'),
]);
const execPath = process.execPath || electronProcess.execPath;
const isProduction = !/node_modules[\\/]electron[\\/]/.test(execPath);

View File

@@ -167,6 +167,12 @@ async function getFlipperServer(
await shutdown(UDSconnectionURL);
}
const [homePath, tempPath, desktopPath] = await Promise.all([
electronIpcClient.send('getPath', 'home'),
electronIpcClient.send('getPath', 'temp'),
electronIpcClient.send('getPath', 'desktop'),
]);
const getEmbeddedServer = async () => {
const server = new FlipperServerImpl(
{
@@ -175,11 +181,11 @@ async function getFlipperServer(
gatekeepers: gatekeepers,
paths: {
appPath,
homePath: await electronIpcClient.send('getPath', 'home'),
homePath,
execPath,
staticPath,
tempPath: await electronIpcClient.send('getPath', 'temp'),
desktopPath: await electronIpcClient.send('getPath', 'desktop'),
tempPath,
desktopPath,
},
launcherSettings: await loadLauncherSettings(),
processConfig: loadProcessConfig(env),

View File

@@ -88,6 +88,10 @@ async function start(deviceQuery: string, appName: string, pluginId: string) {
const environmentInfo = await getEnvironmentInfo(staticPath, false, true);
// TODO: initialise FB user manager to be able to do certificate exchange
const [launcherSettings, settings] = await Promise.all([
loadLauncherSettings(argv.launcherSettings),
loadSettings(argv.settingsString),
]);
const server = new FlipperServerImpl(
{
environmentInfo,
@@ -101,9 +105,9 @@ async function start(deviceQuery: string, appName: string, pluginId: string) {
execPath: process.execPath,
desktopPath: `/dev/null`,
},
launcherSettings: await loadLauncherSettings(argv.launcherSettings),
launcherSettings,
processConfig: loadProcessConfig(process.env),
settings: await loadSettings(argv.settingsString),
settings,
validWebSocketOrigins: [],
},
logger,

View File

@@ -210,8 +210,10 @@ export class FlipperServerImpl implements FlipperServer {
}
private async createFolders() {
await mkdirp(flipperDataFolder);
await mkdirp(flipperSettingsFolder);
await Promise.all([
mkdirp(flipperDataFolder),
mkdirp(flipperSettingsFolder),
]);
}
async startDeviceListeners() {

View File

@@ -82,10 +82,15 @@ export const loadSecureServerConfig = async (): Promise<SecureServerConfig> => {
await ensureOpenSSLIsAvailable();
await certificateSetup();
await generateAuthToken();
const [key, cert, ca] = await Promise.all([
fs.readFile(serverKey),
fs.readFile(serverCert),
fs.readFile(caCert),
]);
serverConfig = {
key: await fs.readFile(serverKey),
cert: await fs.readFile(serverCert),
ca: await fs.readFile(caCert),
key,
cert,
ca,
requestCert: true,
rejectUnauthorized: true, // can be false if necessary as we don't strictly need to verify the client
};

View File

@@ -51,6 +51,11 @@ export async function startFlipperServer(
console.warn('Failed to find desktop path, falling back to homedir');
desktopPath = os.homedir();
}
const [launcherSettings, settings] = await Promise.all([
loadLauncherSettings(enableLauncherSettings),
loadSettings(settingsString),
]);
return new FlipperServerImpl(
{
environmentInfo,
@@ -64,9 +69,9 @@ export async function startFlipperServer(
tempPath: os.tmpdir(),
desktopPath: desktopPath,
},
launcherSettings: await loadLauncherSettings(enableLauncherSettings),
launcherSettings,
processConfig: loadProcessConfig(env),
settings: await loadSettings(settingsString),
settings,
validWebSocketOrigins: ['localhost:', 'http://localhost:'],
type,
},

View File

@@ -58,10 +58,10 @@ export default async function runLint(
];
}
const packageJsonSchema = await fs.readJson(packageJsonSchemaPath);
const pluginPackageJsonSchema = await fs.readJson(
pluginPackageJsonSchemaPath,
);
const [packageJsonSchema, pluginPackageJsonSchema] = await Promise.all([
fs.readJson(packageJsonSchemaPath),
fs.readJson(pluginPackageJsonSchemaPath),
]);
const ajv = new Ajv({
allErrors: true,
loadSchema,

View File

@@ -456,9 +456,11 @@ async function buildServerRelease() {
platforms.push(BuildPlatform.WINDOWS);
}
for (const platform of platforms) {
await bundleServerReleaseForPlatform(dir, versionNumber, platform);
}
await Promise.all(
platforms.map((platform) =>
bundleServerReleaseForPlatform(dir, versionNumber, platform),
),
);
}
function nodeArchFromBuildPlatform(platform: BuildPlatform): string {

View File

@@ -168,8 +168,7 @@ export async function moveSourceMaps(
// If we don't move them out of the build folders, they'll get included in the ASAR
// which we don't want.
console.log(`⏭ Removing source maps.`);
await fs.remove(mainBundleMap);
await fs.remove(rendererBundleMap);
await Promise.all([fs.remove(mainBundleMap), fs.remove(rendererBundleMap)]);
}
}

View File

@@ -69,9 +69,12 @@ async function getWorkspacesByRoot(
}
export async function getWorkspaces(): Promise<Workspaces> {
const rootWorkspaces = await getWorkspacesByRoot(rootDir);
const publicPluginsWorkspaces = await getWorkspacesByRoot(publicPluginsDir);
const fbPluginsWorkspaces = await getWorkspacesByRoot(fbPluginsDir);
const [rootWorkspaces, publicPluginsWorkspaces, fbPluginsWorkspaces] =
await Promise.all([
getWorkspacesByRoot(rootDir),
getWorkspacesByRoot(publicPluginsDir),
getWorkspacesByRoot(fbPluginsDir),
]);
const mergedWorkspaces: Workspaces = {
rootPackage: rootWorkspaces!.rootPackage,
packages: [