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

feat(pages): Add workers in process pages #579

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Feverqwe
Copy link
Contributor

@Feverqwe Feverqwe commented Oct 22, 2023

Add worker when building pages

@@ -116,7 +116,8 @@ export const REGEXP_INCLUDE_FILE_PATH = /(?<=[(]).+(?=[)])/g;
// Regexp result: authorLogin
export const REGEXP_AUTHOR = /(?<=author:\s).+(?=\r?\n)/g;

export const MIN_CHUNK_SIZE = Number(process.env.MIN_CHUNK_SIZE) || 1000;
export const WORKERS_COUNT = Number(process.env.WORKERS_COUNT) || os.cpus().length - 1;
export const MIN_CHUNK_SIZE = Number(process.env.MIN_CHUNK_SIZE) || 10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мммм. Это зафорсит включение воркеров на большинстве существующих сборок.
Так ведь?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это скорее нижняя граница, сколько файлов попадет в один воркер, теперь это работает через пулл воркеров. Кол-во запущенных воркеров всегда будет равно WORKERS_COUNT , я чуть изменил функцию расчета чанка.


export function mapToObject<V>(map: Map<string, V>) {
const obj: Record<string, V> = {};
map.forEach((value, key) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduce

@@ -139,7 +142,9 @@ function prepareNavigationPaths(parsedToc: YfmToc, dirPath: string) {
storage.set(href, parsedToc);

const navigationPath = _normalizeHref(href);
navigationPaths.push(navigationPath);
if (!navigationPaths.includes(navigationPath)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we need Set

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

Successfully merging this pull request may close these issues.

2 participants