OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
680 stars 95 forks source link

Operations gets progressively slower when doing inserts in Excel #3320

Open pvsleeper opened 1 year ago

pvsleeper commented 1 year ago

When repeatedly inserting rows and then deleting rows, Excel API gets progressively slower

Your Environment

Expected behavior

When repeatedly inserting rows and then deleting rows, Excel should not slow down

Current behavior

When repeatedly inserting large number of rows and then deleting them, Excel API slows down

Steps to reproduce

  1. Run attached ScriptLab script and observe the output. Every time you run the script, the delete process gets slower and slower.

Link to live example(s)

async function run() {
  await Excel.run(async (context) => {
    const now = performance.now();
    const exinstig = context.workbook.worksheets.getActiveWorksheet().getUsedRangeOrNullObject();
    exinstig.delete('Up');
    await context.sync();
    const deleteTime = performance.now() - now;
    context.application.suspendScreenUpdatingUntilNextSync();
    context.application.suspendApiCalculationUntilNextSync();
    const range = context.workbook.worksheets.getActiveWorksheet().getRange('A1:C100000');
    const values = [];
    for (let i = 0; i < 100000; i++){
      values.push([`=R${i} + S${i}`, 'test', 'test'])
    }
    range.insert('Down').values = values;
    await context.sync();
    console.info(`delete took ${deleteTime}ms`);
  });
}

Provide additional details

  1. Please create a new ScriptLab script and get it to run the attached function on button click

Context

We render large reports and continuously delete and add data. This is making our plugin perform poorly

Useful logs

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

ghost commented 1 year ago

Thank you for letting us know about this issue. We will take a look shortly. Thanks.

dingjin-ms commented 1 year ago

Hi @pvsleeper, thank you for your reporting!

We have reproed it and opened an internal ticket #7844488 to track the problem. We will get back to you when we got a fix or workaround.

Meanwhile, could you please share the business impact (e.g., how many users of your add-in are impacted) so we could better prioritize the problem? Thank you!

pvsleeper commented 1 year ago

Hi @dingjin-ms - thank you for coming back so quickly.

We have discovered this issue during performance testing for a product that we have to release in 3 months time. This is to replace an existing product and will be rolled out to to around 3000 users at existing customers.

Our product allows users to create reports, and then be able to expand and collapse data, and this is where use this insert/delete mechanism, so we are very concerned that this will impact all our users as we've noticed a significant slowdown over time.

Thank you!

dingjin-ms commented 1 year ago

Thanks @pvsleeper for the information you provided.

We are starting to investigate the problem, but it's not likely to be an easy fix. But we will let you know when we have progress. Thank you!

pvsleeper commented 1 year ago

Thank you @dingjin-ms - I appreciate the feedback - I'll be eagerly waiting to hear if and when you guys manage to make some progress! Cheers!

rettoua commented 1 year ago

is there any news on that ?

SiruiSun-MSFT commented 1 year ago

Unfortunately, this bug is still in our backlog. @rettoua, are you also affected by this issue? If yes, could you provide us with the scale of affected users from your side? It will help us re-prioritize this bug. Thanks for your patience!