question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CPU usage after sorting

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior I only started looking at this component a couple days ago, but from my outsider’s perspective this appears to be a bug. As you sort and/or resize columns, the CPU usage gradually creeps up (and stays there). I’m using Chrome on Windows 10, but I also repro’ed this on an older Win 7 machine using both IE and Chrome (and on that machine, the CPU usage quickly reached 50%).

Expected behavior CPU to go back down to 0 after the sort completes

Reproduction of the problem Bring up the Fluid Row Heights sample: http://swimlane.github.io/ngx-datatable

Bring up Chrome’s Task Manager (Shift+Esc, or via the button in the upper right corner/more tools). You can also see this happening in Windows Task Manager, but Chrome’s task manager shows CPU usage on a per tab basis. Notice the CPU for the datatable tab is at 0 or near 0.

Now click on column headers to sort the rows. After each click the average CPU usage increases slightly. After a dozen or so clicks it’s at about 15%. Go to another tab and it falls to about 1%. It jumps back up after coming back to the datatable tab.

Seems like it’s related to the number of rows. If I go to the Inline Editing sample with 100 rows, 5 showing at a time, CPU load goes down to about 5%. If I go to the 10k rows sample, it goes up to about 25%.

Same thing happens if I resize the columns instead of sorting them, though doesn’t seem to be as severe.

What is the motivation / use case for changing the behavior? Fan eventually kicks in, which is when I first noticed the problem.

Please tell us about your environment: Windows 10, Windows 7

  • Table version: 4.0.0 I assume the online demo is using latest, but I was also able to repro on a sample app on localhost using 4.0.0.

  • Angular version: 2.3.1

  • Browser: Chrome 55 | IE 11

  • Language: TypeScript 2.1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
JanCejkacommented, Dec 22, 2016

Problem is on line 64 - it contains:

if(this.longPressing) {

, while it should be

if(this.isLongPressing) {

this.longPressiong will evaluate always to true since it is EventEmitter assigned at creation of Component.

On top - probably line 29 should be changed as well. I believe current content

get isLongPress(): boolean { return this.longPressing !== undefined; }

should be

get isLongPress(): boolean { return this.isLongPressing; }

and last point - correct onMouseMove should be (there was typo as well plus abs() was missing):

  @HostListener('mousemove', ['$event'])
  onMouseMove(event: MouseEvent): void {
    if(this.pressing && !this.isLongPressing) {
      const xThres = Math.abs(event.clientX - this.mouseX) > 10;
      const yThres = Math.abs(event.clientY - this.mouseY) > 10;

      if(xThres || yThres) {
        this.endPress();
      }
    }
  }
1reaction
dae721commented, Dec 22, 2016

Took a stab at trying to figure out what the problem is. By breaking in the Chrome debugger when it should be idle, I think I found an infinite loop in directives\long-press.directive.ts in the loop function. Set a breakpoint there, click anywhere in the header, you’ll hit the breakpoint, press F8 to continue and the breakpoint will be hit each time. If I remove the breakpoint, let it run awhile, then add the breakpoint back, it hits it right away. Haven’t looked at the code enough to understand if it’s indeed a problem, or maybe a side-effect caused by breaking in the debugger.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Task Manager - Sort by average or maximum CPU - Super User
Is there a way to sort with respect to average or max cpu usage. Use Admin Tools, Resource Monitor instead. Average CPU is...
Read more >
Guidance for troubleshooting high CPU usage - Windows Server
Select the CPU column header to sort the list by CPU usage. Make sure that the arrow that appears on the header points...
Read more >
mysql - High CPU usage from sorting result queries
High CPU usage from sorting result queries · Enable slow query log and identify the the specific query which utilizing high CPU power....
Read more >
Sort processes by CPU Usage - Commandlinefu
ps aux | sort -rk 3,3 | head -n 10 - (Sort processes by CPU Usage Short list about top 10 processes, sorted...
Read more >
8 Useful Solutions to Fix Your CPU 100% in Windows 10/11
After you do this operation, the high CPU usage will become lower ... Step 2: Click the CPU column header to sort the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found