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

fix: improve the loading bot performance #5853

Merged
merged 66 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
17d9568
fix: loadBot will do full index twice
lei9444 Feb 19, 2021
af8c0ea
Merge branch 'main' into loadtime
lei9444 Feb 19, 2021
bad02a8
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
lei9444 Feb 20, 2021
6c6a8d9
move lg parse background
lei9444 Feb 20, 2021
e5e3e1d
Merge branch 'main' into loadtime
lei9444 Feb 20, 2021
9bf9193
Merge branch 'main' into loadtime
lei9444 Feb 24, 2021
ea15a22
add loading ui for single index
lei9444 Feb 24, 2021
696eb01
Merge branch 'main' into loadtime
lei9444 Feb 25, 2021
744d420
fix unit tests
lei9444 Feb 25, 2021
52118c7
Merge branch 'main' into loadtime
lei9444 Feb 25, 2021
796fd8c
Merge branch 'main' into loadtime
lei9444 Feb 25, 2021
db76f9a
fix unit tests
lei9444 Feb 25, 2021
ae77ff5
split the lg and qna state
lei9444 Feb 26, 2021
30bae0e
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
lei9444 Feb 26, 2021
1725d8b
add lu and qna to this solution
lei9444 Mar 2, 2021
e58a6f4
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
lei9444 Mar 2, 2021
19437f1
update set order
lei9444 Mar 2, 2021
c171f84
update lu lsp with worker
lei9444 Mar 2, 2021
9505867
udpate the lint
lei9444 Mar 2, 2021
c468f94
udpate the worker
lei9444 Mar 2, 2021
010e476
add await for async
lei9444 Mar 2, 2021
1e868ed
Merge branch 'main' into loadtime
lei9444 Mar 2, 2021
cfd5f8f
update the lsp function
lei9444 Mar 2, 2021
aa614a5
Merge branch 'main' into loadtime
lei9444 Mar 2, 2021
cb2f727
Merge branch 'main' into loadtime
cwhitten Mar 2, 2021
67f393b
Merge branch 'main' into loadtime
lei9444 Mar 3, 2021
eaf27c8
Merge branch 'main' into loadtime
lei9444 Mar 3, 2021
1197ed2
remove settimeout
lei9444 Mar 3, 2021
13a7a66
Merge branch 'main' into loadtime
lei9444 Mar 3, 2021
04037b4
refactor creating folding range in LG and LU
cosmicshuai Mar 3, 2021
dc8556d
Merge branch 'loadtime' of https://github.com/lei9444/BotFramework-Co…
cosmicshuai Mar 3, 2021
d3ccd66
Merge branch 'main' into loadtime
lei9444 Mar 3, 2021
3b1be57
add unit tests
lei9444 Mar 3, 2021
e5d7ea6
Merge branch 'loadtime' of https://github.com/lei9444/BotFramework-Co…
lei9444 Mar 3, 2021
7dd34d3
fix comments
lei9444 Mar 4, 2021
302ed4c
Merge branch 'main' into loadtime
lei9444 Mar 4, 2021
68b36a5
Merge branch 'main' into loadtime
lei9444 Mar 5, 2021
4679d80
Merge branch 'main' into loadtime
lei9444 Mar 5, 2021
2103fb3
Merge branch 'main' into loadtime
a-b-r-o-w-n Mar 5, 2021
c769ce4
fix some comments
lei9444 Mar 8, 2021
d68a57e
Merge branch 'main' into loadtime
lei9444 Mar 8, 2021
c84428c
fix comments and add unit tests
lei9444 Mar 8, 2021
9d8f90b
Merge branch 'main' into loadtime
lei9444 Mar 8, 2021
6bf1706
fix unit tests
lei9444 Mar 8, 2021
2d98a40
Merge branch 'main' into loadtime
lei9444 Mar 8, 2021
cd67635
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
lei9444 Mar 8, 2021
7f6ff09
Merge branch 'main' into loadtime
lei9444 Mar 8, 2021
380915b
Merge branch 'main' into loadtime
srinaath Mar 9, 2021
feefe2e
Merge branch 'main' into loadtime
beyackle Mar 9, 2021
47c3df9
Merge branch 'main' into loadtime
boydc2014 Mar 10, 2021
a758c84
Merge branch 'main' into loadtime
cwhitten Mar 10, 2021
b7e6c17
Merge branch 'main' into loadtime
hatpick Mar 11, 2021
81203a4
Merge branch 'main' into loadtime
lei9444 Mar 15, 2021
0907c1e
Merge branch 'main' into loadtime
lei9444 Mar 16, 2021
e980467
update lu and qna
lei9444 Mar 16, 2021
8d52658
Merge branch 'main' of https://github.com/microsoft/BotFramework-Comp…
lei9444 Mar 17, 2021
2f43b6f
Merge remote-tracking branch 'upstream/main' into loadtime
cosmicshuai Mar 22, 2021
bbb514a
update the comparator
lei9444 Mar 22, 2021
7aca46d
Merge branch 'main' into loadtime
cwhitten Mar 22, 2021
3437219
Merge branch 'main' into loadtime
lei9444 Mar 24, 2021
15ceb59
Merge branch 'main' into loadtime
lei9444 Mar 25, 2021
34dfba7
Merge branch 'main' into loadtime
lei9444 Mar 25, 2021
3d6f212
fix conflict
lei9444 Mar 25, 2021
0764548
Merge branch 'main' into loadtime
lei9444 Mar 29, 2021
52d145a
fix conflict
lei9444 Mar 29, 2021
af3eb2f
Merge branch 'main' into loadtime
lei9444 Mar 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
projectMetaDataState,
botProjectIdsState,
dialogState,
luFilesState,
luFilesSelectorFamily,
} from '../../../src/recoilModel';

