-
Notifications
You must be signed in to change notification settings - Fork 1k
Russian translations #659
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
Russian translations #659
Changes from 1 commit
ab5c936
991152b
7e5ee2c
5680c03
899f850
a00cedc
1fb53bd
411f54d
5438f92
cf615ae
53dcf46
54cc102
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
--- | ||
layout: overview-large | ||
title: ���������������� ������������ ��������� | ||
title: Конфигурирование параллельных коллекций | ||
|
||
disqus: true | ||
|
||
|
@@ -9,15 +9,15 @@ language: ru | |
num: 7 | ||
--- | ||
|
||
## ������������ ����� | ||
## Обслуживание задач | ||
|
||
������������ ��������� ������������� ����������� ������ ������� ������������ ����� ��� ���������� ��������. � ����� ���������� ������ ������������ ��������� ���� ��� ���������� ������ ������������ �����, ������� � �������� �� ������������ � ������������� �������� �� ����������. | ||
Параллельные коллекции предоставляют возможность выбора методов планирования задач при выполнении операций. В числе параметров каждой параллельной коллекции есть так называемый объект обслуживания задач, который и отвечает за планирование и распределение нагрузки на процессоры. | ||
|
||
������ ������ ������������ ����� �������� ������ �� ���������� ���� �������; ����� ���� �� ����������, ��� � ����� ������ ����������� �� ����� ������ ���������. ��������� � ���, ��� ��������� ���������� ���� �������, ����� ������ � ����������� ������ \[[1][1]\]. | ||
Внутри объект обслуживания задач содержит ссылку на реализацию пула потоков; кроме того он определяет, как и когда задачи разбиваются на более мелкие подзадачи. Подробнее о том, как конкретно происходит этот процесс, можно узнать в техническом отчете \[[1][1]\]. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "реализацию" -> я бы убрал There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
� ��������� ����� ��� ������������ ��������� �������� ��������� ���������� ������� ��������� �����. ��������, `ForkJoinTaskSupport` ���������� ����������� "fork-join" ���� � ������������ �� ��������� �� JVM 1.6 ��� ����� �������. ����� ����������� `ThreadPoolTaskSupport` �������� �������� ��� JVM 1.5 � ��� �����, ������� �� ������������ ���� "fork-join". `ExecutionContextTaskSupport` ����� ���������� ��������� ���������� �� ��������� �� `scala.concurrent`, � ���������� ��� �� ��� �������, ��� � `scala.concurrent` (� ����������� �� ������ JVM, ��� ����� ���� ��� "fork-join" ��� "thread pool executor"). �� ��������� ������ ������������ ��������� ����������� ������ ������������ ����� ��������� ����������, ������� ������������ ��������� ���������� ��� �� ��� "fork-join", ��� � API �������� "future". | ||
В настоящее время для параллельных коллекций доступно несколько реализаций объекта поддержки задач. Например, `ForkJoinTaskSupport` реализован посредством "fork-join" пула и используется по умолчанию на JVM 1.6 или более поздних. Менее эффективный `ThreadPoolTaskSupport` является резервом для JVM 1.5 и тех машин, которые не поддерживают пулы "fork-join". `ExecutionContextTaskSupport` берет реализацию контекста исполнения по умолчанию из `scala.concurrent`, и использует тот же пул потоков, что и `scala.concurrent` (в зависимости от версии JVM, это может быть пул "fork-join" или "thread pool executor"). По умолчанию каждой параллельной коллекции назначается именно обслуживание задач контекста выполнения, поэтому параллельные коллекции используют тот же пул "fork-join", что и API объектов "future". | ||
|
||
������� ����� ������������ ����� ��� ������������ ��������� ����� ���: | ||
Сменить метод обслуживания задач для параллельной коллекции можно так: | ||
|
||
scala> import scala.collection.parallel._ | ||
import scala.collection.parallel._ | ||
|
@@ -31,27 +31,27 @@ num: 7 | |
scala> pc map { _ + 1 } | ||
res0: scala.collection.parallel.mutable.ParArray[Int] = ParArray(2, 3, 4) | ||
|
||
����������� ���� ����������� ������������ ��������� �� ������������� "fork-join" ���� � ������� ������������ ������ 2. ��������� ��������� ������������ "thread pool executor" ����� ���: | ||
Приведенное выше настраивает параллельную коллекцию на использование "fork-join" пула с уровнем параллелизма равным 2. Заставить коллекцию использовать "thread pool executor" можно так: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Код выше There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
в два потока. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Мне казалось, "уровень параллелизма" уже устоялся как термин. Или "не стоит его употреблять здесь, даже если и устоялся"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Для меня уровень паралелизма" в русской терминологии(для меня) имеет больше связи с https://ru.wikipedia.org/wiki/%D0%9F%D0%B0%D1%80%D0%B0%D0%BB%D0%BB%D0%B5%D0%BB%D0%B8%D0%B7%D0%BC_%D0%BD%D0%B0_%D1%83%D1%80%D0%BE%D0%B2%D0%BD%D0%B5_%D0%BA%D0%BE%D0%BC%D0%B0%D0%BD%D0%B4 . Может это моя специфика. |
||
|
||
scala> pc.tasksupport = new ThreadPoolTaskSupport() | ||
pc.tasksupport: scala.collection.parallel.TaskSupport = scala.collection.parallel.ThreadPoolTaskSupport@1d914a39 | ||
|
||
scala> pc map { _ + 1 } | ||
res1: scala.collection.parallel.mutable.ParArray[Int] = ParArray(2, 3, 4) | ||
|
||
����� ������������ ��������� �������������, ���� ������� ������������ ����� ����������� �� �������������. ����� ������������ ��������� ����������������� �� ���������� ������������������ ����, ��� ���� ����������� �������� �� ���������-- ������ ������������ ����� ��������� ����������. | ||
Когда параллельная коллекция сериализуется, поле объекта обслуживания задач исключается из сериализуемых. Когда параллельная коллекция восстанавливается из полученной последовательности байт, это поле приобретает значение по умолчанию-- способ обслуживания задач контекста выполнения. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
речь идет про конкретный глобальный обьект ExecutionContext. |
||
|
||
����� ����������� ����������� �������� ��������� �����, ���������� ��������� ����� `TaskSupport` � ����������� ��������� ������: | ||
Чтобы реализовать собственный механизм поддержки задач, достаточно расширить трейт `TaskSupport` и реализовать следующие методы: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. расширить -> унаследовать There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
def execute[R, Tp](task: Task[R, Tp]): () => R | ||
|
||
def executeAndWaitResult[R, Tp](task: Task[R, Tp]): R | ||
|
||
def parallelismLevel: Int | ||
|
||
����� `execute` ��������� ����������� ���������� ������ � ���������� "future" � �������� ������ � �������� ���������� ����������. ����� `executeAndWait` ������ �� �� �����, �� ���������� ��������� ������ ����� ���������� ������. ����� `parallelismLevel` ������ ���������� �������������� ���������� ����, ������� ������������ ����� ���������� ��� ������������ �������. | ||
Метод `execute` планирует асинхронное выполнение задачи и возвращает "future" в качестве ссылки к будущему результату выполнения. Метод `executeAndWait` делает то же самое, но возвращает результат только после завершения задачи. Метод `parallelismLevel` просто возвращает предпочитаемое количество ядер, которые обслуживание задач использует для планирования заданий. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "которые обслуживание задач использует для планирования заданий" -> которое будет использовано для вычислений. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
## ������ | ||
## Ссылки | ||
|
||
1. [On a Generic Parallel Collection Framework, June 2011][1] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В этом параграфе до самого последнего момента не ясно о каком планировании идет речь.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Интрига, что поделать. (Возможно, выход-- переписать абзац полностью, я подумаю, как именно...)