sharjeelyunus/github-issues-dataset huggingface dataset:
Repository: go
Issue: strings: optimize WriteTo to use an intermediate buffer for large strings
Labels: Performance

Using `go1.5`

NOTE: This issue used to be about using an intermediate buffer in io.WriteString, but will instead perform the optimization in strings.Reader.WriteTo instead. The description in this issue still refers to WriteString, but the performance numbers will probably be the same once applied to strings.Reader.WriteTo.
## 

Currently WriteString does `w.Write([]byte(s))` if `w` is not a `stringWriter`. This causes a memory allocation proportional to len(s). Instead, we should use an intermediate buffer for large strings.

Using this test code:

``` go
var (
    large = strings.Repeat("the quick brown fox jumped over the lazy dog", 1024*1024)
    writerOnly = struct{ io.Writer }{ioutil.Discard}
)

// WriteString2 is modified from io.WriteString to use an
// intermediate buffer for large strings.
func WriteString2(w io.Writer, s string) (n int, err error) {
    const chunkSize = 32*1024
    if sw, ok := w.(interface {WriteString(s string) (n int, err error)}); ok {
        return sw.WriteString(s)
    }
    if len(s) < chunkSize {
        return w.Write([]byte(s))
    }

    buf := make([]byte, chunkSize)
    for len(s) > 0 {
        cnt := copy(buf, s)
        s = s[cnt:]
        cnt, err = w.Write(buf[:cnt])
        n += cnt
        if err != nil {
            break
        }
    }
    return n, err
}

func BenchmarkWriteString(b *testing.B) {
    b.ReportAllocs()
    for i := 0; i < b.N; i++ {
        if _, err := io.WriteString(writerOnly, large); err != nil {
            b.Error(err)
        }
    }
}

func BenchmarkWriteString2(b *testing.B) {
    b.ReportAllocs()
    for i := 0; i < b.N; i++ {
        if _, err := WriteString2(writerOnly, large); err != nil {
            b.Error(err)
        }
    }
}
```

We can get the number of bytes allocated to be capped at some maximum:

```
BenchmarkWriteString-4       200       6482427 ns/op    46137405 B/op          2 allocs/op
BenchmarkWriteString2-4      500       2437841 ns/op       32784 B/op          2 allocs/op
```

I was pleasantly surprised that the runtime also decreased, but this may be because the small buffer fits entirely in the cache.
Repository: opencv
Issue: CMake find_package across 2.x and 3.x
Labels: category: build/install,affected: 2.4,affected: 3.4,RFC

I have an app that is compatible with OpenCV >=2.4.8 as well as the 3.x branch. Previous to 3.1.0, a
`find_package(OpenCV 2.4.8 REQUIRED core imgproc highgui objdetect)`
would succeed with an installed OpenCV 2.4.8 (or 2.4.11 or whatever) and 3.0.0.

However, 932043fdc2e827f715a71053f9d3de479f8c0c6d broke this by returning `PACKAGE_VERSION_COMPATIBLE False` if the major versions don't match (i.e. if requesting 2.4.8, and 3.1.0 is installed).

It seems like there is no way in CMake to tell it "My app is compatible with either >=2.4.8 or 3.x", to make CMake happy with finding either. I can't find a way to do it so I don't think it's possible.

Do you really want this? I realise it's a trade-off. But I think my use case is not that rare. Do you really want to break everybody that has software that is compatible with 2.4.x as well as 3.x?

Sometimes you just can't fully upgrade to 3.x yet, for example Ubuntu 14.04 LTS is on 2.4.x so I think a lot of people still need to support that, but at the same time a lot of my users are on OpenCV 3.x, so it sucks having them to install 2.4.x. Also there is no pre-built binaries for VS2015 for the latest 2.4.12 release so I either have to provide them by myself or have the user compile it (which is not really an option).

I would just like to open a discussion on this and get some feedback. Thanks! :-)
Repository: three.js
Issue: Feature Request - Decals that work with animated meshes
Labels: Enhancement

Currently decals (DecalGeometry.js) do not work with animated meshes.

I am peering into the code to see how difficult it would be to implement this.  It appears maybe animations are done at the shader level, so I'm getting increasingly discouraged the more I'm trying to analyze this.

I'm sure many would appreciate this enhancement!

Thanks
Repository: go
Issue: x/mobile/event/touch: cancellation and gestures
Labels: mobile

As mentioned on golang.org/cl/18180:

iOS cancels a touch when a gesture is detected. We don't currently report touch cancellation, nor do we report gestures.