const state = {
Expand Down Expand Up @@ -63,7 +63,7 @@ describe('Root Bot External Service', () => {
set(dialogState({ projectId: state.projectId, dialogId: state.dialogs[0].id }), state.dialogs[0]);
set(dialogState({ projectId: state.projectId, dialogId: state.dialogs[1].id }), state.dialogs[1]);
set(botProjectIdsState, state.botProjectIdsState);
set(luFilesState(state.projectId), state.luFiles);
set(luFilesSelectorFamily(state.projectId), state.luFiles);
set(projectMetaDataState(state.projectId), state.projectMetaDataState);
set(settingsState(state.projectId), state.settings);
set(dispatcherState, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
formDialogSchemaIdsState,
jsonSchemaFilesState,
lgFilesSelectorFamily,
luFilesState,
luFilesSelectorFamily,
schemasState,
settingsState,
} from '../../../../src/recoilModel';
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('<DiagnosticList/>', () => {
set(currentProjectIdState, state.projectId);
set(botProjectIdsState, [state.projectId]);
set(dialogIdsState(state.projectId), []);
set(luFilesState(state.projectId), state.luFiles);
set(luFilesSelectorFamily(state.projectId), state.luFiles);
set(lgFilesSelectorFamily(state.projectId), state.lgFiles);
set(jsonSchemaFilesState(state.projectId), state.jsonSchemaFiles);
set(botDiagnosticsState(state.projectId), state.diagnostics);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { renderHook } from '@botframework-composer/test-utils/lib/hooks';
import * as React from 'react';
import { useSetRecoilState } from 'recoil';
import { RecoilRoot } from 'recoil';
import { act } from '@botframework-composer/test-utils/lib/hooks';

import { useAssetsParsingState } from '../../../src/pages/design/useAssetsParsingState';
import {
currentProjectIdState,
designPageLocationState,
lgFileState,
localeState,
luFileState,
qnaFileState,
} from '../../../src/recoilModel';

const state = {
luFiles: [
{
id: 'test.en-us',
isContentUnparsed: false,
},
],
lgFiles: [
{
id: 'test.en-us',
isContentUnparsed: false,
},
],
qnaFiles: [
{
id: 'test.en-us',
isContentUnparsed: false,
},
],
focusPath: '',
locale: 'en-us',
projectId: 'test',
};

const useRecoilTestHook = (projectId: string) => {
const setLuFile = useSetRecoilState(luFileState({ projectId, luFileId: 'test.en-us' }));
const isParsing = useAssetsParsingState(state.projectId);

return { setLuFile, isParsing };
};

describe('useAssetsParsingState', () => {
let result;
beforeEach(() => {
const initRecoilState = ({ set }) => {
set(designPageLocationState(state.projectId), { dialogId: 'test' });
set(currentProjectIdState, state.projectId);
set(localeState(state.projectId), 'en-us');
set(luFileState({ projectId: state.projectId, luFileId: 'test.en-us' }), state.luFiles);
set(lgFileState({ projectId: state.projectId, lgFileId: 'test.en-us' }), state.luFiles);
set(qnaFileState({ projectId: state.projectId, qnaFileId: 'test.en-us' }), state.luFiles);
};

const wrapper = (props: { children?: React.ReactNode }) => {
const { children } = props;
return <RecoilRoot initializeState={initRecoilState}>{children}</RecoilRoot>;
};

const rendered = renderHook(() => useRecoilTestHook(state.projectId), {
wrapper,
});
result = rendered.result;
});

it('should be true if the file content is unparsed', async () => {
const { setLuFile } = result.current;
expect(result.current.isParsing).toBeFalsy();
act(() => {
setLuFile({
id: 'test.en-us',
isContentUnparsed: true,
});
});
expect(result.current.isParsing).toBeTruthy();
act(() => {
setLuFile({
id: 'test.en-us',
isContentUnparsed: false,
});
});
expect(result.current.isParsing).toBeFalsy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { renderWithRecoil } from '../../testUtils';
import {
localeState,
dialogsSelectorFamily,
qnaFilesState,
qnaFilesSelectorFamily,
settingsState,
schemasState,
dispatcherState,
Expand Down Expand Up @@ -59,7 +59,7 @@ const initRecoilState = ({ set }) => {
set(currentProjectIdState, state.projectId);
set(localeState(state.projectId), state.locale);
set(dialogsSelectorFamily(state.projectId), state.dialogs);
set(qnaFilesState(state.projectId), state.qnaFiles);
set(qnaFilesSelectorFamily(state.projectId), state.qnaFiles);
set(settingsState(state.projectId), state.settings);
set(schemasState(state.projectId), mockProjectResponse.schemas);
set(dispatcherState, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { renderWithRecoil } from '../../testUtils';
import {
localeState,
dialogsSelectorFamily,
luFilesState,
luFilesSelectorFamily,
settingsState,
schemasState,
currentProjectIdState,
Expand Down Expand Up @@ -50,7 +50,7 @@ const initRecoilState = ({ set }) => {
set(currentProjectIdState, state.projectId);
set(localeState(state.projectId), state.locale);
set(dialogsSelectorFamily(state.projectId), state.dialogs);
set(luFilesState(state.projectId), state.luFiles);
set(luFilesSelectorFamily(state.projectId), state.luFiles);
set(settingsState(state.projectId), state.settings);
set(schemasState(state.projectId), mockProjectResponse.schemas);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
formDialogSchemaIdsState,
jsonSchemaFilesState,
lgFilesSelectorFamily,
luFilesState,
luFilesSelectorFamily,
schemasState,
settingsState,
} from '../../../src/recoilModel';
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('<DiagnosticList/>', () => {
set(currentProjectIdState, state.projectId);
set(botProjectIdsState, [state.projectId]);
set(dialogIdsState(state.projectId), []);
set(luFilesState(state.projectId), state.luFiles);
set(luFilesSelectorFamily(state.projectId), state.luFiles);
set(lgFilesSelectorFamily(state.projectId), state.lgFiles);
set(jsonSchemaFilesState(state.projectId), state.jsonSchemaFiles);
set(botDiagnosticsState(state.projectId), state.diagnostics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
formDialogSchemaIdsState,
jsonSchemaFilesState,
lgFilesSelectorFamily,
luFilesState,
qnaFilesState,
luFilesSelectorFamily,
qnaFilesSelectorFamily,
schemasState,
settingsState,
} from '../../../src/recoilModel';
Expand Down Expand Up @@ -142,9 +142,9 @@ describe('<Diagnostics/>', () => {
set(botProjectIdsState, [state.projectId]);
set(dialogIdsState(state.projectId), ['test']);
set(dialogState({ projectId: state.projectId, dialogId: 'test' }), state.dialogs[0]);
set(luFilesState(state.projectId), state.luFiles);
set(luFilesSelectorFamily(state.projectId), state.luFiles);
set(lgFilesSelectorFamily(state.projectId), state.lgFiles);
set(qnaFilesState(state.projectId), state.qnaFiles);
set(qnaFilesSelectorFamily(state.projectId), state.qnaFiles);
set(jsonSchemaFilesState(state.projectId), state.jsonSchemaFiles);
set(botDiagnosticsState(state.projectId), state.diagnostics);
set(settingsState(state.projectId), state.settings);
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/__tests__/shell/luApi.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as React from 'react';
import { RecoilRoot } from 'recoil';

import { useLuApi } from '../../src/shell/luApi';
import { localeState, luFilesState, dispatcherState, currentProjectIdState } from '../../src/recoilModel';
import { localeState, luFilesSelectorFamily, dispatcherState, currentProjectIdState } from '../../src/recoilModel';
import { Dispatcher } from '../../src/recoilModel/dispatchers';

jest.mock('../../src/recoilModel/parsers/luWorker', () => {
Expand Down Expand Up @@ -34,7 +34,7 @@ describe('use luApi hooks', () => {
const initRecoilState = ({ set }) => {
set(currentProjectIdState, state.projectId);
set(localeState(state.projectId), 'en-us');
set(luFilesState(state.projectId), state.luFiles);
set(luFilesSelectorFamily(state.projectId), state.luFiles);
set(dispatcherState, (current: Dispatcher) => ({
...current,
updateLuFile: updateLuFileMockMock,
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/__tests__/shell/triggerApi.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { RecoilRoot } from 'recoil';
import { useTriggerApi } from '../../src/shell/triggerApi';
import {
localeState,
luFilesState,
luFilesSelectorFamily,
lgFilesSelectorFamily,
dialogsSelectorFamily,
schemasState,
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('use triggerApi hooks', () => {
const initRecoilState = ({ set }) => {
set(currentProjectIdState, state.projectId);
set(localeState(state.projectId), 'en-us');
set(luFilesState(state.projectId), state.luFiles);
set(luFilesSelectorFamily(state.projectId), state.luFiles);
set(lgFilesSelectorFamily(state.projectId), state.lgFiles);
set(dialogsSelectorFamily(state.projectId), state.dialogs);
set(schemasState(state.projectId), state.schemas);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Text, Tips, Links, nameRegex, LUIS_REGIONS } from '../../constants';
import { FieldConfig, useForm } from '../../hooks/useForm';
import { getReferredQnaFiles } from '../../utils/qnaUtil';
import { getLuisBuildLuFiles } from '../../utils/luUtil';
import { luFilesState, qnaFilesState, dialogsSelectorFamily } from '../../recoilModel';
import { luFilesSelectorFamily, qnaFilesSelectorFamily, dialogsSelectorFamily } from '../../recoilModel';

// -------------------- Styles -------------------- //
const textFieldLabel = css`
Expand Down Expand Up @@ -91,8 +91,8 @@ interface IPublishDialogProps {
export const PublishDialog: React.FC<IPublishDialogProps> = (props) => {
const { isOpen, onDismiss, onPublish, botName, config, projectId } = props;
const dialogs = useRecoilValue(dialogsSelectorFamily(projectId));
const luFiles = useRecoilValue(luFilesState(projectId));
const qnaFiles = useRecoilValue(qnaFilesState(projectId));
const luFiles = useRecoilValue(luFilesSelectorFamily(projectId));
const qnaFiles = useRecoilValue(qnaFilesSelectorFamily(projectId));
const qnaConfigShow = getReferredQnaFiles(qnaFiles, dialogs).length > 0;
const luConfigShow = getLuisBuildLuFiles(luFiles, dialogs).length > 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useRecoilValue } from 'recoil';

import { TriggerFormData, TriggerFormDataErrors } from '../../utils/dialogUtil';
import { userSettingsState } from '../../recoilModel/atoms';
import { currentDialogState, dialogsSelectorFamily, localeState, luFilesState } from '../../recoilModel';
import { currentDialogState, dialogsSelectorFamily, localeState, luFilesSelectorFamily } from '../../recoilModel';
import { isRegExRecognizerType, resolveRecognizer$kind } from '../../utils/dialogValidator';
import TelemetryClient from '../../telemetry/TelemetryClient';

Expand Down Expand Up @@ -50,7 +50,7 @@ export const TriggerCreationModal: React.FC<TriggerCreationModalProps> = (props)
const isRegEx = isRegExRecognizerType(dialogFile);
const regexIntents = (dialogFile?.content?.recognizer as RegexRecognizer)?.intents ?? [];

const luFiles = useRecoilValue(luFilesState(projectId));
const luFiles = useRecoilValue(luFilesSelectorFamily(projectId));
const locale = useRecoilValue(localeState(projectId));
const currentDialog = useRecoilValue(currentDialogState({ projectId, dialogId }));
const luFile = luFiles.find((f) => f.id === `${currentDialog?.id}.${locale}`);
Expand Down
6 changes: 3 additions & 3 deletions Composer/packages/client/src/hooks/useResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { useRef } from 'react';
import { lgImportResolverGenerator } from '@bfc/shared';
import { useRecoilValue } from 'recoil';

import { dialogsSelectorFamily, luFilesState, localeState, qnaFilesState } from '../recoilModel';
import { dialogsSelectorFamily, luFilesSelectorFamily, localeState, qnaFilesSelectorFamily } from '../recoilModel';
import { lgFilesSelectorFamily } from '../recoilModel/selectors/lg';

export const useResolvers = (projectId: string) => {
const dialogs = useRecoilValue(dialogsSelectorFamily(projectId));
const luFiles = useRecoilValue(luFilesState(projectId));
const luFiles = useRecoilValue(luFilesSelectorFamily(projectId));
const lgFiles = useRecoilValue(lgFilesSelectorFamily(projectId));
const locale = useRecoilValue(localeState(projectId));
const qnaFiles = useRecoilValue(qnaFilesState(projectId));
const qnaFiles = useRecoilValue(qnaFilesSelectorFamily(projectId));

const lgFilesRef = useRef(lgFiles);
lgFilesRef.current = lgFiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { NeutralColors, SharedColors } from '@uifabric/fluent-theme';
import {
dispatcherState,
settingsState,
luFilesState,
qnaFilesState,
luFilesSelectorFamily,
qnaFilesSelectorFamily,
botDisplayNameState,
dialogsWithLuProviderSelectorFamily,
} from '../../recoilModel';
Expand Down Expand Up @@ -167,8 +167,8 @@ export const RootBotExternalService: React.FC<RootBotExternalServiceProps> = (pr
const rootqnaKey = groupQnAKey.root;

const dialogs = useRecoilValue(dialogsWithLuProviderSelectorFamily(projectId));
const luFiles = useRecoilValue(luFilesState(projectId));
const qnaFiles = useRecoilValue(qnaFilesState(projectId));
const luFiles = useRecoilValue(luFilesSelectorFamily(projectId));
const qnaFiles = useRecoilValue(qnaFilesSelectorFamily(projectId));
const botName = useRecoilValue(botDisplayNameState(projectId));
const isLUISKeyNeeded = BotIndexer.shouldUseLuis(dialogs, luFiles);
const isQnAKeyNeeded = BotIndexer.shouldUseQnA(dialogs, qnaFiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { TextField } from 'office-ui-fabric-react/lib/TextField';
import {
dispatcherState,
settingsState,
luFilesState,
qnaFilesState,
luFilesSelectorFamily,
qnaFilesSelectorFamily,
dialogsSelectorFamily,
botDisplayNameState,
} from '../../recoilModel';
Expand Down Expand Up @@ -66,8 +66,8 @@ export const SkillBotExternalService: React.FC<SkillBotExternalServiceProps> = (
const skillQnAKey = groupQnAKey[projectId];

const dialogs = useRecoilValue(dialogsSelectorFamily(projectId));
const luFiles = useRecoilValue(luFilesState(projectId));
const qnaFiles = useRecoilValue(qnaFilesState(projectId));
const luFiles = useRecoilValue(luFilesSelectorFamily(projectId));
const qnaFiles = useRecoilValue(qnaFilesSelectorFamily(projectId));

const isLUISKeyNeeded = BotIndexer.shouldUseLuis(dialogs, luFiles);
const isQnAKeyNeeded = BotIndexer.shouldUseQnA(dialogs, qnaFiles);
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/src/pages/design/Modals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
schemasState,
showCreateDialogModalState,
localeState,
qnaFilesState,
qnaFilesSelectorFamily,
displaySkillManifestState,
brokenSkillInfoState,
brokenSkillRepairCallbackState,
Expand All @@ -42,7 +42,7 @@ type ModalsProps = {
projectId: string;
};
const Modals: React.FC<ModalsProps> = ({ projectId = '' }) => {
const qnaFiles = useRecoilValue(qnaFilesState(projectId));
const qnaFiles = useRecoilValue(qnaFilesSelectorFamily(projectId));
const schemas = useRecoilValue(schemasState(projectId));

const displaySkillManifestNameIdentifier = useRecoilValue(displaySkillManifestState);
Expand Down
Loading