Compare commits

...

10 Commits

Author SHA1 Message Date
gcp-cherry-pick-bot[bot]
bc0dd3aecb Don't iterate over all system processes (cherry-pick #11281) (#11285)
Cherry-picked Don't iterate over all system processes (#11281)

Release Notes:

- Fixed a UI beachball when gathering process information

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-05-01 20:21:54 -06:00
Conrad Irwin
bb394bd9d0 Fix bundle script moar 2024-05-01 20:21:31 -06:00
Conrad Irwin
a5eec9c25e Upload file better? 2024-05-01 18:55:26 -06:00
gcp-cherry-pick-bot[bot]
9529e367a9 Only keep one blame up-to-date (cherry-pick #11274) (#11277)
Cherry-picked Only keep one blame up-to-date (#11274)

I was experiencing hang, and we blamed it on spawning a few hundred git
processes
simultaneously.

cc @MrNugget

Release Notes:

- Fixed slowness with hundreds of buffers open doing git blame.

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-05-01 18:51:05 -06:00
gcp-cherry-pick-bot[bot]
932555abca Use HIGH priority to wake blocked timers (cherry-pick #11269) (#11278)
Cherry-picked Use HIGH priority to wake blocked timers (#11269)

One contributor to some beach-balls was that the main thread was calling
block_with_timeout, but the timeout never fired.

Release Notes:

- Reduced main thread hangs under very high system load

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-05-01 18:50:52 -06:00
Conrad Irwin
6e5e482854 Fix linux bundle again maybe 2024-05-01 11:29:30 -06:00
Conrad Irwin
f3a82e450f zed 0.134.1 2024-05-01 10:44:13 -06:00
Conrad Irwin
8a1e4512c4 blerg (#11254)
Release Notes:

- N/A
2024-05-01 10:23:12 -06:00
Conrad Irwin
03abd7df78 Revert tyop (#11253)
Follup up from
https://github.com/zed-industries/zed/pull/11229#pullrequestreview-2033556336

Release Notes:

- N/A
2024-05-01 10:23:12 -06:00
Joseph T. Lyons
28b0378fe9 v0.134.x preview 2024-05-01 11:32:45 -04:00
12 changed files with 86 additions and 50 deletions

View File

@@ -329,7 +329,7 @@ jobs:
with:
draft: true
prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
files: target/release/zed-linux-x86_64.tar.gz
files: zed-linux-x86_64.tar.gz
body: ""
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
Cargo.lock generated
View File

@@ -12654,7 +12654,7 @@ dependencies = [
[[package]]
name = "zed"
version = "0.134.0"
version = "0.134.1"
dependencies = [
"activity_indicator",
"anyhow",

View File

@@ -12,7 +12,7 @@ use settings::{Settings, SettingsStore};
use sha2::{Digest, Sha256};
use std::io::Write;
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
use sysinfo::{CpuRefreshKind, MemoryRefreshKind, Pid, ProcessRefreshKind, RefreshKind, System};
use sysinfo::{CpuRefreshKind, Pid, ProcessRefreshKind, RefreshKind, System};
use telemetry_events::{
ActionEvent, AppEvent, AssistantEvent, AssistantKind, CallEvent, CopilotEvent, CpuEvent,
EditEvent, EditorEvent, Event, EventRequestBody, EventWrapper, ExtensionEvent, MemoryEvent,
@@ -171,40 +171,38 @@ impl Telemetry {
drop(state);
let this = self.clone();
cx.spawn(|_| async move {
// Avoiding calling `System::new_all()`, as there have been crashes related to it
let refresh_kind = RefreshKind::new()
.with_memory(MemoryRefreshKind::everything()) // For memory usage
.with_processes(ProcessRefreshKind::everything()) // For process usage
.with_cpu(CpuRefreshKind::everything()); // For core count
let mut system = System::new_with_specifics(refresh_kind);
// Avoiding calling `refresh_all()`, just update what we need
system.refresh_specifics(refresh_kind);
// Waiting some amount of time before the first query is important to get a reasonable value
// https://docs.rs/sysinfo/0.29.10/sysinfo/trait.ProcessExt.html#tymethod.cpu_usage
const DURATION_BETWEEN_SYSTEM_EVENTS: Duration = Duration::from_secs(4 * 60);
loop {
smol::Timer::after(DURATION_BETWEEN_SYSTEM_EVENTS).await;
system.refresh_specifics(refresh_kind);
cx.background_executor()
.spawn(async move {
let mut system = System::new_with_specifics(
RefreshKind::new().with_cpu(CpuRefreshKind::everything()),
);
let refresh_kind = ProcessRefreshKind::new().with_cpu().with_memory();
let current_process = Pid::from_u32(std::process::id());
let Some(process) = system.processes().get(&current_process) else {
let process = current_process;
log::error!("Failed to find own process {process:?} in system process table");
// TODO: Fire an error telemetry event
return;
};
system.refresh_process_specifics(current_process, refresh_kind);
this.report_memory_event(process.memory(), process.virtual_memory());
this.report_cpu_event(process.cpu_usage(), system.cpus().len() as u32);
}
})
.detach();
// Waiting some amount of time before the first query is important to get a reasonable value
// https://docs.rs/sysinfo/0.29.10/sysinfo/trait.ProcessExt.html#tymethod.cpu_usage
const DURATION_BETWEEN_SYSTEM_EVENTS: Duration = Duration::from_secs(4 * 60);
loop {
smol::Timer::after(DURATION_BETWEEN_SYSTEM_EVENTS).await;
let current_process = Pid::from_u32(std::process::id());
system.refresh_process_specifics(current_process, refresh_kind);
let Some(process) = system.process(current_process) else {
log::error!(
"Failed to find own process {current_process:?} in system process table"
);
// TODO: Fire an error telemetry event
return;
};
this.report_memory_event(process.memory(), process.virtual_memory());
this.report_cpu_event(process.cpu_usage(), system.cpus().len() as u32);
}
})
.detach();
}
pub fn set_authenticated_user_info(

View File

@@ -264,7 +264,7 @@ pub async fn post_hang(
Error::Internal(anyhow!(err))
})?;
let mut backtrace = "Possible hang detected on main threadL".to_string();
let mut backtrace = "Possible hang detected on main thread:".to_string();
let unknown = "<unknown>".to_string();
for frame in report.backtrace.iter() {
backtrace.push_str(&format!("\n{}", frame.symbols.first().unwrap_or(&unknown)));

View File

@@ -9054,8 +9054,11 @@ impl Editor {
return;
}
let focused = self.focus_handle(cx).contains_focused(cx);
let project = project.clone();
let blame = cx.new_model(|cx| GitBlame::new(buffer, project, user_triggered, cx));
let blame =
cx.new_model(|cx| GitBlame::new(buffer, project, user_triggered, focused, cx));
self.blame_subscription = Some(cx.observe(&blame, |_, _, cx| cx.notify()));
self.blame = Some(blame);
}
@@ -10055,6 +10058,10 @@ impl Editor {
let rename_editor_focus_handle = rename.editor.read(cx).focus_handle.clone();
cx.focus(&rename_editor_focus_handle);
} else {
if let Some(blame) = self.blame.as_ref() {
blame.update(cx, GitBlame::focus)
}
self.blink_manager.update(cx, BlinkManager::enable);
self.show_cursor_names(cx);
self.buffer.update(cx, |buffer, cx| {
@@ -10075,6 +10082,10 @@ impl Editor {
self.blink_manager.update(cx, BlinkManager::disable);
self.buffer
.update(cx, |buffer, cx| buffer.remove_active_selections(cx));
if let Some(blame) = self.blame.as_ref() {
blame.update(cx, GitBlame::blur)
}
self.hide_context_menu(cx);
hide_hover(self, cx);
cx.emit(EditorEvent::Blurred);

View File

@@ -88,7 +88,9 @@ pub struct GitBlame {
buffer_snapshot: BufferSnapshot,
buffer_edits: text::Subscription,
task: Task<Result<()>>,
focused: bool,
generated: bool,
changed_while_blurred: bool,
user_triggered: bool,
regenerate_on_edit_task: Task<Result<()>>,
_regenerate_subscriptions: Vec<Subscription>,
@@ -99,6 +101,7 @@ impl GitBlame {
buffer: Model<Buffer>,
project: Model<Project>,
user_triggered: bool,
focused: bool,
cx: &mut ModelContext<Self>,
) -> Self {
let entries = SumTree::from_item(
@@ -153,6 +156,8 @@ impl GitBlame {
entries,
buffer_edits,
user_triggered,
focused,
changed_while_blurred: false,
commit_details: HashMap::default(),
task: Task::ready(Ok(())),
generated: false,
@@ -186,6 +191,18 @@ impl GitBlame {
})
}
pub fn blur(&mut self, _: &mut ModelContext<Self>) {
self.focused = false;
}
pub fn focus(&mut self, cx: &mut ModelContext<Self>) {
self.focused = true;
if self.changed_while_blurred {
self.changed_while_blurred = false;
self.generate(cx);
}
}
fn sync(&mut self, cx: &mut ModelContext<Self>) {
let edits = self.buffer_edits.consume();
let new_snapshot = self.buffer.read(cx).snapshot();
@@ -298,6 +315,10 @@ impl GitBlame {
}
fn generate(&mut self, cx: &mut ModelContext<Self>) {
if !self.focused {
self.changed_while_blurred = true;
return;
}
let buffer_edits = self.buffer.update(cx, |buffer, _| buffer.subscribe());
let snapshot = self.buffer.read(cx).snapshot();
let blame = self.project.read(cx).blame_buffer(&self.buffer, None, cx);
@@ -544,7 +565,8 @@ mod tests {
.await
.unwrap();
let blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project.clone(), true, cx));
let blame =
cx.new_model(|cx| GitBlame::new(buffer.clone(), project.clone(), true, true, cx));
let event = project.next_event(cx).await;
assert_eq!(
@@ -613,7 +635,7 @@ mod tests {
.await
.unwrap();
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, cx));
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));
cx.executor().run_until_parked();
@@ -693,7 +715,7 @@ mod tests {
.await
.unwrap();
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, cx));
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));
cx.executor().run_until_parked();
@@ -842,7 +864,7 @@ mod tests {
.await
.unwrap();
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, cx));
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));
cx.executor().run_until_parked();
git_blame.update(cx, |blame, cx| blame.check_invariants(cx));

View File

@@ -47,7 +47,6 @@ mod macos {
.header("src/platform/mac/dispatch.h")
.allowlist_var("_dispatch_main_q")
.allowlist_var("_dispatch_source_type_data_add")
.allowlist_var("DISPATCH_QUEUE_PRIORITY_DEFAULT")
.allowlist_var("DISPATCH_QUEUE_PRIORITY_HIGH")
.allowlist_var("DISPATCH_TIME_NOW")
.allowlist_function("dispatch_get_global_queue")

View File

@@ -76,7 +76,7 @@ impl PlatformDispatcher for MacDispatcher {
fn dispatch_after(&self, duration: Duration, runnable: Runnable) {
unsafe {
let queue =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT.try_into().unwrap(), 0);
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH.try_into().unwrap(), 0);
let when = dispatch_time(DISPATCH_TIME_NOW as u64, duration.as_nanos() as i64);
dispatch_after_f(
when,

View File

@@ -98,8 +98,14 @@ impl PtyProcessInfo {
fn refresh(&mut self) -> Option<&Process> {
let pid = self.pid_getter.pid()?;
self.system.refresh_processes_specifics(self.refresh_kind);
self.system.process(pid)
if self
.system
.refresh_process_specifics(pid, self.refresh_kind)
{
self.system.process(pid)
} else {
None
}
}
fn load(&mut self) -> Option<ProcessInfo> {

View File

@@ -2,7 +2,7 @@
description = "The fast, collaborative code editor."
edition = "2021"
name = "zed"
version = "0.134.0"
version = "0.134.1"
publish = false
license = "GPL-3.0-or-later"
authors = ["Zed Team <hi@zed.dev>"]

View File

@@ -1 +1 @@
dev
preview

View File

@@ -52,17 +52,17 @@ zed_dir="${temp_dir}/zed$suffix.app"
# Binary
mkdir -p "${zed_dir}/bin"
cp "target/${target_triple}/release/Zed" "${zed_dir}/zed"
cp "target/${target_triple}/release/Zed" "${zed_dir}/bin/zed"
# Icons
mkdir -p "${zed_dir}/share/icons/hicolor/512x512/apps"
cp "crates/zed/resources/app-icon$suffix.png" "${zed_dir}/share/icons/hicolor/512x512/apps/zed.png"
mkdir -p "${zed_dir}/share/icons/hicolor/1024x1024/apps"
cp "crates/zed/resources/app-icon$suffix/share/icons/hicolor/1024x1024/apps/zed.png"
cp "crates/zed/resources/app-icon$suffix@2x.png" "${zed_dir}/share/icons/hicolor/1024x1024/apps/zed.png"
# .desktop
mkdir -p "${zed_dir}/share/applications"
cp "crates/zed/resources/zed$suffix.desktop" "${zed_dir}/share/applications/zed$suffix.desktop"
cp "crates/zed/resources/zed.desktop" "${zed_dir}/share/applications/zed$suffix.desktop"
if [[ "$channel" == "preview" ]]; then
sed -i "s|Name=Zed|Name=Zed Preview|g" "${zed_dir}/share/applications/zed$suffix.desktop"
elif [[ "$channel" == "nightly" ]]; then
@@ -84,4 +84,4 @@ else
fi
rm -rf "${archive}"
tar -czvf $archive -C ${temp_dir} ${zed_dir}
tar -czvf $archive -C ${temp_dir} "zed$suffix.app"