aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/analytics/analytics_thread.zig3
-rw-r--r--src/cli/create_command.zig3
-rw-r--r--src/global.zig13
-rw-r--r--src/http.zig8
-rw-r--r--src/watcher.zig9
5 files changed, 20 insertions, 16 deletions
diff --git a/src/analytics/analytics_thread.zig b/src/analytics/analytics_thread.zig
index 870dec5a5..2c778d589 100644
--- a/src/analytics/analytics_thread.zig
+++ b/src/analytics/analytics_thread.zig
@@ -346,9 +346,8 @@ const header_entry = Headers.Kv{
fn readloop() anyerror!void {
defer disabled = true;
- Output.Source.configureThread();
+ Output.Source.configureNamedThread(thread, "Analytics");
defer Output.flush();
- thread.setName("Analytics") catch {};
var event_list = try default_allocator.create(EventList);
event_list.* = EventList.init();
diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig
index 0a9cc2c5e..908b1c615 100644
--- a/src/cli/create_command.zig
+++ b/src/cli/create_command.zig
@@ -2169,8 +2169,7 @@ const GitHandler = struct {
PATH: string,
verbose: bool,
) void {
- Output.Source.configureThread();
- std.Thread.setName(thread, "git") catch {};
+ Output.Source.configureNamedThread(thread, "git");
defer Output.flush();
const outcome = if (verbose)
run(destination, PATH, true) catch false
diff --git a/src/global.zig b/src/global.zig
index 08cc77fab..536b55be7 100644
--- a/src/global.zig
+++ b/src/global.zig
@@ -80,6 +80,19 @@ pub const Output = struct {
source = Source.init(stdout_stream, stderr_stream);
}
+ pub fn configureNamedThread(thread: std.Thread, name: stringZ) void {
+ if (source_set) return;
+ configureThread();
+
+ // On Linux, thread may be undefined
+ // Fortunately, we can use a different syscall that only affects the current thread
+ if (Environment.isLinux) {
+ _ = std.os.linux.prctl(std.os.PR_SET_NAME, @ptrToInt(name.ptr), 0, 0, 0);
+ } else {
+ thread.setName(name) catch {};
+ }
+ }
+
pub fn set(_source: *Source) void {
source = _source.*;
source_set = true;
diff --git a/src/http.zig b/src/http.zig
index 158092bd9..275dbb022 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -1111,7 +1111,7 @@ pub const RequestContext = struct {
var js_thread: std.Thread = undefined;
pub fn spawnThread(handler: *HandlerThread) !void {
js_thread = try std.Thread.spawn(.{ .stack_size = 64 * 1024 * 1024 }, spawn, .{handler});
- js_thread.setName("JavaScript SSR") catch {};
+ if (!Environment.isMac) js_thread.setName("JavaScript SSR") catch {};
js_thread.detach();
}
@@ -1125,11 +1125,7 @@ pub const RequestContext = struct {
}
var start_timer = std.time.Timer.start() catch unreachable;
- var stdout = std.io.getStdOut();
- var stderr = std.io.getStdErr();
- var output_source = Output.Source.init(stdout, stderr);
- defer Output.flush();
- Output.Source.set(&output_source);
+ Output.Source.configureThread();
@import("javascript/jsc/JavascriptCore.zig").JSCInitialize();
js_ast.Stmt.Data.Store.create(std.heap.c_allocator);
diff --git a/src/watcher.zig b/src/watcher.zig
index f9ae5c3aa..f8de190bd 100644
--- a/src/watcher.zig
+++ b/src/watcher.zig
@@ -273,6 +273,7 @@ pub fn NewWatcher(comptime ContextType: type) type {
allocator: *std.mem.Allocator,
watchloop_handle: ?std.Thread.Id = null,
cwd: string,
+ thread: std.Thread = undefined,
pub const HashType = u32;
@@ -302,17 +303,13 @@ pub fn NewWatcher(comptime ContextType: type) type {
pub fn start(this: *Watcher) !void {
std.debug.assert(this.watchloop_handle == null);
- var thread = try std.Thread.spawn(.{}, Watcher.watchLoop, .{this});
- thread.setName("File Watcher") catch {};
+ this.thread = try std.Thread.spawn(.{}, Watcher.watchLoop, .{this});
}
// This must only be called from the watcher thread
pub fn watchLoop(this: *Watcher) !void {
this.watchloop_handle = std.Thread.getCurrentId();
- var stdout = std.io.getStdOut();
- var stderr = std.io.getStdErr();
- var output_source = Output.Source.init(stdout, stderr);
- Output.Source.set(&output_source);
+ Output.Source.configureNamedThread(this.thread, "File Watcher");
defer Output.flush();
if (FeatureFlags.verbose_watcher) Output.prettyln("Watcher started", .{});
ogheader'>2022-10-04Updating sponsors list in README (#4979)Gravatar Tony Sullivan 12-48/+176 * updating all org and project sponsors * fix: copy/paste errors * sponsors should be in one row * using a logo cloud image for now * updating sponsors message to match other repos 2022-10-04[ci] formatGravatar matthewp 4-7/+11 2022-10-04Refactor hydration path handling (#4918)Gravatar Bjorn Lu 14-44/+137 * Refactor hydration path handling * Remove old code * Fix jsx strip * Postprocess fix * Handle jsx to tsx stuff * Skip bigint tests * Fix deno * Try fix windows * Fix windows * Add more comments 2022-10-04fix: import.meta.env.BASE_URL will be '/' in client loaded component on dev ↵Gravatar 董雨航 9-0/+82 mode (#4886) 2022-10-04fix object styles not escaped (#4887)Gravatar Calvin Liang 8-2/+71 * fix object styles not escaped * fix `shouldEscape` not passed down * add tests * fix package name * fix pnpm-lock * add changeset 2022-10-04closes #4633 (#4977)Gravatar Tony Sullivan 3-3/+11 * closes #4633 * chore: add changeset 2022-10-04[ci] update lockfile (#4946)Gravatar Fred K. Bot 1-150/+159 Co-authored-by: FredKSchott <FredKSchott@users.noreply.github.com> 2022-10-04[ci] formatGravatar matthewp 1-4/+4 2022-10-04Update config base type description (#4954)Gravatar Zihan Chen 1-1/+10 2022-10-04Support Astro.slots.render for mdx (#4973)Gravatar Bjorn Lu 8-2/+69 * Support Astro.slots.render for mdx * Remove extra imports 2022-10-03[ci] release (#4968)astro@1.4.4Gravatar Fred K. Bot 28-57/+58 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2022-10-03Fix regression in rendering strings (#4967)Gravatar Matthew Phillips 2-2/+9 2022-10-03[ci] formatGravatar matthewp 1-1/+2 2022-10-03Adds a better test for benchmarking (#4966)Gravatar Matthew Phillips 2-7/+77 * Rendering: speed up rendering of HTML chunks * Add a changeset * Remove the fix * remove the changeset 2022-10-03Benchmark action: provide the PR number (#4964)Gravatar Matthew Phillips 1-0/+1 * Testing benchmarking * Provide the PR number 2022-10-03Build packages in the benchmark action (#4962)Gravatar Matthew Phillips 1-0/+11 * Just a test * Run the build * Add turbo stuff 2022-10-03Run benchmarks on comment (#4960)Gravatar Matthew Phillips 2-1/+85 * Run benchmarks on !bench command * Re-enable main 2022-10-03[ci] release (#4957)astro@1.4.3@astrojs/mdx@0.11.4Gravatar Fred K. Bot 32-70/+69 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2022-10-03[ci] formatGravatar matthewp 5-6/+6 2022-10-03Improve rendering perf (#4956)Gravatar Matthew Phillips 8-31/+73 * Improve rendering perf * Adding a changeset * Disable eslint warning 2022-10-03Suppress eslint warnings (#4953)Gravatar Bjorn Lu 3-3/+14 2022-10-03[ci] formatGravatar bluwy 1-1/+1 2022-10-03Refactor ViteConfigWithSSR type (#4952)Gravatar Bjorn Lu 7-20/+20 2022-10-01[ci] release (#4945)@astrojs/image@0.9.11.3.0Gravatar Fred K. Bot 3-6/+7 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2022-09-30Astro image cache dependency fix scottaw66 (#4944)Gravatar Scott Willsey 3-3/+7 * Moves http-cache-semantics from dev dependency to dependency * Pull request for astro image http-cache-semantics dependency 2022-09-30[ci] release (#4943)astro@1.4.2Gravatar Fred K. Bot 29-60/+58 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2022-09-30[ci] formatGravatar natemoo-re 1-1/+1 2022-09-30Convert HTMLString to regular string, preventing hydration script fro… (#4932)Gravatar Matthew Phillips 2-1/+6 * Convert HTMLString to regular string, preventing hydration script from being missing * Add a changeset 2022-10-01Fix missing language tag on README code block (#4940)Gravatar Chris Swithinbank 1-1/+1 2022-09-30[ci] formatGravatar natemoo-re 2-2/+2 2022-09-30P5: fix MDX memory leak (#4939)Gravatar Nate Moore 10-1/+84 * fix(astro): tag jsx vnodes with renderer so errors are properly handled * chore: fix missing package in test Co-authored-by: Nate Moore <nate@astro.build> 2022-09-30chore: delete .stackblitzrc files from examples (#4922)Gravatar Nate Moore 22-132/+0 Co-authored-by: Nate Moore <nate@astro.build>