Reddit Programming – Telegram
Reddit Programming
212 subscribers
1.22K photos
125K links
I will send you newest post from subreddit /r/programming
Download Telegram
Why `git diff` sometimes hangs for 10 seconds on Windows (it's Defender's behavioral analysis, and file exclusions won't help)
https://www.reddit.com/r/programming/comments/1mqzkxv/why_git_diff_sometimes_hangs_for_10_seconds_on/

<!-- SC_OFF -->Originally posted in r/git (https://www.reddit.com/r/git). TL;DR: Git commands like git diff, git log, and git blame randomly stall for 10 seconds on Windows. It's Microsoft Defender analyzing how Git spawns its pager through named pipes/PTY emulation - not scanning files, which is why exclusions don't help. After analysis, the same commands run instantly for ~30 seconds, then stall again. The fix: disable pagers for specific commands or pipe manually. This happens in PowerShell, Git Bash, and any terminal using Git for Windows. The Mystery For months, I've been haunted by a bizarre Git performance issue on Windows 11: git diff hangs for 10 seconds before showing anything Running it again immediately: instant Wait a minute and run it again: 10 seconds But git diff | cat is ALWAYS instant The pattern was consistent across git log, git blame, any Git command that uses a pager. After about 30 seconds of inactivity, the delay returns. The Investigation What Didn't Work The fact that git diff | cat was always instant should have been a clue - if it was file cache or scanning, piping wouldn't help. But I went down the obvious path anyway: Added git.exe to Windows Defender exclusions Added less.exe to exclusions Excluded entire Git installation folder Excluded my repository folders Result: No improvement. Still the same 10-second delay on first run. The First Clue: It's Not Just Git Opening new tabs in Windows Terminal revealed the pattern extends beyond Git: PowerShell tab: always instant First Git Bash tab: 10 seconds to open Second Git Bash tab immediately after: instant Wait 30 seconds, open another Git Bash tab: 10 seconds again This wasn't about Git specifically, it was about Unix-style process creation on Windows. The Smoking Gun: Process Patterns Testing with different pagers proved it's pattern-based: # Cold start git -c core.pager=less diff # 10 seconds git -c core.pager=head diff # Instant! (cached) # After cache expires (~30 seconds) git -c core.pager=head diff # 10 seconds git -c core.pager=less diff # Instant! (cached) The specific pager being launched doesn't matter. Windows Defender is analyzing the pattern of HOW Git spawns child processes, not which program gets spawned. The Real Culprit: PTY Emulation When Git launches a pager on Windows, it: Allocates a pseudo-terminal (PTY) pair Sets up bidirectional I/O redirection Spawns the pager with this complex console setup This Unix-style PTY pattern triggers Microsoft Defender's behavioral analysis. When launching terminal tabs, Git Bash needs this same PTY emulation while PowerShell uses native console APIs. Why Exclusions Don't Work File exclusions prevent scanning file contents for known malware signatures. Behavioral analysis monitors HOW processes interact: spawning patterns, I/O redirection, PTY allocation. You can't "exclude" a behavior pattern. Windows Defender sees: "Process creating pseudo-terminal and spawning child with redirected I/O" This looks suspicious. After 10 seconds of analysis, it determines: "This is safe Git behavior". Caches approval for around 30 seconds (observed in my tests). The 10-Second Timeout The delay precisely matches Microsoft Defender's documented "cloud block timeout", the time it waits for a cloud verdict on suspicious behavior. Default: 10 seconds. [1] Test It Yourself Here's the exact test showing the ~30 second cache: $ sleep 35; time git diff; sleep 20; time git diff; sleep 35; time git diff real 0m10.105s user 0m0.015s sys 0m0.000s real 0m0.045s user 0m0.015s sys 0m0.015s real 0m10.103s user 0m0.000s sys 0m0.062s There's a delay in the cold case even though there's no changes in the repo (empty output). After 35 seconds: slow (10s). After 20 seconds: fast (cached). After 35
seconds: slow again. Solutions 1. Disable Pager for git diff Configure Git to bypass the pager for diff: git config --global pager.diff false # Then pipe manually when you need pagination: # git diff | less 2. Manual Piping Skip Git's internal pager entirely: git diff --color=always | less -R 3. Alias for Common Commands alias gd='git diff --color=always | less -R' 4. Switch to WSL2 WSL2 runs in a VM where Defender doesn't monitor internal process behavior Update 1: Tested Git commands in PowerShell - they're also affected by the 10-second delay: PS > foreach ($sleep in 35, 20, 35) { Start-Sleep $sleep $t = Get-Date git diff "After {0}s wait: {1:F1}s" -f $sleep, ((Get-Date) - $t).TotalSeconds } After 35s wait: 10.2s After 20s wait: 0.1s After 35s wait: 10.3s This makes sense: Git for Windows still creates PTYs for pagers regardless of which shell calls it. The workarounds remain the same - disable pagers or pipe manually. Update 2: Thanks to u/bitzap (https://www.reddit.com/u/bitzap)_sr for clarifying what Defender actually sees: MSYS2 implements PTYs using Windows named pipes. So from Defender's perspective, it's analyzing Git creating named pipes with complex bidirectional I/O and spawning a child, that's the suspicious pattern. Environment: Windows 11 24H2, Git for Windows 2.49.0 [1] https://learn.microsoft.com/en-us/defender-endpoint/configure-cloud-block-timeout-period-microsoft-defender-antivirus <!-- SC_ON --> submitted by /u/Resident_Gap_3008 (https://www.reddit.com/user/Resident_Gap_3008)
[link] (https://www.reddit.com/r/git/comments/1mq6r0y/why_git_diff_in_git_bash_sometimes_takes_10/) [comments] (https://www.reddit.com/r/programming/comments/1mqzkxv/why_git_diff_sometimes_hangs_for_10_seconds_on/)
Programming Complexity and Other EIA
https://www.reddit.com/r/programming/comments/1mr8vf9/programming_complexity_and_other_eia/

<!-- SC_OFF -->Good morning, everyone. My name is Alisson Oliveira, and I am conducting research on measuring the complexity of intellectual work (Explicit Intellectual Activities - EIA), such as in the process of coding and software maintenance. I would like to know if anyone is familiar with any work similar to [1], where a dataset is used as an empirical test to compare human assessment with some scientific measurement technique. The technique I developed is generic and can be applied to any EIA - for example, in industrial property patents [2] - but since the technique relies on empirical data, a good dataset is essential for measurement. If you know of any similar work or datasets that I could use, please comment below. Thank you, and have a great week! Best regards, Alisson [1] https://sol.sbc.org.br/index.php/erigo/article/view/32208/32008 [2] https://jppres.com/jppres/pdf/vol12/jppres23.1859_12.5.852.pdf <!-- SC_ON --> submitted by /u/Affectionate_Past402 (https://www.reddit.com/user/Affectionate_Past402)
[link] (https://sol.sbc.org.br/index.php/erigo/article/view/32208/32008) [comments] (https://www.reddit.com/r/programming/comments/1mr8vf9/programming_complexity_and_other_eia/)
C# vs Java int: Primitive type semantics, runtime behavior, and tribal knowledge
https://www.reddit.com/r/programming/comments/1mrbeuz/c_vs_java_int_primitive_type_semantics_runtime/

<!-- SC_OFF -->How a debate over C# vs Java int and specs led to the Lₐₓ/Lₐₜ/R (LAX/LAT/R) taxonomy: a framework for type classification. <!-- SC_ON --> submitted by /u/_msiyer_ (https://www.reddit.com/user/_msiyer_)
[link] (https://msiyer.com/csharp-vs-java-int-primitive-type-semantics-runtime-behavior-and-tribal-knowledge/) [comments] (https://www.reddit.com/r/programming/comments/1mrbeuz/c_vs_java_int_primitive_type_semantics_runtime/)
Branch prediction: Why CPUs can't wait? - namvdo's blog
https://www.reddit.com/r/programming/comments/1mrjr1m/branch_prediction_why_cpus_cant_wait_namvdos_blog/

<!-- SC_OFF -->Recently, I’ve learned about a feature that makes the CPU work more efficiently, and knowing it can make our code more performant. The technique called “branch prediction” is available in modern CPUs, and it’s why your “if” statement might secretly slow down your code. I tested 2 identical algorithms -- same logic, same data, but one ran 60% faster by just changing the data order. Data organization matters; let's learn more about this in this blog post! <!-- SC_ON --> submitted by /u/vannam0511 (https://www.reddit.com/user/vannam0511)
[link] (https://namvdo.ai/cpu-branch-prediction/) [comments] (https://www.reddit.com/r/programming/comments/1mrjr1m/branch_prediction_why_cpus_cant_wait_namvdos_blog/)
Experimenting with Dyad (self-hosted coding assistant) using Gemini + Ollama 3
https://www.reddit.com/r/programming/comments/1mrqlc0/experimenting_with_dyad_selfhosted_coding/

<!-- SC_OFF -->I recently tested out Dyad, a self-hosted, open-source coding assistant. It can connect to external models like Google Gemini, but it also supports local inference through tools like Ollama 3. I documented the whole setup (Linux) and then pushed it through a series of programming challenges to see how practical vibecoding actually is: generating a static website building a Kahoot-style clone and even rebuilding one of my own projects (an animated 3D map in Three.js) For comparison, I ran Dyad both with Gemini (cloud) and Ollama 3 locally on my PC. The local run was slower and more limited, but still surprisingly capable for certain tasks. Curious if anyone else has experimented with self-hosted coding assistants. Did you find them practical for real projects, or more of a novelty at this stage? <!-- SC_ON --> submitted by /u/OnlyDemor (https://www.reddit.com/user/OnlyDemor)
[link] (https://youtu.be/rhnhtzhDqV4) [comments] (https://www.reddit.com/r/programming/comments/1mrqlc0/experimenting_with_dyad_selfhosted_coding/)
New Search Algorithm 1.4x faster than binary (SIBS)
https://www.reddit.com/r/programming/comments/1ms4pqr/new_search_algorithm_14x_faster_than_binary_sibs/

<!-- SC_OFF -->Developed Stochastic Interval Binary Search using multi-armed bandits - achieved iteration reduction in 25/25 test cases up to 10M elements. <!-- SC_ON --> submitted by /u/Charming-Falcon6276 (https://www.reddit.com/user/Charming-Falcon6276)
[link] (https://github.com/Genius740Code/SIBS) [comments] (https://www.reddit.com/r/programming/comments/1ms4pqr/new_search_algorithm_14x_faster_than_binary_sibs/)
A case for fleeting websites with agentic coding
https://www.reddit.com/r/programming/comments/1msbcjn/a_case_for_fleeting_websites_with_agentic_coding/

<!-- SC_OFF -->AI isn't all doom & gloom - it can genuinely bring joy too! Without agentic coding, I would never have had found the time to develop this silly little fan page I made! And it actually made some people happy - how great is that Sure in the end only a couple hundred people checked it out, but that was well worth the effort I had to put into it. I will gladly use agentic coding for other temporary websites again! <!-- SC_ON --> submitted by /u/avataw (https://www.reddit.com/user/avataw)
[link] (https://andrewru.com/posts/agent-mode-for-fun) [comments] (https://www.reddit.com/r/programming/comments/1msbcjn/a_case_for_fleeting_websites_with_agentic_coding/)