There is the following task: On the server side, a two-dimensional array of 10,000 elements per 10,000 elements is stored in memory. A request comes from the client: you need to take the matrix, make some manipulations with it (delete some elements, the dimension changes) and apply the factor to it in the client request, then return the result.

Requests from multiple clients must be processed in parallel, not sequentially, each request in a separate thread. At the same time, the matrix changes the dimension only for a specific client, each new client needs to give the matrix with its original dimension for the calculation.

The question is how to do it. Use CopyTo - wildness for an array of this dimension. Maybe you can somehow clone it to give a copy of the original state of the matrix, without changing it itself?

  • Well, how do you want to clone without copying it? I think there is no difference - manually run through the cells and copy each, use Clone or CopyTo - Andrey NOP
  • one
    And when should the changed matrix become “visible” to other clients? If never, make it immutable and carry a new size and multipliers with you. - VladD
  • Supplement the question with information on whether the modified matrix should be saved for others or the same client, how long the changes for a single client are calculated, how fast the system should process requests, how many queries, array elements are value types or reference? - Ivan K
  • The visible matrix will never become, but each client needs to calculate a certain parameter using its very first state, and the clone of the matrix can change only for one client. Vlad, what do you mean? As for the valueType matrix, the system processes a lot of requests, performance is very important. The main operation is the product of the client matrix and the large server - Sleeeper
  • @Sleeeper: Well, get the “source matrix + new size + multiplier” data structure, write an indexer - and everything seems to be. - VladD

0