helloadhavan/github_issues huggingface dataset:
Repository: vercel/next.js
Pull request: [turbopack] optimize the TurboMalloc threadlocals

Improve memory tracking in turbo-tasks-malloc

### What?

Made the thread_local initializer `const` compatible.  This skips per-thread lazy initialization of the threadlocal datastructure which allows us to skip a small amount of bootstrapping logic.

Additionally, this allows us to access the native llvm implementation of threadlocals which can improve performance.  See https://matklad.github.io/2020/10/03/fast-thread-locals-in-rust.html

### Performance

Confusingly, the benchmarks are not positive, but vercel-site appears to be.  Perhaps the 'small' benchmarks are just too small/

![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/AwJ29EfoPcPdLSwCZxAz/51a29e9b-d653-4ba1-8e18-063b6a60c3a9.png)



Closes PACK-4803

Changed files:
filename: turbopack/crates/turbo-tasks-malloc/src/counter.rs
patch: @@ -6,6 +6,10 @@ use std::{
 
 use crate::AllocationCounters;
 
+/// Tracks the current total amount of memory allocated through all the [ThreadLocalCounter]
+/// instances.  This is an overestimate as individual threads 'preallocate' a [TARGET_BUFFER] bytes
+/// to reduce the number of global synchronizations.  This means at any given time this might
+/// overcount by up to [MAX_BUFFER] bytes for each thread.
 static ALLOCATED: AtomicUsize = AtomicUsize::new(0);
 const KB: usize = 1024;
 /// When global counter is updates we will keep a thread-local buffer of this
@@ -26,6 +30,12 @@ struct ThreadLocalCounter {
 }
 
 impl ThreadLocalCounter {
+    const fn new() -> Self {
+        Self {
+            buffer: 0,
+            allocation_counters: AllocationCounters::new(),
+        }
+    }
     fn add(&mut self, size: usize) {
         self.allocation_counters.allocations += size;
         self.allocation_counters.allocation_count += 1;
@@ -88,7 +98,7 @@ impl ThreadLocalCounter {
 }
 
 thread_local! {
-  static LOCAL_COUNTER: UnsafeCell<ThreadLocalCounter> = UnsafeCell::new(ThreadLocalCounter::default());
+  static LOCAL_COUNTER: UnsafeCell<ThreadLocalCounter> = const {UnsafeCell::new(ThreadLocalCounter::new())};
 }
 
 pub fn get() -> usize {

filename: turbopack/crates/turbo-tasks-malloc/src/lib.rs
patch: @@ -34,6 +34,15 @@ pub struct AllocationCounters {
 }
 
 impl AllocationCounters {
+    const fn new() -> Self {
+        Self {
+            allocation_count: 0,
+            deallocation_count: 0,
+            allocations: 0,
+            deallocations: 0,
+            _not_send: PhantomData {},
+        }
+    }
     pub fn until_now(&self) -> AllocationInfo {
         let new = TurboMalloc::allocation_counters();
         AllocationInfo {
@@ -50,6 +59,7 @@ impl AllocationCounters {
 pub struct TurboMalloc;
 
 impl TurboMalloc {
+    // Returns the current amount of memory
     pub fn memory_usage() -> usize {
         get()
     }
Repository: facebook/react
Pull request: remove flow check in electron app.js

When we were upgrading flow in https://github.com/facebook/react/commit/6ddcbd4f96cb103de3978617a53c200baf5b546c we added `$FlowFixMe` for some parameters in this file. However, this file is not compiled at all, and the `:` syntax breaks the code.

This PR removes the flow check in this file

Changed files:
filename: packages/react-devtools/app.js
patch: @@ -3,8 +3,6 @@
  *
  * This source code is licensed under the MIT license found in the
  * LICENSE file in the root directory of this source tree.
- *
- * @flow
  */
 
 const {app, BrowserWindow} = require('electron'); // Module to create native browser window.
@@ -40,17 +38,12 @@ app.on('ready', function () {
   }
 
   // https://stackoverflow.com/questions/32402327/
-  // $FlowFixMe[incompatible-use] found when upgrading Flow
-  mainWindow.webContents.on(
-    'new-window',
-    function (event: $FlowFixMe, url: $FlowFixMe) {
-      event.preventDefault();
-      require('electron').shell.openExternal(url);
-    },
-  );
+  mainWindow.webContents.on('new-window', function (event, url) {
+    event.preventDefault();
+    require('electron').shell.openExternal(url);
+  });
 
   // and load the index.html of the app.
-  // $FlowFixMe[incompatible-use] found when upgrading Flow
   mainWindow.loadURL('file://' + __dirname + '/app.html'); // eslint-disable-line no-path-concat
   // $FlowFixMe[incompatible-use] found when upgrading Flow
   mainWindow.webContents.executeJavaScript(
@@ -61,7 +54,6 @@ app.on('ready', function () {
   );
 
   // Emitted when the window is closed.
-  // $FlowFixMe[incompatible-use] found when upgrading Flow
   mainWindow.on('closed', function () {
     mainWindow = null;
   });
Repository: denoland/deno
Pull request: fix: do not panic when fetching invalid file url on Windows

I tried adding a test, but it's not possible due to a debug assertion in the url crate (https://github.com/servo/rust-url/issues/505)

Closes https://github.com/denoland/deno/issues/27258

Changed files:
filename: Cargo.lock
patch: @@ -1623,6 +1623,7 @@ dependencies = [
  "bytes",
  "data-url",
  "deno_core",
+ "deno_path_util",
  "deno_permissions",
  "deno_tls",
  "dyn-clone",

filename: ext/fetch/Cargo.toml
patch: @@ -18,6 +18,7 @@ base64.workspace = true
 bytes.workspace = true
 data-url.workspace = true
 deno_core.workspace = true
+deno_path_util.workspace = true
 deno_permissions.workspace = true
 deno_tls.workspace = true
 dyn-clone = "1"

filename: ext/fetch/lib.rs
patch: @@ -41,6 +41,8 @@ use deno_core::OpState;
 use deno_core::RcRef;
 use deno_core::Resource;
 use deno_core::ResourceId;
+use deno_path_util::url_from_file_path;
+use deno_path_util::PathToUrlError;
 use deno_permissions::PermissionCheckError;
 use deno_tls::rustls::RootCertStore;
 use deno_tls::Proxy;
@@ -172,6 +174,8 @@ pub enum FetchError {
   NetworkError,
   #[error("Fetching files only supports the GET method: received {0}")]
   FsNotGet(Method),
+  #[error(transparent)]
+  PathToUrl(#[from] PathToUrlError),
   #[error("Invalid URL {0}")]
   InvalidUrl(Url),
   #[error(transparent)]
@@ -436,7 +440,7 @@ where
       let permissions = state.borrow_mut::<FP>();
       let path = permissions.check_read(&path, "fetch()")?;
       let url = match path {
-        Cow::Owned(path) => Url::from_file_path(path).unwrap(),
+        Cow::Owned(path) => url_from_file_path(&path)?,
         Cow::Borrowed(_) => url,
       };
 

filename: runtime/errors.rs
patch: @@ -696,6 +696,7 @@ fn get_fetch_error(error: &FetchError) -> &'static str {
     FetchError::Permission(e) => get_permission_check_error_class(e),
     FetchError::NetworkError => "TypeError",
     FetchError::FsNotGet(_) => "TypeError",
+    FetchError::PathToUrl(_) => "TypeError",
     FetchError::InvalidUrl(_) => "TypeError",
     FetchError::InvalidHeaderName(_) => "TypeError",
     FetchError::InvalidHeaderValue(_) => "TypeError",
Repository: facebook/react
Pull request: Test :Add a small test for ReactTestUtils to find rendered component with type in document

I tried to write  test for the   ReactTestUtils to find rendered component with type in document

Tests before this PR

![Windows PowerShell 4_13_2022 11_35_24 PM](https://user-images.githubusercontent.com/72331432/163243620-40eb753c-4136-4793-a628-efcf9e004562.png)


Tests after this PR 

![Windows PowerShell 4_13_2022 11_35_30 PM](https://user-images.githubusercontent.com/72331432/163244704-cd17f0e3-7289-4794-895a-be03753e46de.png)



Changed files:
filename: packages/react-dom/src/__tests__/ReactTestUtils-test.js
patch: @@ -463,4 +463,19 @@ describe('ReactTestUtils', () => {
     ReactTestUtils.renderIntoDocument(<Component />);
     expect(mockArgs.length).toEqual(0);
   });
+  it('should find rendered component with type in document', () => {
+    class MyComponent extends React.Component {
+      render() {
+        return true;
+      }
+    }
+
+    const instance = ReactTestUtils.renderIntoDocument(<MyComponent />);
+    const renderedComponentType = ReactTestUtils.findRenderedComponentWithType(
+      instance,
+      MyComponent,
+    );
+
+    expect(renderedComponentType).toBe(instance);
+  });
 });
Repository: nodejs/node
Pull request: tools: use `util.parseArgs` in `lint-md`

`node:util` provides a `parseArgs` export, so this PR switches `lint-md` to use it, as it's (IMO) a cleaner way to read arguments.

Changed files:
filename: tools/lint-md/lint-md.mjs
patch: @@ -1,4 +1,5 @@
-import fs from 'fs';
+import fs from 'node:fs';
+import { parseArgs } from 'node:util';
 
 import { unified } from 'unified';
 import remarkParse from 'remark-parse';
@@ -7,20 +8,18 @@ import presetLintNode from 'remark-preset-lint-node';
 import { read } from 'to-vfile';
 import { reporter } from 'vfile-reporter';
 
-const paths = process.argv.slice(2);
+const { values: { format }, positionals: paths } = parseArgs({
+  options: {
+    format: { type: 'boolean', default: false },
+  },
+  allowPositionals: true,
+});
 
 if (!paths.length) {
-  console.error('Usage: lint-md.mjs <path> [<path> ...]');
+  console.error('Usage: lint-md.mjs [--format] <path> [<path> ...]');
   process.exit(1);
 }
 
-let format = false;
-
-if (paths[0] === '--format') {
-  paths.shift();
-  format = true;
-}
-
 const linter = unified()
   .use(remarkParse)
   .use(presetLintNode)
Repository: vercel/next.js
Pull request: [test] Only run build_and_deploy once for PRs from upstream

PRs from upstream (i.e. not from forks) will always trigger a push and pull_request event. We only want one (the push). The pull_request event is not usable by vercel-packages since the commit will not have workflows associated with it. This also matches the behavior from before we started [running build_and_deploy on PRs from forks](https://github.com/vercel/next.js/issues/78737).

Keep in mind that `build-and-deploy` will now temporarily be marked as complete thus passing the GitHub required check. This is only a problem if `build-and-test` finished before the actual `build-and-deploy` from the `push` event. I tried it failing the `buildPassed` from the PR event but that marks the whole PR as failed in GH. Not a pleasent UX.

## Test plan

- [x] build_and_deploy runs only once for this PR (PR from upstream): https://github.com/vercel/next.js/actions/workflows/build_and_deploy.yml?query=branch%3Asebbie%2Fpr-from-upstream
- [x] build_and_deploy runs on [PR from fork](https://github.com/vercel/next.js/pull/80327): https://github.com/vercel/next.js/actions/runs/15542806123/job/43757359615?pr=80327

Changed files:
filename: .github/workflows/build_and_deploy.yml
patch: @@ -28,6 +28,9 @@ env:
 jobs:
   deploy-target:
     runs-on: ubuntu-latest
+    # Don't trigger this job on `pull_request` events from upstream branches.
+    # Those would already run this job on the `push` event
+    if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork }}
     outputs:
       value: ${{ steps.deploy-target.outputs.value }}
     steps:
@@ -693,7 +696,7 @@ jobs:
 
   buildPassed:
     needs: ['deploy-target', 'build', 'build-wasm', 'build-native']
-    if: always()
+    if: ${{ always() && needs.deploy-target.outputs.value != '' }}
     name: thank you, build
     runs-on: ubuntu-latest
     steps:
Repository: facebook/react
Pull request: [difftrain] Remove dependency on node-fetch

`fetch` is now provided by github-scripts implicitly in https://github.com/actions/github-script/releases/tag/v6.4.0, so this was causing a duplicate declaration error.

Changed files:
filename: .github/workflows/commit_artifacts.yml
patch: @@ -8,17 +8,11 @@ jobs:
   download_artifacts:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/setup-node@v3
-        with:
-          node-version: 18.x
-      - run: npm init -y
-      - run: npm install node-fetch@2
       - name: Download and unzip artifacts
         uses: actions/github-script@v6
         with:
           script: |
             const cp = require('child_process');
-            const fetch = require('node-fetch');
 
             function sleep(ms) {
               return new Promise(resolve => setTimeout(resolve, ms));
Repository: nodejs/node
Pull request: os: improve path check with direct index access

Replaced String.prototype.endsWith with manual string length and index checks for performance improvements.

Changed files:
filename: lib/os.js
patch: @@ -26,7 +26,6 @@ const {
   Float64Array,
   NumberParseInt,
   ObjectDefineProperties,
-  StringPrototypeEndsWith,
   StringPrototypeSlice,
   SymbolToPrimitive,
 } = primordials;
@@ -184,9 +183,9 @@ function tmpdir() {
            process.env.TMP ||
            (process.env.SystemRoot || process.env.windir) + '\\temp';
 
-    if (path.length > 1 && StringPrototypeEndsWith(path, '\\') &&
-        !StringPrototypeEndsWith(path, ':\\'))
+    if (path.length > 1 && path[path.length - 1] === '\\' && path[path.length - 2] !== ':') {
       return StringPrototypeSlice(path, 0, -1);
+    }
 
     return path;
   }
Repository: vercel/next.js
Pull request: [dev-overlay] Publish as production bundle

`pnpm dev` will continue to serve a development bundle.
`pnpm build` will now produce a production bundle.
CI will therefore run tests with the production bundle.

Published Next DevTools bundle size is now 450kB (down from 1.1MB).

Changed files:
filename: packages/next/taskfile.js
patch: @@ -3136,8 +3136,7 @@ export async function next_bundle_devtools(task, opts) {
   await task.source('dist').webpack({
     watch: opts.dev,
     config: require('./next-devtools.webpack-config')({
-      // TODO: Use prod variant
-      dev: true,
+      dev: opts.dev,
     }),
     name: 'next-bundle-devtools-dev',
   })
Repository: ggml-org/llama.cpp
Pull request: Prefilling assistant message in openai compatible API

This adds support for prefilling assistant response (or its thought process) using the OpenAI compatible API.

The feature is used for example by Claude.

It can be tested using open-webui or with the following curl command:
```
curl http://localhost:8080/apply-template \
-H "Content-Type: application/json" \
-H "Authorization: Bearer no-key" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
 {
    "role": "system",
    "content": "SYSTEM"
 },
 {
    "role": "user",
    "content": "USERMESSAGE"
 },
 {
    "role": "assistant",
    "content": "ASSISTANT"
 }
]
}'
```

**Example advanced scenario**: time limit for the thinking process
- launch a reasoning model and stop its thought early
- append `</think>` to its partial response
- prefill the response and let it continue generating tokens

Changed files:
filename: examples/server/utils.hpp
patch: @@ -642,9 +642,31 @@ static json oaicompat_completion_params_parse(
         throw std::runtime_error("Cannot use custom grammar constraints with tools.");
     }
 
+    // if the assistant message appears at the end of list, we do not add end-of-turn token
+    // for ex. this can be useful to modify the reasoning process in reasoning models
+    bool prefill_assistant_message = !inputs.messages.empty() && inputs.messages.back().role == "assistant";
+    common_chat_msg last_message;
+    if (prefill_assistant_message) {
+        last_message = inputs.messages.back();
+        inputs.messages.pop_back();
+
+        /* sanity check, max one assistant message at the end of the list */
+        if (!inputs.messages.empty() && inputs.messages.back().role == "assistant"){
+            throw std::runtime_error("Cannot have 2 or more assistant messages at the end of the list.");
+        }
+
+        inputs.extract_reasoning = false;
+        inputs.add_generation_prompt = true;
+    }
+
     // Apply chat template to the list of messages
     auto chat_params = common_chat_templates_apply(tmpls, inputs);
 
+    /* Append assistant prefilled message */
+    if (prefill_assistant_message) {
+         chat_params.prompt += last_message.content;
+    }
+
     llama_params["chat_format"]      = static_cast<int>(chat_params.format);
     llama_params["prompt"]           = chat_params.prompt;
     if (!chat_params.grammar.empty()) {
Repository: denoland/deno
Pull request: test(ext/node): fix flaky node/http2.createServer() test

fixes #27154

Note: I couldn't reproduce the flakiness in local arm mac. I'm going to test the fix in CI several times.

Changed files:
filename: tests/unit_node/http2_test.ts
patch: @@ -152,15 +152,18 @@ Deno.test("[node/http2.createServer()]", {
   // TODO(satyarohith): enable the test on windows.
   ignore: Deno.build.os === "windows",
 }, async () => {
+  const serverListening = Promise.withResolvers<number>();
   const server = http2.createServer((_req, res) => {
     res.setHeader("Content-Type", "text/html");
     res.setHeader("X-Foo", "bar");
     res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
     res.write("Hello, World!");
     res.end();
   });
-  server.listen(0);
-  const port = (server.address() as net.AddressInfo).port;
+  server.listen(0, () => {
+    serverListening.resolve((server.address() as net.AddressInfo).port);
+  });
+  const port = await serverListening.promise;
   const endpoint = `http://localhost:${port}`;
 
   const response = await curlRequest([
Repository: facebook/react
Pull request: Don't recommend deprecated debugger script

yarn debug-test is now deprecated in React package.json. It has been replaced by yarn test --debug.


https://user-images.githubusercontent.com/72331432/219268188-8ff5dd42-da2b-434c-83be-72a9d258ee98.mp4



Changed files:
filename: .github/PULL_REQUEST_TEMPLATE.md
patch: @@ -9,7 +9,7 @@
   3. If you've fixed a bug or added code that should be tested, add tests!
   4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development.
   5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`.
-  6. If you need a debugger, run `yarn debug-test --watch TestName`, open `chrome://inspect`, and press "Inspect".
+  6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect".
   7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`).
   8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files.
   9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
Repository: ggml-org/llama.cpp
Pull request: Code health: Remove invalid `portPos` specifiers from graph dumping to dot files

Neither "g" nor "x" are valid portPos specifiers per the official [graphviz documents](https://graphviz.org/docs/attr-types/portPos/):

> If a compass point is used, it must have the form "n","ne","e","se","s","sw","w","nw","c","_".

I tested locally for it to fall back to default portPos specifier if an invalid portPos is specified. As a consequence, we can remove associated code. Tested it locally to still yield valid dot files, which compile now without the "port x unrecognized" warnings (see also #589 ).

<img width="1300" height="712" alt="image" src="https://github.com/user-attachments/assets/885afcf3-8718-45b2-bd6d-1f0237855556" />



Changed files:
filename: ggml/src/ggml.c
patch: @@ -6640,20 +6640,18 @@ static struct ggml_tensor * ggml_graph_get_parent(const struct ggml_cgraph * cgr
 static void ggml_graph_dump_dot_node_edge(FILE * fp, const struct ggml_cgraph * gb, struct ggml_tensor * node, struct ggml_tensor * parent, const char * label)  {
     struct ggml_tensor * gparent = ggml_graph_get_parent(gb, node);
     struct ggml_tensor * gparent0 = ggml_graph_get_parent(gb, parent);
-    fprintf(fp, "  \"%p\":%s -> \"%p\":%s [ arrowhead = %s; style = %s; label = \"%s\"; ]\n",
+    fprintf(fp, "  \"%p\" -> \"%p\" [ arrowhead = %s; style = %s; label = \"%s\"; ]\n",
             gparent0 ? (void *) gparent0 : (void *) parent,
-            gparent0 ? "g" : "x",
             gparent ? (void *) gparent : (void *) node,
-            gparent ? "g" : "x",
             gparent ? "empty" : "vee",
             gparent ? "dashed" : "solid",
             label);
 }
 
 static void ggml_graph_dump_dot_leaf_edge(FILE * fp, struct ggml_tensor * node, struct ggml_tensor * parent, const char * label)  {
-    fprintf(fp, "  \"%p\":%s -> \"%p\":%s [ label = \"%s\"; ]\n",
-            (void *) parent, "x",
-            (void *) node, "x",
+    fprintf(fp, "  \"%p\" -> \"%p\" [ label = \"%s\"; ]\n",
+            (void *) parent,
+            (void *) node,
             label);
 }
Repository: ggml-org/llama.cpp
Pull request: context : restore preemptive sched reset when LLAMA_SET_ROWS=0

fix #14863

Changed files:
filename: src/llama-context.cpp
patch: @@ -105,7 +105,7 @@ llama_context::llama_context(
 
     {
         const char * LLAMA_SET_ROWS = getenv("LLAMA_SET_ROWS");
-        const bool supports_set_rows = LLAMA_SET_ROWS ? (atoi(LLAMA_SET_ROWS) != 0) : false;
+        supports_set_rows = LLAMA_SET_ROWS ? (atoi(LLAMA_SET_ROWS) != 0) : false;
 
         if (!supports_set_rows && !cparams.kv_unified) {
             LLAMA_LOG_WARN("%s: non-unified KV cache requires ggml_set_rows() - forcing unified KV cache\n", __func__);
@@ -899,6 +899,12 @@ int llama_context::encode(const llama_batch & batch_inp) {
         }
     }
 
+    if (!supports_set_rows) {
+        // Reset state for the next token before backend sync, to allow the CPU activities in the reset to
+        // overlap with device computation.
+        ggml_backend_sched_reset(sched.get());
+    }
+
     // TODO: hacky solution
     if (model.arch == LLM_ARCH_T5 && t_embd) {
         //cross.t_embd = t_embd;
@@ -1229,6 +1235,12 @@ int llama_context::decode(const llama_batch & batch_inp) {
     // wait for the computation to finish (automatically done when obtaining the model output)
     //synchronize();
 
+    if (!supports_set_rows) {
+        // Reset state for the next token before backend sync, to allow the CPU activities in the reset to
+        // overlap with device computation.
+        ggml_backend_sched_reset(sched.get());
+    }
+
     return 0;
 }
 

filename: src/llama-context.h
patch: @@ -287,6 +287,10 @@ struct llama_context {
 
     bool has_evaluated_once = false;
 
+    // env: LLAMA_SET_ROWS (temporary)
+    // ref: https://github.com/ggml-org/llama.cpp/pull/14285
+    bool supports_set_rows = false;
+
     // perf
     mutable int64_t t_start_us  = 0;
     mutable int64_t t_load_us   = 0;
Repository: facebook/react
Pull request: Add `scale` as a unitless property

## Summary

CSS has a new property called `scale` (`scale: 2` is a shorthand for `transform: scale(2)`).

In vanilla JavaScript, we can do the following:

```js
document.querySelector('div').scale = 2;
```

which will make the `<div>` twice as big. So in JavaScript, it is possible to pass a plain number.
However, in React, the following does not work currently:


```js
<div style={{scale: 2}}>
```

because `scale` is not in the list of unitless properties. This PR adds `scale` to the list.


## How did you test this change?

I built `react` and `react-dom` from source and copied it into the node_modules of my project and verified that now `<div style={{scale: 2}}>` does indeed work whereas before it did not.

Changed files:
filename: packages/react-dom-bindings/src/shared/CSSProperty.js
patch: @@ -40,6 +40,7 @@ export const isUnitlessNumber = {
   opacity: true,
   order: true,
   orphans: true,
+  scale: true,
   tabSize: true,
   widows: true,
   zIndex: true,