Skip to content
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

Add PriorityTaskQueue #4144

Merged
merged 4 commits into from
Sep 25, 2022
Merged

Add PriorityTaskQueue #4144

merged 4 commits into from
Sep 25, 2022

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented Sep 24, 2022

This acts as a fallback when idle callbacks aren't supported, we may also want to use it for other tasks (eg. write buffer?)

@Tyriar Tyriar added this to the 5.1.0 milestone Sep 24, 2022
@Tyriar Tyriar self-assigned this Sep 24, 2022
@Tyriar Tyriar merged commit eca9c72 into xtermjs:master Sep 25, 2022
@Tyriar Tyriar deleted the priority_queue branch September 25, 2022 16:39
Tyriar added a commit to microsoft/vscode that referenced this pull request Sep 26, 2022
- Optimize critical I/O path for input latency xtermjs/xterm.js#4145
- Add PriorityTaskQueue xtermjs/xterm.js#4144
- Use the browser's IdleDeadline to determine max task time xtermjs/xterm.js#4143
- Defer paused renderer resize to idle callback xtermjs/xterm.js#4142
- Do char atlas warmup via new IdleTaskQueue xtermjs/xterm.js#4141
- Share rgba vars throughout Color.ts, fast setTheme parseColor xtermjs/xterm.js#4140
- Optimize contexts for reading frequently xtermjs/xterm.js#4137
- Fix width of upper 1/8 block char xtermjs/xterm.js#4134

Fixes #161323
@jerch
Copy link
Member

jerch commented Sep 27, 2022

@Tyriar Can I use this for the BufferLine resizing? If so, which is the straight forward usage pattern? DebouncedIdleTask.set?

@Tyriar
Copy link
Member Author

Tyriar commented Sep 27, 2022

@jerch yes you could use it for that:

private _resizeIdleTask: DebouncedIdleTask = new DebouncedIdleTask();
resize(cols, rows) {
  // Check if there is room in the buffer or we need a new one immediately
  if (cols * CELL_SIZE * 4 > this._data.buffer.byteLength) {
    // Discard any pending resizes
    this._resizeIdleTask.clear();
    // Resize immediately
    this._data = ...
  } else {
    // Swap out the current resize task
    this._resizeIdleTask.set(() => cleanUp());
    // Resize without reallocating this._data
    ...
  }
}

This clean up stuff could be encapsulated within a class for simplicity (DynamicUint8Array?), basically a stripped down version of my ArrayBufferList exploration https://github.com/Tyriar/xterm.js/tree/array_buffer_list

@jerch jerch mentioned this pull request Sep 28, 2022
5 tasks
lemanschik pushed a commit to code-oss-dev/code that referenced this pull request Nov 25, 2022
- Optimize critical I/O path for input latency xtermjs/xterm.js#4145
- Add PriorityTaskQueue xtermjs/xterm.js#4144
- Use the browser's IdleDeadline to determine max task time xtermjs/xterm.js#4143
- Defer paused renderer resize to idle callback xtermjs/xterm.js#4142
- Do char atlas warmup via new IdleTaskQueue xtermjs/xterm.js#4141
- Share rgba vars throughout Color.ts, fast setTheme parseColor xtermjs/xterm.js#4140
- Optimize contexts for reading frequently xtermjs/xterm.js#4137
- Fix width of upper 1/8 block char xtermjs/xterm.js#4134

Fixes microsoft#161323
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants