Skip to content

perf: add benchmark and improve performance - #64

Merged
gapry merged 1 commit into
mainfrom
performance
Nov 29, 2026
Merged

gapry merged 1 commit into
mainfrom
performance

Conversation

@gapry

@gapry gapry commented Nov 29, 2026

Copy link
Copy Markdown
Owner

No description provided.

@amazon-q-developer

Copy link
Copy Markdown

Warning

Amazon Q Developer for GitHub: end of support

On January 30, 2027, AWS will discontinue support for the Amazon Q Developer for GitHub App. New app installations will no longer be available starting November 18, 2026.

For capabilities similar to the Amazon Q Developer for GitHub App, explore Kiro and the Kiro GitHub App. For more information about the end of support, see Amazon Q Developer end-of-support announcement on the AWS DevOps Blog.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR introduces a performance benchmarking suite (bench/navigation.js, bench/render.js) and refactors the app routing/rendering architecture — moving from a monolithic stateful App.jsx with popstate listeners to a cleaner Navigation API–based router with a dedicated router.js module. The Shiki highlighter is also changed from the JS regex engine to the Oniguruma WASM engine (lazy-initialised), and post.config.js gains pre-rendered JSON output for each post at build time.

Critical issues found:

  1. post.config.js — Path traversal via unsanitised tag names (security): Tag values from raw frontmatter are used directly as directory components in path.join(distDir, 'tag', tag) without any normalisation. A tag value containing .. or / would write outside distDir during the build. Use path.basename(tag) or an allow-list to sanitise.

  2. bench/navigation.js — Shared debug port across sequential Chrome spawns (logic error): Both benchmark profiles spawn separate Chrome processes that all bind to the same hardcoded debugPort = 9230. The 300 ms grace sleep may not be enough for the OS to release the port, causing the second Chrome to fail to bind silently and the benchmark to either hang or report incorrect results against the wrong process.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment thread post.config.js
path.join(distDir, 'index.html'),
path.join(tagDir, 'index.html')
);
writePage(path.join(tagDir, 'index.html'), '/posts.json');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: Tag values read from raw markdown frontmatter are used directly as filesystem path components without sanitisation. A tag containing .. or path separators (e.g., ../dist/evil) would cause path traversal during the build, potentially overwriting files outside distDir. Sanitise tag values before using them in path.join, for example by using path.basename(tag) to strip directory components.1

Footnotes

  1. CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') - https://cwe.mitre.org/data/definitions/22.html ↩

Comment thread bench/navigation.js

const root = fileURLToPath(new URL('..', import.meta.url));
const previewPort = 4180;
const debugPort = 9230;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: Both fast and mobile profiles use the same hardcoded debugPort = 9230. Each runProfile spawns its own Chrome process against that port. If the Chrome process from the first profile is still releasing the port during the 300 ms grace sleep, the second Chrome will fail to bind on the same port, causing the waitUntil for 'chrome' to silently poll the previous (or a failed) debug endpoint and either return stale targets or timeout. Consider either passing a unique port per profile or ensuring the port is free before spawning the next Chrome instance.

@gapry
gapry merged commit aeca3f1 into main Nov 29, 2026
2 checks passed
@gapry
gapry deleted the performance branch November 29, 2026 15:44
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.

1 participant