Excel でのマルチ スレッド再計算Multithreaded recalculation in Excel

適用されますExcel 2013 |。Office 2013 |Visual StudioApplies to: Excel 2013 | Office 2013 | Visual Studio

Microsoft Office Excel 2007 �́A���[�N�V�[�g�̃}���`�X���b�h�Čv�Z (MTR) �g�p���� Excel �̍ŏ��̃o�[�W�����ł����B�R���s���[�^�[�̃v���Z�b�T����v���Z�b�T�̃R�A���Ɋ֌W�Ȃ��A�Čv�Z���ɍő� 1024 �‚̓������s�X���b�h��g�p����悤�� Excel ��\���ł��܂��BMicrosoft Office Excel 2007 was the first version of Excel to use multithreaded recalculation (MTR) of worksheets. You can configure Excel to use up to 1024 concurrent threads when recalculating, regardless of the number of processors or processor cores on the computer.

注意

���ꂼ��̃X���b�h�ɂ͊֘A����I�y���[�e�B���O �V�X�e���̃I�[�o�[�w�b�h�����邽�߁A�K�v�ȏ�ɑ����̃X���b�h��g�p����悤�� Excel ��\�����Ă͂����܂���BThere is an operating system overhead associated with each thread, so you should not configure Excel to use more threads than you need.

�R���s���[�^�[�ɕ����̃v���Z�b�T�܂��̓v���Z�b�T�̃R�A�����ڂ���Ă���ꍇ�́A�I�y���[�e�B���O �V�X�e�����A�œK�ȕ��@�Ńv���Z�b�T�ɃX���b�h����蓖�Ă܂��BIf the computer has multiple processors or processor cores, the operating system takes responsibility for allocating the threads to the processors in the most efficient way.

Excel の MTR の概要Excel MTR overview

Excel �́A�v�Z�`�F�[���̊e�����̂����A�ʁX�̃X���b�h�ŕ��s�I�ɍČv�Z�ł��镔������ʂ��悤�Ƃ��܂��B���̔��ɒP���ȃc���[ (x �� y �́Ay �� x �ɂ݈̂ˑ����Ă��邱�Ƃ�Ӗ�����) �́A���̗������Ă��܂��BExcel tries to identify parts of the calculation chain that can be recalculated concurrently on different threads. The following very simple tree (where x ← y means y only depends on x) shows an example of this.

�} 1. �ʁX�̃X���b�h�ł̓������s�v�ZFigure 1. Calculating concurrently on different threads

異なるスレッドで同時に計算します。Calculating concurrently on different threads

A1 �̌v�Z���ςނƁA����̃X���b�h�ł� A2�AA3 �̏��Ɍv�Z���ł���悤�ɂȂ�A�����ɁA�������̃X���b�h�ł� B1�AC1 �̏��Ɍv�Z���ł���悤�ɂȂ�܂� (���ׂẴZ�����X���b�h �Z�[�t�ł���Ɖ��肵�Ă��܂�)�BAfter A1 is calculated, A2 and then A3 can be calculated on one thread, while B1 and then C1 can be calculated on another, assuming all the cells are thread safe.

注意

�X���b�h �Z�[�t�ȃZ���Ƃ����p��́A�X���b�h �Z�[�t�Ȋ֐��݂̂�܂ރZ����Ӗ����܂��B�X���b�h �Z�[�t�ł��邩�ǂ����ɂ‚ẮA[Excel �ŃX���b�h �Z��t�ƌ��Ȃ������ (���Ȃ���Ȃ����)�ŏڂ���������܂��BThe term thread-safe cell means a cell that only contains thread-safe functions. What is and is not thread-safe is detailed What Is and Is Not Considered Thread Safe by Excel.

�قƂ�ǂ̎��p�I�ȃu�b�N�ɂ́A���̗����͂邩�ɕ��G�Ȉˑ��֌W�c���[���܂܂�Ă��܂��B����ɁA�Z���̍Čv�Z�ɂ����鎞�Ԃ͌v�Z����������܂ŕs���ł���A�֐��̈����ɂ���đ啝�ɈقȂ邱�Ƃ�����܂��B�ŗǂ̌��ʂ𓾂邽�߂ɁAExcel �́A����ȏ�̍œK�����ł��Ȃ��Ȃ�܂ŁA�v�Z�̂��тɌv�Z�����̉��P����݂܂��BMost practical workbooks contain far more complex dependency trees than this example. Moreover, the recalculation time of a cell cannot be known until a calculation is done and can vary greatly depending on the functions' arguments. To obtain the best results, Excel tries to improve the calculation order on every calculation until no further optimization is possible.

Excel �́A���̍��ڂ̎��s�ɒP��̃��C�� �X���b�h��g�p���܂��BExcel uses a single main thread to run or execute the following:

  • �g�ݍ��݃R�}���hBuilt-in commands

  • XLL �R�}���hXLL commands

  • XLL アドイン マネージャー インターフェイスの関数 (xlAutoOpen関数というように)XLL Add-in Manager interface functions (xlAutoOpen function, and so on)

  • Microsoft Visual Basic for Applications (VBA) �̃��[�U�[��`�R�}���h (�ʏ�̓}�N���ƌĂ΂�܂�)Microsoft Visual Basic for Applications (VBA) user-defined commands (often referred to as macros)

  • VBA �̃��[�U�[��`�֐�VBA user-defined functions

  • �g�ݍ��݂̃X���b�h �Z�[�t�ł͂Ȃ����[�N�V�[�g�֐� (���̃Z�N�V�����Ɉꗗ������܂�)Built-in thread-unsafe worksheet functions (see the next section for a list)

  • XLM マクロ シートのユーザー定義コマンドとユーザー定義関数XLM macro sheet user-defined commands and functions

  • COM �A�h�C���̃R�}���h�Ɗ֐�COM add-in commands and functions

  • ����t���t�H�[�}�b�g����̊֐��Ɖ��Z�qFunctions and operators within conditional formatting expressions

  • ワークシートの式で使用された定義済みの名前定義内の関数と演算子Functions and operators within defined name definitions used in worksheet formulas

  • �����ҏW�{�b�N�X��̎��̋����I�ȕ]�� ( F9 �L�[��g�p)The forced evaluation of an expression in the formula-edit box using the F9 key

���ׂẴ��[�N�V�[�g�̐����́A�֐����X���b�h �Z�[�t���ǂ����Ɋ֌W�Ȃ��A���C�� �X���b�h�ŕ]������܂��B�������A�����̃X���b�h��g�p����悤�� Excel ��\�����Ă���ꍇ������܂��B���[�U�[�������̃X���b�h��g�p����悤�Ɏw�肷��ƁA�X���b�h �Z�[�t�̃Z���ɂ͒lj��̃X���b�h���g�p����܂��B���ו��U�̊ϓ_����̍������ɓK���ꍇ�́A���C�� �X���b�h��X���b�h �Z�[�t�ȃZ���Ɏg�p����܂��BAll worksheet formulas, regardless of whether the functions are thread safe or not, are evaluated on the main thread unless Excel is configured to use more than one thread. When the user specifies that more than one thread should be used, the additional threads are used for thread-safe cells. Note that the main thread may still be used for thread-safe cells when it makes sense from a load-balancing point of view.

�����ł����x�������ׂ����ƂƂ��āAExcel �͈�x�ɕ����̃R�}���h����s���܂���B���̂��߁A�X���b�h ���[�J�� �������ƃN���e�B�J�� �Z�N�V�����̎g�p�ȂǁA�X���b�h �Z�[�t�Ȋ֐���L�q����Ƃ��Ɠ��l�̒��ӂ𕥂��K�v�͂���܂���BIt is worth restating that Excel does not run more than one command at once, so you do not need to employ the same precautions as when you are writing thread-safe functions, such as the use of thread-local memory and critical sections.

何し、は見なされませんスレッド セーフ Excel を使用してWhat is and is not considered thread safe by Excel

Excel �ł́A���̂�̂������X���b�h �Z�[�t�ƌ��Ȃ���܂��BExcel only considers the following as thread safe:

  • Excel �̒P�����Z�q�Ɠ񍀉��Z�q�̂��ׂ�All unary and binary operators in Excel.

  • Excel 2007 �ȍ~�̑g�ݍ��݃��[�N�V�[�g�֐��̂قƂ�ǂ��ׂ� (��O�̈ꗗ��Q��)Almost all built-in worksheet functions starting in Excel 2007 (see exceptions list)

  • �X���b�h �Z�[�t�Ƃ��Ė����I�ɓo�^����Ă��� XLL �A�h�C���֐�XLL add-in functions that have been explicitly registered as thread-safe.

���̑g�ݍ��݃��[�N�V�[�g�֐��́A�X���b�h �Z�[�t�ł͂���܂���BThe built-in worksheet functions that are not thread safe are:

  • PHONETICPHONETIC

  • CELL ("����" �܂��� "�A�h���X" �̂ǂ��炩�̈������g�p���ꂽ�ꍇ)CELL when either the "format" or "address" argument is used

  • INDIRECTINDIRECT

  • GETPIVOTDATAGETPIVOTDATA

  • CUBEMEMBERCUBEMEMBER

  • CUBEVALUECUBEVALUE

  • CUBEMEMBERPROPERTYCUBEMEMBERPROPERTY

  • CUBESETCUBESET

  • CUBERANKEDMEMBERCUBERANKEDMEMBER

  • CUBEKPIMEMBERCUBEKPIMEMBER

  • CUBESETCOUNTCUBESETCOUNT

  • ADDRESS (5 �Ԗڂ̃p�����[�^�[ "sheet_name" ���w�肳��Ă���ꍇ)ADDRESS where the fifth parameter (the sheet_name) is given

  • データベースのいずれかのピボット テーブルを参照する関数 (DSUMDAVERAGEというように)Any database function (DSUM, DAVERAGE, and so on) that refers to a pivot table

  • エラーです。タイプERROR.TYPE

  • HYPERLINKHYPERLINK

���m�ɂ��邽�߂ɁA�X���b�h �Z�[�t�ƌ��Ȃ���Ȃ���̂�����܂��BTo be explicit, the following are considered to be unsafe:

  • VBA �̃��[�U�[��`�֐�VBA user-defined functions

  • COM �A�h�C���̃��[�U�[��`�֐�COM add-in user-defined functions

  • XLM �}�N�� �V�[�g�̃��[�U�[��`�֐�XLM macro-sheet user-defined functions

  • �����I�ɃX���b�h �Z�[�t�Ƃ��ēo�^����Ă��Ȃ� XLL �A�h�C���֐�XLL add-in functions not explicitly registered as thread safe

���̑���Ɗ֐��̓X���b�h �Z�[�t�Ƃ͌��Ȃ���܂���B�܂��A�X���b�h �Z�[�t�Ƃ��ēo�^���� XLL �֐�����Ăяo�����Ǝ��s���܂��BThe implications are that the following operations and functions are not thread-safe, and fail if they are called from an XLL function registered as thread safe:

  • 呼び出しを XLM 情報関数では、たとえば、 xlfGetCell (取得します。セル)。Calls to XLM information functions, for example, xlfGetCell (GET.CELL).

  • XlfSetName (SET.NAME) を定義または xll ファイルの内部名を削除する場合に呼び出されます。Calls to xlfSetName (SET.NAME) to define or delete XLL-internal names.

  • �X���b�h �Z�[�t�ł͂Ȃ����[�U�[��`�֐��� xlUDF ��g�p�����Ăяo���BCalls to thread-unsafe user-defined functions using xlUDF.

  • 式のスレッドの安全でない関数が含まれているかの定義には、スレッドの安全でない関数が含まれている定義済みの名前が含まれているxlfEvaluate関数を呼び出します。Calls to the xlfEvaluate function for expressions that contain thread-unsafe functions or that contain defined names whose definitions contain thread-unsafe functions.

  • �u���[�N�����N���A���� xlAbort �֐��̌Ăяo���BCalls to the xlAbort function to clear a break condition.

  • �v�Z����Ă��Ȃ��Z���̎Q�Ƃ̒l��擾���� xlCoerce �֐��̌Ăяo���BCalls to the xlCoerce function to get the value of an uncalculated cell reference.

注意

XLL ���[�N�V�[�g�֐� ( xlcSave �Ȃ�) �ł́AC API �R�}���h�̌Ăяo�������‚���Ă��܂���B���̊֐����X���b�h �Z�[�t�Ƃ��ēo�^����Ă��邩�ǂ����͊֌W����܂���BXLL worksheet functions are not permitted to call C API commands, for example, xlcSave, regardless of whether they have been registered as thread safe or not.

�X���b�h �Z�[�t�Ƃ��Đ錾���ꂽ XLL �֐��� XLM ���֐���Ăяo���Ȃ����Ƃ�A�v�Z����Ă��Ȃ��Z����Q�Ƃł��Ȃ����Ƃ���AExcel �� �}�N�� �V�[�g�Ɠ����Ƃ��ēo�^���� XLL �֐���X���b�h �Z�[�t�Ƃ��Ă�o�^���邱�Ƃ���‚��܂���B���̂��߁A xlCoerce ��g�p���Čv�Z����Ă��Ȃ��Z���̎Q�Ƃ̒l��擾���悤�Ƃ���ƁA xlretUncalced �G���[�Ŏ��s���܂��BXLM ���֐��̌Ăяo���́A xlretFailed �G���[�Ŏ��s���܂��B���̑��̑O�q�����|�C���g�́AExcel C API �ɓ������ꂽ�G���[ �R�[�h xlretNotThreadSafe �Ŏ��s���܂��BGiven that XLL functions declared as thread safe cannot call XLM information functions or reference uncalculated cells, Excel does not permit XLL functions that are registered as macro sheet equivalents to also be registered as thread safe. Therefore attempting to get the value of an uncalculated cell reference using xlCoerce fails with an xlretUncalced error. Calling an XLM information function fails with an xlretFailed error. The other points listed previously fail with an error code introduced in the Excel C API: xlretNotThreadSafe.

C API ��p�̃R�[���o�b�N�֐��́A���ׂăX���b�h �Z�[�t�ł��BThe C API-only call-back functions are all thread safe:

  • xlCoerce (�������A�v�Z����Ă��Ȃ��Z���̎Q�Ƃ̋����^�ϊ��͎��s���܂�)xlCoerce (except although coercion of uncalculated cell references fails)

  • xlFreexlFree

  • xlStackxlStack

  • xlSheetIdxlSheetId

  • xlSheetNmxlSheetNm

  • xlAbort (�u���[�N�����N���A���邽�߂Ɏg�p����ꍇ������܂�)xlAbort (except when used to clear a break condition)

  • xlGetInstxlGetInst

  • xlGetHwndxlGetHwnd

  • xlGetBinaryNamexlGetBinaryName

  • xlDefineBinaryNamexlDefineBinaryName

�B��̗�O�� xlSet �֐��ł��B�����̏ꍇ�A���̊֐��̓R�}���h�Ɠ����ł��邽�߁A�ǂ̂悤�ȃ��[�N�V�[�g�֐������Ăяo���ł��܂���BThe one exception is the xlSet function, which is, in any case, a command-equivalent and so cannot be called from any worksheet function.

XLL ���[�N�V�[�g�֐��́A�X���b�h �Z�[�t�Ƃ��� Excel �ɓo�^�ł��܂��B����ɂ��A���̊֐������S�ɕ����̃X���b�h�œ����ɌĂяo���邱�Ƃ� Excel �ɒʒm���܂��B�������A���ꂪ�����ł��邱�Ƃ͎����Ŋm�F����K�v������܂��B�X���b�h �Z�[�t�Ƃ��ēo�^�����֐��̓��삪�X���b�h �Z�[�t�łȂ��ƁAExcel ���s����ɂȂ邱�Ƃ�����܂��BAn XLL worksheet function can be registered with Excel as thread safe. This tells Excel that the function can be called safely and simultaneously on multiple threads, although you must make sure this is really the case. You can possibly destabilize Excel if a function registered as thread safe then behaves unsafely.

としてスレッド セーフな XLL 関数を登録します。Registering XLL functions as thread safe

�X���b�h �Z�[�t�Ȋ֐���L�q����Ƃ��ɁA�J���҂��]���K�v�̂��郋�[���͎��̂Ƃ���ł��BThe rules that a developer must obey when writing thread-safe functions are as follows:

  • �X���b�h �Z�[�t�ł͂Ȃ��”\���̂���ʂ� DLL ��̃��\�[�X��Ăяo���Ȃ��BDo not call resources in other DLLs that may not be thread safe.

  • C API �܂��� COM ��ʂ��ăX���b�h �Z�[�t�łȂ��Ăяo����s��Ȃ��BDo not make any thread-unsafe calls via the C API or COM.

  • �N���e�B�J�� �Z�N�V������g�p���āA�����̃X���b�h�œ����Ɏg�p�����”\���̂��郊�\�[�X��ی삷��BProtect resources that could be used simultaneously by more than one thread using critical sections.

  • �X���b�h�ŗL�̃X�g���[�W�ɂ̓X���b�h ���[�J�� ��������g�p���āA�֐���̐ÓI�ϐ��̓X���b�h ���[�J���ϐ��ɒu��������BUse thread-local memory for thread-specific storage, and replace static variables within functions with thread-local variables.

Excel �ɂ́A��� 1 �‚̐������ۂ����܂��B�X���b�h �Z�[�t�Ȋ֐���}�N�� �V�[�g�Ɠ����Ȃ�̂Ƃ��ēo�^���邱�Ƃ͂ł��܂���B���̂��߁AXLM ���֐���Ăяo�����Ƃ�A�Čv�Z����Ă��Ȃ��Z���̒l��擾���邱�Ƃ͂ł��܂���BExcel imposes an additional restriction: thread-safe functions cannot be registered as macro-sheet equivalents, and therefore cannot call XLM information functions or get the values of un-recalculated cells.

メモリの競合Memory contention

�}���`�X���b�h �V�X�e���́A2 �‚̊�{�I�Ȗ��ɑΏ�����K�v������܂��BMultithreaded systems must address two fundamental issues:

  • �����̃X���b�h���ǂݏ������郁�����̕ی���@�BHow to protect memory that must be read from, or written to, by more than one thread.

  • ���s���̃X���b�h�Ɋ֘A�t�����ăv���C�x�[�g�ɂȂ郁�����̍쐬���@�ƃA�N�Z�X���@�BHow to create and access memory that is associated with, and so private to, the executing thread.

Windows �I�y���[�e�B���O �V�X�e���� Windows �\�t�g�E�F�A�J���L�b�g (SDK) �ɂ́A����痼���ɂ��ꂼ��Ή�����c�[���ł���N���e�B�J�� �Z�b�V�����ƃX���b�h ���[�J�� �X�g���[�W (TLS) API ��g�p�ł��܂��B�ڍׂɂ‚��ẮA�uExcel �̃������Ǘ��v��Q�Ƃ��Ă��������BThe Windows operating system and Windows Software Development Kit (SDK) provide tools for both of these: critical sections and the thread-local storage (TLS) API respectively. For more information, see Memory Management in Excel.

�ŏ��̖��́A���Ƃ��΁A2 �‚̃��[�N�V�[�g�֐� (�܂��͓����֐��� 2 �‚̓������s�C���X�^���X) �� 1 �‚� DLL �v���W�F�N�g��̃O���[�o���ϐ��ɃA�N�Z�X���� (�܂��͕ύX�������) �K�v������ꍇ�ɔ������܂��B���̂悤�ȃO���[�o���ϐ��́A�O���[�o���ɃA�N�Z�X�ł���N���X �I�u�W�F�N�g�̃C���X�^���X��ɉB����Ă��邱�Ƃ�����_�ɒ��ӂ��K�v�ł��BThe first issue can arise, for example, when two worksheet functions (or two simultaneously running instances of the same function) need to access or modify a global variable in a DLL project. Remember that such a global variable might be hidden in a globally accessible instance of a class object.

2 �–ڂ̖��́A���Ƃ��΁A���[�N�V�[�g�֐����֐��{�̂̃R�[�h��ŐÓI�ȕϐ��܂��̓I�u�W�F�N�g�錾���Ă���ꍇ�ɔ������܂��BC/C++ �R���p�C���́A���ׂẴX���b�h���g�p���� 1 �‚̃R�s�[�݂̂�쐬���܂��B���̂��߁A�֐��̈���̃C���X�^���X���l��ύX���Ă���Ƃ��ɁA�ʂ̃X���b�h�̂������̃C���X�^���X�͒l���ȑO�ɐݒ肳�ꂽ��e���Ƒz�肵�Ă���”\��������Ƃ������Ƃł��BThe second issue can arise, for example, when a worksheet function declares a static variable or object within the function body code. The C/C++ compiler only creates a single copy that all threads use. This means one instance of the function could change the value, while another on a different thread might be assuming the value is what it previously set.

MTR のサンプル アプリケーションExample applications of MTR

���[�N�V�[�g�֐���G�N�X�|�[�g���� XLL �́AExcel �̃}���`�X���b�h�Čv�Z (MTR) �𗘗p�ł��܂� (�Y������֐����A�X���b�h �Z�[�t�łȂ��A�N�V��������s����K�v���Ȃ��ꍇ)�B����ɂ��AExcel �̓u�b�N��”\�Ȍ���Z���ԂɍČv�Z�ł���悤�ɂȂ邽�߁A������A�v���P�[�V�����ɂƂ��Ė]�܂�����ԂɂȂ�܂��BAny XLL that exports worksheet functions can take advantage of multithreaded recalculation (MTR) in Excel provided that those functions do not need to perform thread-unsafe actions. This enables Excel to recalculate workbooks that depend on them as quickly as possible and is therefore desirable whatever the application.

具体的には、MTR は、ユーザー定義関数 (Udf) 目的の結果を取得する外部プロセスを呼び出すこと自体を呼び出しているブックの再計算時間に大きな影響を及ぼします。Specifically, MTR has an enormous impact on the recalculation time of workbooks that call user-defined functions (UDFs) that themselves call external processes to obtain the desired result. 具体的には、UDF を同時に多数の要求を処理できるリモート サーバーを呼び出すと関数呼び出しを含むブックを検討してください。In particular, consider a UDF that calls a remote server that can process many requests simultaneously and a workbook containing many calls to that function. ブックの再計算がシングル スレッドの場合、各 UDF を呼び出すし、リモート サーバーにする必要があります完了次のいずれかをする前に。If recalculation of the workbook is single-threaded, each call to the UDF, and so to the remote server, must complete before the next one can be made. これは、一度に多数の呼び出しを処理するサーバーの能力を浪費します。This wastes the server's ability to process many calls at once. ブックの再計算は、マルチ スレッドは、同時にまたは連続で、Excel は複数の呼び出しをことができます。If recalculation of the workbook is multithreaded, Excel can make multiple calls at the same time or in rapid succession.

�T�[�o�[�Ɠ����� (���̐��� N �Ƃ���) �̃X���b�h��g�p����悤�� Excel ���\������Ă��āA�u�b�N�̈ˑ��֌W�c���[�̃g�|���W�ɂ��̗]�n������΁A���v�̍Čv�Z���Ԃ̓V���O�� �X���b�h�̌v�Z���Ԃ� 1/N �߂��܂ŒZ�k�����”\��������܂��B����́A�u�b�N����s���Ă���N���C�A���g �R���s���[�^�[���v���Z�b�T�� 1 �‚������ڂ��Ă���ꍇ�ɂ���Ă͂܂�”\��������܂��B���ɁA�T�[�o�[�̌Ăяo���ɂ����鎞�Ԃ��A�T�[�o�[�ŌĂяo����������鎞�Ԃ���Z���ꍇ�ɓ��Ă͂܂�܂��BIf Excel is configured to use the same number of threads as the server—call it N—and the topology of the dependency tree of the workbook permits it, the total recalculation time could be reduced to something approaching 1/N of the single-threaded calculation time. This may be true even where the client computer (on which the workbook is running) only has one processor, especially where the time taken to make the call to the server is small relative to the time it takes the server to process the call.

�lj��̃X���b�h�ɂ́A���ꂼ��ɃI�y���[�e�B���O �V�X�e���̃I�[�o�[�w�b�h�����݂��܂��B���̂��߁A����̃u�b�N�Ɠ���̃T�[�o�[����уN���C�A���g �R���s���[�^�[�ɂ‚��āA���炩�̎����� Excel �ɐݒ肷��œK�ȃX���b�h������‚���K�v������܂��BThere is operating system overhead for each additional thread. Therefore some experimentation might be required for a given workbook and a given server and client computer to find the optimum number of threads Excel should be told to use.

���Ƃ��΁AExcel ����s���Ă���V���O�� �v���Z�b�T�̃R���s���[�^�[�ƁA1,000 �‚̃Z����܂�ł���u�b�N�ɂ‚��čl���Ă݂܂��傤�B����́AUDF ��Ăяo���A���� UDF �� 1 �ˆȏ�̃����[�g �T�[�o�[��Ăяo���܂��B1,000 �‚̃Z�������݂Ɉˑ����Ă��Ȃ��Ɖ��肷��ƁAExcel �͌㑱�̌Ăяo������s���邽�߂ɌĂяo���̊�����ҋ@����K�v�͂���܂��� (���̐���́A���̗�ɉe����^���邱�ƂȂ��A������x�̊ɘa���”\�ł�)�B�T�[�o�[�� 100 ���̗v���̓����������”\�ŁAExcel �� 100 �X���b�h��g�p����悤�ɍ\������Ă���ƁA���s���Ԃ� 1 �X���b�h�݂̂�g�p�����ꍇ�� 1/100 �߂��ɂ܂ŒZ�k�ł��܂��BExcel ���e�X���b�h�ɃZ������蓖�Ă邽�߂ɂ�����I�[�o�[�w�b�h�ƁA�I�y���[�e�B���O �V�X�e���� 100 �X���b�h��Ǘ����邽�߂ɂ�����I�[�o�[�w�b�h�ɂ��A���ۂɂ́A����قǂ܂ł̎��ԒZ�k�ɂ͂Ȃ�܂���B�܂��A�T�[�o�[�̃X�P�[�����O���K�؂ł���A100 ���̃^�X�N�̓���������˗����Ă�•ʂ̃^�X�N�̊������Ԃɑ傫�ȉe�����Ȃ��Ƃ������Ƃ�A�ÖٓI�ɉ��肵�Ă��܂��BFor example, consider a single-processor computer that is running Excel and a workbook that contains 1,000 cells. It calls a UDF, which in turn calls one or more remote servers. Assume that the 1,000 cells do not depend upon each other, so that Excel does not have to wait for one call to complete before calling the next. (Some relaxation of this constraint is possible without affecting this example.) If the servers can process 100 requests simultaneously, and Excel is configured to use 100 threads, the execution time can be reduced to as little as 1/100th of that where only one thread is used. The overhead that is associated with Excel allocating calls to each thread and the operating system managing 100 threads means that, in practice, the reduction will not be quite this great. There is also an implicit assumption here that the server scales well, and asking it to process 100 tasks concurrently will not affect individual task completion times significantly.

���̋Z�@���傫�ȃ����b�g�ɂȂ���p�I�A�v���P�[�V�����Ƃ��āA�����e�J�����@�ȂǁA�����ȃ^�X�N�ɕ������ĕ����̃T�[�o�[�Ɉ˗��ł��鐔�l�W��^�̃^�X�N���������܂��BOne practical application in which this technique can have an important benefit is that of Monte-Carlo methods, as well as other numerically intensive tasks that can be split into smaller sub-tasks that can be farmed out to servers.

Excel Services に関する考慮事項Excel Services considerations

Excel Services �́A�T�[�o�[�ł� Excel �X�v���b�h�V�[�g�̓ǂݍ��݁A�v�Z�A����у����_�����O��T�|�[�g���܂��B���[�U�[�́A�W���̃u���E�U �c�[����g�p���āA�X�v���b�h�V�[�g�ɃA�N�Z�X���đΘb�������s�ł���悤�ɂȂ�܂��BExcel Services supports the loading, calculating, and rendering of Excel spreadsheets on a server. Users can then access and interact with the spreadsheets by using standard browser tools.

Excel Services �� UDF �́AMicrosoft .NET Framework �̃}�l�[�W �R�[�h��g�p���č쐬��, .NET �A�Z���u����ʂ��Ďg�p�”\�ɂȂ�܂��BXLL �́AExcel Services �ł̓T�|�[�g����܂���B�}�l�[�W �R�[�h �T�[�o�[ UDF ���\�[�X�́AXLL ��Ăяo���Ă��̋@�\�ɃA�N�Z�X�ł��邽�߁A���[�U�[�̓T�[�o�[�œǂݍ��܂ꂽ�u�b�N�ƃN���C�A���g�œǂݍ��܂ꂽ�u�b�N�œ����@�\��g�p�ł��܂��BExcel Services UDFs are created using Microsoft .NET Framework managed code and made available though a .NET assembly. XLLs are not supported by Excel Services. A managed code server UDF resource can call into an XLL to access its functionality, so that the user can have the same functionality with a server-loaded workbook as with a client-loaded workbook.

���̕��@�� XLL �̊֐���g�p�ł���悤�ɂ���ɂ́A�����Ɩ߂�l��l�C�e�B�u �f�[�^�^���� .NET Framework �}�l�[�W �f�[�^�^�ɕϊ����� XLL �֐���Ăяo�� .NET �A�Z���u���ŁA�֐�����b�v����K�v������܂��B.NET ���b�p�[�́A�A�N�Z�X�Ώۂ� XLL �֐����Ƃ� 1 �‚̃T�[�o�[ UDF ��G�N�X�|�[�g���܂��B�lj��̗v���Ƃ��āA���̕��@�ŌĂяo����� XLL �֐��̓X���b�h �Z�[�t�ł��邱�Ƃ��K�v�ł��BXLL �֐��͖{���̕��@�� Excel �ɓo�^����Ă��Ȃ����߁A���̊֐�������I�ɃX���b�h �Z�[�t�ɂ�����@���T�[�o�[�� .NET ���b�p�[�ɂ͂���܂���B����́AXLL �J���҂̐ӔC�ŕۏ؂��܂��BTo make an XLL's functions available in this way, they must therefore be wrapped in a .NET assembly that converts arguments and return values from the native data types to the .NET Framework managed data types, and that calls the XLL functions. The .NET wrapper would export one server UDF for each XLL function being accessed. An additional requirement is that any XLL functions called in this way must be thread safe. Because the XLL functions are not registered in the way that they are with client Excel, the server and the .NET wrapper have no way of enforcing that they are thread safe. It is the responsibility of the XLL developer to ensure this.

�֘A����See also