Is a portable iOS/Android API for gestures possible? If not, should gestures be turned off? If they are, are there any cancelled events any more?
Repository: youtube-dl
Issue: Add Bittorent Bundle
Labels: site-support-request

https://bundles.bittorrent.com/
For most film the site provide a trailer.
The url is in audio/video tag, you just have to change the end of the url with the filename you want (which are at the end of the page, kindly provided by the site) to retrieve the full film/album.
Example:

```
https://bundles.bittorrent.com/bundles/killswitch
```

Which should give you this url:

```
 https://s3.amazonaws.com/content-bundles/production-df0ec56d-0fbb-bc2c-11e7-354ff3af9c4e/445f077458b8583394423c53b88b5019f861ab0c9753b398dbf2396a88df1f66/xcode/Killswitch/Killswitch - Documentary Trailer.mp4
```

This only the trailer, now if you want the full film, just take the name of the file at the bottom of the page and replace it in the url like so:

```
 https://s3.amazonaws.com/content-bundles/production-df0ec56d-0fbb-bc2c-11e7-354ff3af9c4e/445f077458b8583394423c53b88b5019f861ab0c9753b398dbf2396a88df1f66/xcode/Killswitch/Killswitch_BT-Launch_20151019-8.5Mbs.mp4
```
Repository: go
Issue: proposal: net/http: configurable Server.WriteBufferSize
Labels: Proposal

Hi, in our most cases, the http written bytes more than 4<<10, so we need set bufio Read/Write buffer size and connection  SNDBUF/RCVBUF ?

Also we think this change is appropriate, does go plan to support this?
Repository: go
Issue: runtime/internal/atomic: consider making Xadd panic on underflow
Labels: NeedsFix,compiler/runtime

I've sunk a lot of time in to debugging Xadds in the runtime that unintentionally underflow and cause the unsigned number to wrap, leading to some (often subtle) horrible thing happening later. This debugging effort means the runtime is now sprinkled with underflow checks in many places where it calls Xadd.

We should consider making Xadd itself do this check, or introducing another variant that does. One caveat is that we currently don't have a signed version of Xadd, so there are places where we use it on a *uint32, but cast that unsigned value to a signed value everywhere we use it. In this case we definitely don't want to panic on unsigned underflow, so we should introduce a signed Xadd for these that takes a *int32 and doesn't do this check (though it could panic on signed wrap-around).

/cc @michaelmatloob @rsc @dvyukov for any thoughts.
Repository: TypeScript
Issue: tsc removes comments preceding 'export = ...' unless extra newline follows the comment
Labels: Bug,Help Wanted

The tsc compiler with remove comments set to false (no --removeComments flag and/or "removeComments": false in tsconfig.json) performs unexpectedly **based on whitespace characters surrounding comments before an export statement**. For example,

``` typescript
/* @ngInject */
export = function($scope: any) {
    // A comment
    $scope.options = {};
}
```

Run the compiler:

``` bash
$ tsc --module commonjs controller.ts
```

The compiler strips /\* @ngInject */ but preserves // A comment

``` typescript
module.exports = function ($scope) {
    // A comment
    $scope.options = {};
};
```

However, **placing a new line after /\* @ngInject */ keeps it from being removed**:

``` typescript
/* @ngInject */

export = function($scope: any) {
    // A comment
    $scope.options = {};
}
```

produces

``` typescript
/* @ngInject */
export = function($scope: any) {
    // A comment
    $scope.options = {};
}
```

Any idea why tsc is sensitive to such contextual whitespace?

``` bash
$ tsc -v
message TS6029: Version 1.7.5
```
Repository: go
Issue: text/template: add more package docs
Labels: Documentation,NeedsInvestigation

We can add more comments to text/template package so the readers who use godoc will see somewhat more detailed material in the documentation rather than the sparse documentation which is currently present.
Repository: kubernetes
Issue: Deprecate cAdvisor flags in kubelet
Labels: area/kubelet,kind/cleanup,area/cadvisor,sig/node,priority/important-longterm,lifecycle/frozen

Currently all cAdvisor flags are exposed through the cAdvisor binary. Many of the flags are irrelevant, or provide more controls than we want to give. Additionally, once we separate most cAdvisor functionality out of kubelet, most of thees flags will no longer make sense.

Open questions about the deprecation:
- Which flags are existing customers using? We should probably send a survey to various kubernetes groups to find out.
- Can we simply make the backwards incompatible change of removing the flags, or do we need to create "dummy" deprecated flags for each one in kubelet?

Prerequisite for https://github.com/kubernetes/kubernetes/issues/18770

@kubernetes/goog-node
Repository: TypeScript
Issue: Leak of `noImplicitAny` checking with private static property
Labels: Bug,Help Wanted

``` ts
declare class C {
  private static implicitAnyTypeProperty;
  static inherited: typeof C.implicitAnyTypeProperty;
  inherited: typeof C.implicitAnyTypeProperty;
}
```

expected:

```
$ node_modules/.bin/tsc index --noImplicitAny
index.ts(2,3): error TS7008: Member 'implicitAnyTypeProperty' implicitly has an 'any' type.
```

actual:

```
$ node_modules/.bin/tsc index --noImplicitAny
```
Repository: go
Issue: spec: no rule about loops in constant definition
Labels: NeedsInvestigation

The compiler issues error `constant definition loop` for the following program:

``` go
package main
import "fmt"
const C = len(u)
func f() ([1]int, [C]float64) {
    return [...]int{1}, [...]float64{1.1}
}
var u, v = f()
func main() {
    fmt.Println(C, v)
}
```

In fact the value if `C` (resp. the type of `u`) does not depend on the type of the second return of `f`.

The same program is compiled successfully by gccgo.

PS. Another test case

``` go
package main
import "fmt"
const C = len(u)
type S struct {
    X [1]int
    Y [C]int
}
var s S
var u, v = s.X, s.Y
func main() {
    fmt.Println(C, v)
}
```
Repository: rust
Issue: Fine-tune binary heap sifting logic
Labels: I-slow,C-enhancement,A-collections,T-libs-api

There's a fundamental compromise in sifting strategy that optimizes for small/big heaps or elements.

See #30534 for discussion and details, which changed `pop` to optimize for the large case. It's possible a branch on `self.len` could produce better results for small cases.

CC @bluss if you want to chime in
Repository: rust
Issue: VecDeque's iterator could be optimized
Labels: I-slow,C-enhancement,A-collections,T-libs-api

`VecDeque`'s iterator seems to never allow llvm to vectorize loops, this could be improved.

Even an enum where it uses the slice iterator for its contiguous case, and a fallback iterator, would allow vectorization for the contiguous case.

The following simple benchmark shows the massive difference between the deque iterator and using its two slice parts. The results are the same whether the deque is discontinuous or not. The summation in `sum_deque_2` is an order of magnitude faster, because llvm can autovectorize it.

``` rust

/* Results
test sum_deque   ... bench:       1,301 ns/iter (+/- 111)
test sum_deque_2 ... bench:          71 ns/iter (+/- 2)
*/

#![feature(test)]
extern crate test;

use test::Bencher;
use test::black_box;

use std::collections::VecDeque;


#[bench]
fn sum_deque(b: &mut Bencher) {
    let mut dq: VecDeque<_> = (0..1024).collect();
    /*
    for _ in 0..128 {
        let elt = dq.pop_back().unwrap();
        dq.push_front(elt);
    }
    */
    let dq = black_box(dq);

    b.iter(|| {
        let mut sum = 0;
        for elt in &dq {
            sum += *elt;
        }
        sum
    })
}


#[bench]
fn sum_deque_2(b: &mut Bencher) {
    let mut dq: VecDeque<_> = (0..1024).collect();
    /*
    for _ in 0..128 {
        let elt = dq.pop_back().unwrap();
        dq.push_front(elt);
    }
    */
    let dq = black_box(dq);

    b.iter(|| {
        let mut sum = 0;
        let (a, b) = dq.as_slices();
        for elt in a {
            sum += *elt;
        }
        for elt in b {
            sum += *elt;
        }
        sum
    })
}
```
Repository: rust
Issue: Allow deprecating a re-export
Labels: C-enhancement,A-lints,T-lang,E-help-wanted,L-deprecated

This would allow a module to rename an identifier without breaking users, and provide a message that they should change.

Example:

``` rust
mod foo {
    #[deprecated(reason = "use Foo instead")]
    pub use self::Foo as Bar;

    pub struct Foo(pub i32);
}

use self::foo::Bar; // <- deprecrated, use Foo instead
```
Repository: go
Issue: x/mobile/exp/audio/al: add missing generic accessors and setters
Labels: FeatureRequest,mobile

Continuing the discussion started at https://github.com/golang/go/issues/11298#issuecomment-168354198...

Source offset setters are missing from the package and the offset must represented in float32 for more precision. Suggested APIs are below.

```
// OffsetSeconds returns the current playback position of the source in seconds.
func (s Source) OffsetSeconds() float32 {
return getSourcef(s, paramSecOffset)
}

// SetOffsetSeconds sets the current playback position of the source in seconds.
func (s Source) SetOffsetSeconds(sec float32){
setSourcef(s, paramSecOffset,sec)
}

// OffsetSample returns the sample offset of the current playback position.
func (s Source) OffsetSample() int32 {
return getSourcei(s, paramSampleOffset)
}

// SetOffsetSample sets the sample offset of the current playback position.
func (s Source) SetOffsetSample(i int32){
setSourcei(s, paramSampleOffset,i)
}

// OffsetByte returns the byte offset of the current playback position.
func (s Source) OffsetByte() int32 {
return getSourcei(s, paramByteOffset)
}

// SetOffsetByte sets the byte offset of the current playback position.
func (s Source) SetOffsetByte(i int32){
setSourcei(s, paramByteOffset,i)
}
```

/cc @splace
Repository: go
Issue: tour: use names instead of numbers for page urls
Labels: NeedsInvestigation

The current system of using paths like /moretypes/12 is problematic. One is that such URLs are not descriptive. The other is that the numbers change whenever we add or remove a page, breaking existing links. (I have two recent CLs that completely renumber the methods section.)

We should change the URLs to use names instead of numbers. For instance, the URL http://tour.golang.org/methods/4 could be http://tour.golang.org/methods/pointer-receivers instead. This adds a new requirement that all pages within a sub-tour must have a unique name, but I think the existing content meets that requirement already, and I don't think it's an onerous burden for future material.

@campoy - how hard would it be to do this? Looking at the code, I'm not sure how to make the change cleanly.
Repository: vscode
Issue: Add fuzzy search to commands in palette
Labels: feature-request,quick-open

As @bpasero suggested, I'm opening an issue to suggest adding fuzzy search in the palette for commands as well. 

He had an issue with this though, so it could be enabled with a user setting. But I am unsure about his concern.

> The issue with fuzzy matching is that you also need to do fuzzy sorting: more relevant results to the top. However for the command palette we chose to sort entries by name to keep the result list stable and memorable. Enabling fuzzy for commands would change the sort order for each search you do making it harder to learn the list of available commands.

I don't understand how the sort order is relevant when you are looking for a specific command or set of commands. Let's say I would like to look for all Markdown related commands (which start with `Markdown:`): in Sublime, I would only type `md:`, removing practically all unrelevant commands from the results list. The results however would still be sorted by names. Am I misunderstanding his issue?

Once you're used to search in a fuzzy pattern (often with shortened words like `msg` for message), it is very awkward to go back to typing complete words.
Repository: nvm
Issue: Feature Request: npm management?
Labels: feature requests

Nvm installs node and npm for a particular user, but the version of node and npm are linked. It would be nice if there was a way to choose a different version of npm, in the same way you can change your node version. It seems like the easy and recommended way to update npm is via `npm install npm -g`, but this installs npm globally. If you don't have the need or ability to do a global install, it would be nice if nvm could install a newer/different version for you.
Repository: go
Issue: cmd/link: DW_AT_name should come from source code
Labels: compiler/runtime

gc is not generating DW_AT_name according to the spec.
DW_AT_name is "a string representing the name as it appears in the source program."
Mangled names should go in DW_AT_linkage_name.
I've seen names like these:
  package.functioname for functions
  package.(type).functionname for methods
  package.functioname.func1 for closures
  package.type for types

These should all be the linkage_name. 

We should probably represent packages as DW_TAG_namespace. Functions and types should be children of the package. Methods should be children of the type. Anonymous functions should only have a linkage_name and not a DW_AT_name.

It would also be good to fix variables to represent what's in the source, e.g. no '&foo'.
Repository: youtube-dl
Issue: youtube-dl should display ffmpeg errors
Labels: request,postprocessors

Whenever ffmpeg gives out errors, youtube-dl should give that feedback to the user. As it is now, it only gives the last line:[ffmpeg] Correcting container in "A.m4a"
ERROR: file:A.temp.m4a: Invalid argument

But it would be better if it gave the whole error so that I would know that the error has to do with mp4 codec: Requested output format 'mp4' is not a suitable output format 
file:A.temp.m4a: Invalid argument
Repository: kubernetes
Issue: Implement alternative storage destination (for events)
Labels: priority/backlog,sig/scalability,area/logging,sig/api-machinery,lifecycle/frozen

currently, events are stored into etcd, i think this is not a good way. because events always multi-times than pods, if the cluster is big(`15000 pods, there maybe  > 100K events`), etcd can not handle it effectively. Than the e2e test(`density test`) maybe not works fine.
why not send the events to a manager center(`like kafka`), or store them in the database?
Repository: TypeScript
Issue: Allow inline type predicates
Labels: Suggestion,Needs Proposal

