Repository navigation
Conversation
There was a problem hiding this comment.
Superseded by the review of
b2fff3b3.
This review, of bffe36da
🛑 Significant concerns — One BLOCKING issue: perf-map.c++ is built into the jsg library on all platforms but uses <unistd.h>, fcntl(F_GETFL) and write() without a Windows guard, which should break the Windows build and release. The Linux-only test is a WARNING.
Findings: 1 blocking · 1 warning · 1 info · 1 suggestion (4 are inline comments on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #8163.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## BLOCKING (1)
### [Code Quality] perf-map.c++ is compiled into the jsg library on all platforms but uses <unistd.h>, fcntl(F_GETFL), O_APPEND and write() with no _WIN32 guard, so it should break the Windows build (.github/workflows/test.yml:48, release.yml:102-105).
- **File:** src/workerd/jsg/perf-map.c++:9
## WARNING (1)
### [Code Quality] perf-map-test.c++ uses the Linux-only memfd_create/MFD_CLOEXEC with no platform guard, but the *-test.c++ glob builds it on macOS and Windows too, so those CI test builds should fail.
- **File:** src/workerd/jsg/perf-map-test.c++:17
## INFO (1)
### [Performance] Each JIT code event results in its own synchronous write() syscall on the isolate thread.
- **File:** src/workerd/jsg/perf-map.c++:38
## SUGGESTION (1)
### [Code Quality] The KJ_REQUIRE line in V8System::enablePerfMap is over the 100-column limit and is not clang-formatted.
- **File:** src/workerd/jsg/setup.c++:227
📋 Code Quality: 🛑 1 blocking · 1 warning · 1 suggestion
The new perf-map source isn't guarded for Windows, the test uses a Linux-only API, and one line is not formatted.
Recommendation: 🔴 Serious Concerns
- [BLOCKING] perf-map.c++ is compiled into the jsg library on all platforms but uses <unistd.h>, fcntl(F_GETFL), O_APPEND and write() with no _WIN32 guard, so it should break the Windows build (.github/workflows/test.yml:48, release.yml:102-105). (
src/workerd/jsg/perf-map.c++:9) - [WARNING] perf-map-test.c++ uses the Linux-only memfd_create/MFD_CLOEXEC with no platform guard, but the *-test.c++ glob builds it on macOS and Windows too, so those CI test builds should fail. (
src/workerd/jsg/perf-map-test.c++:17) - [SUGGESTION] The KJ_REQUIRE line in V8System::enablePerfMap is over the 100-column limit and is not clang-formatted. (
src/workerd/jsg/setup.c++:227)
View full review
- Windows build (
src/workerd/jsg/perf-map.c++:7-9):perf-map.c++is added to the mainjsgwd_cc_librarywith no platform restriction. It includes<unistd.h>and callsfcntl(F_GETFL),O_APPEND,write()andssize_t, none of which the Windows toolchain provides. Other files in the tree put<unistd.h>behind#if !_WIN32, for exampleserver/factory/bootstrap.c++:37andio/worker.c++:74. Windows is built and tested in.github/workflows/test.yml:48and released in.github/workflows/release.yml:102-105.setup.hnow includesperf-map.h, so the header must also stay portable. - Linux-only test (
src/workerd/jsg/perf-map-test.c++:9,17,58): the*-test.c++glob builds this test on every platform, but it usesmemfd_create,MFD_CLOEXECand<sys/mman.h>. Guard it with#ifdef __linux__the wayfast-api-test.c++does, or exclude the file from the glob on non-Linux targets. - Formatting (
src/workerd/jsg/setup.c++:227): theKJ_REQUIREline is over 100 columns and is not clang-formatted.
⚡ Performance: 💬 1 info
Each JIT code event costs one synchronous write() on the isolate thread.
Recommendation: 💬 Optional Nits
- [INFO] Each JIT code event results in its own synchronous write() syscall on the isolate thread. (
src/workerd/jsg/perf-map.c++:38)
View full review
PerfMapWriter::add makes one unbuffered write() per ADD_CODE_LINE_POS and CODE_MOVED event, inline in the isolate's V8 callback. The feature is opt-in, so the cost is acceptable, but keep it in mind while the cardinality question is still open.
✅ All other checks passed
🔒 Security: ✅ LGTM
The writer receives a descriptor that is already open; this pull request does not open any path itself. Newlines and carriage returns in JS-derived names are replaced, so a script cannot inject extra map records. The line buffer is bounded at 1024 bytes.
📖 AGENTS.md: ✅ LGTM
The change follows existing JSG and Bazel patterns.
📝 Documentation: ✅ LGTM
No documentation issues.
Reviewed commit: bffe36da
|
|
||
| ssize_t n; | ||
| do { | ||
| n = write(fd.get(), line, pos - line); |
There was a problem hiding this comment.
ℹ️ INFO · Performance
Each JIT code event results in its own synchronous write() syscall on the isolate thread.
This runs inline in IsolateBase::jitCodeEvent on the isolate thread, one syscall for every code event. A cold start can produce thousands of these, and a slow or full filesystem would stall the isolate. The feature is opt-in, so this is acceptable, but if you change how names are written to address cardinality, consider whether per-event writes are still the right choice.
There was a problem hiding this comment.
Superseded by the review of
d6cb3401.
This review, of b2fff3b3
💬 Approved with comments — The earlier Windows build BLOCKING and the Linux-only test WARNING are both fixed. The only remaining note is an INFO about one write() call per JIT event.
Findings: 1 info
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
⚡ Performance: 💬 1 info
One write() syscall per JIT code event on the isolate thread
Recommendation: 💬 Optional Nits
- [INFO] Each ADD_CODE_LINE_POS and CODE_MOVED event makes its own synchronous write() syscall on the isolate thread. (
src/workerd/jsg/perf-map.c++:49)
View full review
PerfMapWriter::add runs inline from V8's JIT code event callback. Each call does one unbuffered write(), and warm-up or GC compaction can produce many of these events. The feature is opt-in, so this is acceptable. Revisit it if the cardinality question turns out to mean high event volume.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security issues. The writer takes a descriptor that is already open, and it replaces newlines in names so a script cannot inject extra map records. The line buffer is bounded at 1024 bytes.
📖 AGENTS.md: ✅ LGTM
The change follows the existing JSG and Bazel patterns.
📋 Code Quality: ✅ LGTM
All three earlier findings are fixed:
- Windows build:
perf-map.c++:9-25puts the POSIX code behind#if !_WIN32. - Linux-only test: the test uses
mkstemp+unlink, andBUILD.bazel:373-381builds it as a separatekj_testthat is incompatible with Windows. - Line length: the
KJ_REQUIREline insetup.c++is now wrapped.
📝 Documentation: ✅ LGTM
No documentation issues.
Reviewed commit: b2fff3b3
perf-map.c++ used <unistd.h>, fcntl() and write() unguarded, which breaks the Windows build. On Windows the writer now throws KJ_UNIMPLEMENTED, as getJsStackTrace() already does. The test used memfd_create(), which is Linux-only, so it also failed to build on macOS. It now uses an unlinked mkstemp() file, and is marked incompatible with Windows. Also explain in perf-map.h why each line is its own write(), and wrap an over-long KJ_REQUIRE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b2fff3b to
d6cb340
Compare
There was a problem hiding this comment.
✅ Approved — No findings at this commit. The earlier Windows-build and Linux-only test problems are still fixed, and the setup.h and BUILD.bazel changes are correct.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
The writer takes a descriptor that is already open, so no path comes from untrusted input. It replaces newlines in function names, so a script cannot inject extra map records. The line buffer is bounded at 1024 bytes.
📖 AGENTS.md: ✅ LGTM
The change follows the existing JSG and Bazel conventions.
📋 Code Quality: ✅ LGTM
No new problems in the code changed since the last review. setup.c++ skips bytecode events in both the CODE_ADDED and CODE_MOVED paths. perf-map.c++ keeps its POSIX code behind #if !_WIN32. The test target is marked incompatible with Windows. enablePerfMap documents that it requires JitCodeEventTracking::YES and must be called before any isolate is created.
⚡ Performance: ✅ LGTM
No new performance concerns. The earlier note still applies: each JIT code event makes one synchronous write() call. The feature is opt-in, so this is acceptable for now.
📝 Documentation: ✅ LGTM
No documentation issues.
Reviewed commit: d6cb3401
enhances our existing code gen event tracking to record a corresponding perfmap file
not merging there's some alignment with the perf team on how to integrate into continuous profiling, but approach will be the same either way (I think only concern is cardinality, so only change would be changing name writing in
PerfMapWriter::add)