Skip to content

perf: handling backpressure without timer#333

Merged
dimdenGD merged 2 commits intodimdenGD:mainfrom
cesco69:backpressure-v20-64-0
Apr 16, 2026
Merged

perf: handling backpressure without timer#333
dimdenGD merged 2 commits intodimdenGD:mainfrom
cesco69:backpressure-v20-64-0

Conversation

@cesco69
Copy link
Copy Markdown
Contributor

@cesco69 cesco69 commented Apr 16, 2026

From https://github.com/uNetworking/uWebSockets.js/releases/tag/v20.64.0

Bumps uWS to v20.77.0 with important backpressure fix (see main repo for explanation)

Tested with

const express = require('../src/index.js');
const compression = require('compression');
const app = express();

// force encoding by query param ?compress=
app.use((req, res, next) => {
  const enc = req.query.compress;
  if (enc) {
    req.headers['accept-encoding'] = enc;
  }
  next();
});

app.use(compression({ threshold: 1 }));
app.use(express.static('tests/parts'));

const PORT = 13335;
app.listen(PORT, () => {
  const base = `http://localhost:${PORT}`;
  const files = ['small-file.json', 'medium-file.json', 'large-file.json'];
  const encodings = ['gzip', 'br', 'deflate'];

  console.log(`\n  Server on ${base}\n`);
  console.log('  === Links ===\n');

  for (const file of files) {
    console.log(`  ${file}`);
    console.log(`     ${'identity'.padEnd(8)} : ${base}/${file}?compress=identity`);
    for (const enc of encodings) {
      console.log(`     ${enc.padEnd(8)} : ${base}/${file}?compress=${enc}`);
    }
    console.log();
  }
});

Works on Chrome/Windows with gzip, br and deflate

Ref uNetworking/uWebSockets.js#1249

@cesco69
Copy link
Copy Markdown
Contributor Author

cesco69 commented Apr 16, 2026

@GetThatCookie take a look

@cesco69 cesco69 marked this pull request as ready for review April 16, 2026 09:37
@GetThatCookie
Copy link
Copy Markdown

GetThatCookie commented Apr 16, 2026

From my side this looks like the right minimal step.

It removes the timer / batching workaround from the chunked streaming path and goes back to direct res.write(chunk) with onWritable(...), which is leaner and much more in line with the current uWS backpressure model after uNetworking/uWebSockets.js#1249.

If a real HTTP tryWrite lands upstream later, ultimate-express could move to that.
See uNetworking/uWebSockets#1922.

But I would not block this PR on it.

@dimdenGD dimdenGD merged commit b96cbbb into dimdenGD:main Apr 16, 2026
4 checks passed
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.

3 participants