From #5731 

``` typescript
if (<foo is Element>(foo.nodeType === 1)) { 
    // Assume foo is Element here
}
```

A proposal from @sandersn: https://github.com/Microsoft/TypeScript/issues/5731#issuecomment-162586789

> ## Type Predicate Expressions
> 
> A type predicate expression allows you to narrow a union type with a single expression. The syntax is 
> 
> > `<`_variable_ `is` _type_`>` _boolean-expression_
> 
> When the expression is used in a conditional context, the true branch of the conditional narrows variable to type, while the false branch narrows variable by removing type. 
> 
> The type predicate expression is of type Boolean, with apparent type of type predicate. The right hand side must be an expression of type Boolean. The left hand side's variable must be a name bound in the current scope. The left hand side's type must be a name bound in the current scope. 
> ### Open questions
> 1. How does variable capture work? Can a type predicate expression be returned from a function and used to narrow a variable that's no longer in scope? This could be defined to cause an error, but that restriction is neither obvious nor easy to use.
> 2. Why reuse the type assertion syntax? The type of the right expression is checked to be Boolean, unlike assertions, and the resulting type is still Boolean, also unlike assertions.
Repository: youtube-dl
Issue: add support for prosiebenmaxx plailistfiles
Labels: geo-restricted

hi,

could you please add support for playlists such as of this:

http://www.prosiebenmaxx.de/anime/playlist-animenacht

unfortunately the page dosnt allow to get the video url out of the playlist (as youtube dose for example) so for me there is no way to get the videos

thanks alot in advance
Repository: rust
Issue: Struct and variant constructors are not generic over lifetimes like regular functions.
Labels: C-enhancement,A-lifetimes,T-compiler,F-unboxed_closures

The following testcase produces the errors noted in comments and the last one is an ICE ([run on playpen](https://play.rust-lang.org/?gist=f5acaea83408a752d28d&version=nightly)):

``` rust
#![feature(fn_traits, unboxed_closures)]

fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {}

struct Compose<F,G>(F,G);
impl<T,F,G> FnOnce<(T,)> for Compose<F,G>
where F: FnOnce<(T,)>, G: FnOnce<(F::Output,)> {
    type Output = G::Output;
    extern "rust-call" fn call_once(self, (x,): (T,)) -> G::Output {
        (self.1)((self.0)(x))
    }
}

struct Str<'a>(&'a str);
fn mk_str<'a>(s: &'a str) -> Str<'a> { Str(s) }

fn main() {
    let _: for<'a> fn(&'a str) -> Str<'a> = mk_str;
    // expected concrete lifetime, found bound lifetime parameter 'a
    let _: for<'a> fn(&'a str) -> Str<'a> = Str;

    test(|_: &str| {});
    test(mk_str);
    // expected concrete lifetime, found bound lifetime parameter 'x
    test(Str);

    test(Compose(|_: &str| {}, |_| {}));
    test(Compose(mk_str, |_| {}));
    // internal compiler error: cannot relate bound region:
    //   ReLateBound(DebruijnIndex { depth: 2 },
    //     BrNamed(DefId { krate: 0, node: DefIndex(6) => test::'x }, 'x(65)))
    //<= ReSkolemized(0,
    //     BrNamed(DefId { krate: 0, node: DefIndex(6) => test::'x }, 'x(65)))
    test(Compose(Str, |_| {}));
}
```

The same errors occur if an `enum Foo<'a> { Str(&'a str) }` is used.

Usage of `FnOnce<(T,)>` is to avoid proving an explicit type parameter for the `Output` associated type, as an workaround for #30867.

Originally found in @asajeffrey's [wasm](https://github.com/asajeffrey/wasm) repo (see my comment on asajeffrey/wasm#1).
cc @nikomatsakis @arielb1
Repository: TypeScript
Issue: Compiler "target" option capitalization in docs inconsistent with code and json schema
Labels: Docs

https://github.com/Microsoft/TypeScript/wiki/Compiler-Options
says `--target` can take the value `ES5` (uppercase).

Visual Studio Code warns about using the uppercase one in your `tsconfig.json`, presumably because it's following the schema.

The JSON schema for `tsconfig.json` also has it in lowercase, but the docs (https://github.com/Microsoft/TypeScript/wiki/tsconfig.json#details) refer you to the first page (which uses uppercase) for the values.

---

My guess at fixing the problem:

From the source it appears the value ought to be lowercase:
https://github.com/Microsoft/TypeScript/blob/master/src/compiler/commandLineParser.ts#L221

I think the fix is to use lowercase in the docs (the first page).