sharjeelyunus/github-issues-dataset huggingface dataset:
Repository: go
Issue: cmd/compile: reordering struct field accesses can alter performance
Labels: Performance,NeedsInvestigation,compiler/runtime

### What version of Go are you using (`go version`)?

    go version devel +47c868dc1c Sat Oct 28 11:53:49 2017 +0000 linux/amd64

### Does this issue reproduce with the latest release?

Yes.

### What operating system and processor architecture are you using (`go env`)?

```
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mvdan/go/land:/home/mvdan/go"
GORACE=""
GOROOT="/home/mvdan/tip"
GOTOOLDIR="/home/mvdan/tip/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build268906853=/tmp/go-build -gno-record-gcc-switches"
```

### What did you do?

https://play.golang.org/p/d5g7tuaxHW

    go test -bench=.

### What did you expect to see?

Both of them performing equally.

### What did you see instead?

With 6 runs of each on an idle machine:

```
name          time/op
Separate-4    2.48ns ± 1%
Contiguous-4  2.15ns ± 2%
```

This is a minifiedin version of a performance issue I had in a very hot function. In particular, the function is the ASCII fast path of a rune advance method.

Here's the assembly for the two funcs:

```
"".(*T).separate STEXT nosplit size=26 args=0x10 locals=0x0
        0x0000 00000 (f_test.go:9)      TEXT    "".(*T).separate(SB), NOSPLIT, $0-16
        0x0000 00000 (f_test.go:9)      MOVQ    "".t+8(SP), AX
        0x0005 00005 (f_test.go:10)     INCQ    8(AX)
        0x0009 00009 (f_test.go:11)     MOVQ    $0, (AX)
        0x0010 00016 (f_test.go:12)     MOVQ    8(AX), AX
        0x0014 00020 (f_test.go:12)     MOVQ    AX, "".~r0+16(SP)
        0x0019 00025 (f_test.go:12)     RET
"".(*T).contiguous STEXT nosplit size=29 args=0x10 locals=0x0
        0x0000 00000 (f_test.go:15)     TEXT    "".(*T).contiguous(SB), NOSPLIT, $0-16
        0x0000 00000 (f_test.go:15)     MOVQ    "".t+8(SP), AX
        0x0005 00005 (f_test.go:16)     MOVQ    $0, (AX)
        0x000c 00012 (f_test.go:17)     MOVQ    8(AX), CX
        0x0010 00016 (f_test.go:17)     INCQ    CX
        0x0013 00019 (f_test.go:17)     MOVQ    CX, 8(AX)
        0x0017 00023 (f_test.go:18)     MOVQ    CX, "".~r0+16(SP)
        0x001c 00028 (f_test.go:18)     RET
```

Funnily enough, the faster one results in an extra instruction. How that makes sense is beyond me. Perhaps it's because the first one accesses `8(AX)` three times, and the second only twice?

My understanding of the compiler and assembly are limited, so any pointers welcome.

/cc @randall77 @philhofer
Repository: go
Issue: proposal: encoding/json: add omitnil option
Labels: Proposal,Proposal-Hold

Note: This proposal already has as a [patch] from 2015 by @bakineggs, but it appears to have fallen between the cracks.

I have the following case:

```go
type Join struct {
    ChannelId string      `json:"channel_id"`
    Accounts  []Ident     `json:"accounts,omitempty"`
    History   []TextEntry `json:"history,omitempty"`
}
```

This struct is used for message passing and the slices are only relevant (and set to non-`nil`) in some cases. However, since `encoding/json` does not differentiate between a `nil` slice and an empty slice, there will be legitimate cases where a field is excluded when it's not expected to (e.g., the `History` slice is set, but empty).

I reiterate the proposal by Dan in his patch referred above to support an `omitnil` option which allows this differentiation for slices and maps.

*Note for hypothetical Go 2.0:* This is already how `omitempty` works for pointers to Go's basic types (e.g., `(*int)(nil)` is omitted while pointer to `0` is not). For Go 2.0 the behavior of `omitempty` could change to omit both `nil` and `0` when specified, and then only `nil` would be omitted when `omitnil` is specified.

[patch]: https://go-review.googlesource.com/c/go/+/10686
Repository: rust
Issue: Consider more fine grained grouping for built-in lints
Labels: C-enhancement,A-lints,T-lang

Copying the comment from https://github.com/rust-lang/rust/pull/45424#issuecomment-338345084:

I've also audited the remaining ungrouped lints.
In principle new lint groups can be created for them, but it looks like fine-grained lint grouping didn't find its use even in clippy, so I didn't do anything.

**Unused++.**
These can also be quite reasonably added into the `unused` group, but less obviously than those I added into it in this PR.
```
STABLE_FEATURES
RENAMED_AND_REMOVED_LINTS
UNKNOWN_LINTS
UNUSED_COMPARISONS
```

**Bad style++.**
Probably can be added into the `bad_style` group, but it currently consists only of casing-related lints.
```
NON_SHORTHAND_FIELD_PATTERNS
WHILE_TRUE
```

**Future compatibility++.**
Errors that are reported as lints for some reasons unknown to me.
See the question in https://github.com/rust-lang/rust/pull/45424#discussion_r146084996 as well.
```
CONST_ERR // ?
UNKNOWN_CRATE_TYPES // Deny-by-default
NO_MANGLE_CONST_ITEMS // Deny-by-default
NO_MANGLE_GENERIC_ITEMS
```

**Restrictions.**
Something generally reasonable that can be prohibited if necessary.
```
BOX_POINTERS // Allow-by-default
UNSAFE_CODE // Allow-by-default
UNSTABLE_FEATURES // Allow-by-default
MISSING_DOCS // Allow-by-default
MISSING_COPY_IMPLEMENTATIONS // Allow-by-default
MISSING_DEBUG_IMPLEMENTATIONS // Allow-by-default
```

**Pedantic.**
Something not bad enough to always report/fix.
```
UNUSED_RESULTS // Allow-by-default
UNUSED_IMPORT_BRACES // Allow-by-default
UNUSED_QUALIFICATIONS // Allow-by-default
TRIVIAL_CASTS // Allow-by-default
TRIVIAL_NUMERIC_CASTS // Allow-by-default
VARIANT_SIZE_DIFFERENCES // Allow-by-default
UNIONS_WITH_DROP_FIELDS
```

**Obvious mistakes.**
Prevent foot shooting, some can become hard errors in principle.
```
OVERFLOWING_LITERALS
EXCEEDING_BITSHIFTS // Deny-by-default
UNCONDITIONAL_RECURSION
MUTABLE_TRANSMUTES // Deny-by-default
IMPROPER_CTYPES
PLUGIN_AS_LIBRARY
PRIVATE_NO_MANGLE_FNS
PRIVATE_NO_MANGLE_STATICS
```

**General purpose lints.**
```
WARNINGS
DEPRECATED
```
Repository: go
Issue: lib/time: update tzdata before release
Labels: NeedsFix,release-blocker,recurring

The timezone database in lib/time should be updated shortly before the 1.10 release (to whatever tzdata release is current then). There was https://golang.org/cl/74230 attempting to do this just now, but it was too early. @ALTree suggested to open an issue about this, so we don't forget.

The latest available version is shown at https://www.iana.org/time-zones.
Repository: pytorch
Issue: Data sampling seems to be more complicated than necessary
Labels: module: dataloader,triaged

I love Pytorch for its flexibility and debugging friendly environment, and like Andrej Karpathy said after using Pytorch, "I have more energy. My skin is clearer. My eye sight has improved."

However, I am finding sampling from datasets a bit more convoluted that it needs to be. I was hoping for a way to efficiently extract samples (using multiprocessing) from the dataset by providing a batch index list as input, e.g. 
```python
batch_indices = [5,4,2]
loader.get_indices(batch_indices)
```
where `loader`is a `DataLoader`object or a `torch.data.Dataset` object. In other words, I am looking for a simple, yet flexible sampling interface.

Currently, if I want to sample using a non-uniform distribution, first I have to define a sampler class for the `loader`, then within the class I have to define a generator that returns indices from a pre-defined list. Later, whenever the sampling distribution changes I have to re-create the sampler object that takes input values which are used to compute the new sampling distribution. I didn't find an easier way yet.

As a result, defining the data loader would be something like,
```python
loader = data.DataLoader(train_set, sampler=sampler(train_set), num_workers=2)`
```
for the initialization step; and
```python
loader.sampler = sampler(train_set, some_values)
```
between epochs.

This seems to give me certain restrictions (please correct me if I am wrong),
1. dynamic sampling is not well supported with this approach - consider the case where the sampling distribution or the batch size changes after every iteration (not epoch); and

2. this makes it necessary to have an epoch-based outer loop. Once I tried to avoid having epochs by using `itertools.cycle` on a `DataLoader` with `RandomSampler`, but it gave me a bad memory leak.

Therefore, is it an issue if we have the API allow for a sampling procedure that looks like the code below ? My goal is to have a flexible data sampling interface while harnessing the multiprocessing power of `DataLoader`.

```python
for i in range(n_iters):
    # 1. Sample according to `probs`
    indices = np.random.choice(n, batch_size, p=probs)
    batch = loader.get_indices(indices)
   
    # 2. Optimization step
    opt.zero_grad()
    loss = model.compute_loss(batch)
    loss.backward()
    opt.step()

    # 3. Change probs values according to some criterion
    probs = get_newProbs(probs, loss)
```

If the `DataLoader` **api** can't be changed, what if we add three extra functions to `torch.data.Dataset` ?
1. `.get_indices(batch_indices, collate_fn)` - to extract a batch from indices using a collate function;
2. `.spawn_workers(num_workers)` - to initialize workers for sampling with multiprocessing; and 
3. `.terminate_workers()` - to terminate the worker threads.

What do you think ?

I would be happy to submit a pull request for this feature!

cc @SsnL
Repository: TypeScript
Issue: __metadata should register function that returns type instead of literal type
Labels: Suggestion,Revisit,Domain: Decorators

Imagine case with circular dependencies

```
class Car {
  @Field owner: Person // !!! Error: Person is not defined.
}

class Person {
  @Field car: Car;
}

// car has owner, owner has car
```

Typescript metadata would be emitted here like

eg.
`__metadata('design:type', Person)`.

As `Person` is injected for the first time before `Person` class is initialized, it will result with `ReferenceError` saying `Person is not defined`.

If it'd emit metadata like:  
```__metadata('design:type', () => Person)``` 

it'd be fine.

Later on, when using Reflect.metadata, it would also need to call meta function instead of just returning the type.

If you think it's good idea, do you have any suggestions about starting point for PR that would implement this change?
Repository: pytorch
Issue: type of torch.bernoulli and torch.multinomial inconsistent
Labels: module: distributions,triaged

type of `torch.bernoulli` and `torch.multinomial` inconsistent:

- `torch.bernoulli` => torch.FloatTensor
- `torch.multinomial` => torch.LongTensor

I think the types should be self-consistent, ie both FloatTensor, or both LongTensor.

cc @vincentqb @fritzo @neerajprad @alicanb @vishwakftw
Repository: TypeScript
Issue: @ts-ignore for the block scope and imports
Labels: Suggestion,Awaiting More Feedback,VS Code Tracked

currently @ts-ignore only mutes the errors from the line immediately below it

would be great to have the same for 
1. the whole next block 
2. also for all imports

### use case:

refactoring: commenting out a piece of code to see what would break without it, yet avoiding to deal with the errors in the file where commented code is which can be many
Repository: opencv
Issue: Annotation squares have an offset to the cursor in `opencv_annotation`
Labels: bug,priority: low,category: highgui-gui,platform: ios/osx,category: apps

##### System information (version)

- OpenCV => 3.3.0
- Operating System / Platform => macOS High Sierra (10.13)
- Compiler => Installed with homebrew

##### Detailed description

When annotating images using `opencv_annotation` the annotation program start the annotation markings (the red/green squares) with a offset from cursor in the y-axis depending on the y-position of the cursor (proportional it seems). The offset is not dependent on where the annotation/marking started, only the current position of the cursor. 

At the bottom (y~0, assuming [0,0] is in the bottom left corner) the marking starts with a negative offset from the cursor, and then the offset gradually increases when the y-position of the cursor increases. It seems the offset is 0 around one third to the top (y-position to the cursor is 1/3 of the height of the image).

##### Steps to reproduce (example)

If I start an annotation on the bottom of an image, the marking appears below the cursor:

<img width="400" alt="bottom" src="https://user-images.githubusercontent.com/6630430/32182217-74de28f6-bd96-11e7-8008-b22fb351a954.png">

About one third up the image, the marking is where it should be:

<img width="577" alt="one-third" src="https://user-images.githubusercontent.com/6630430/32182261-845b8562-bd96-11e7-8bf1-a3fac2dd7772.png">

When I reach the top, the marking appears above the cursor:

<img width="523" alt="top" src="https://user-images.githubusercontent.com/6630430/32182700-9d475280-bd97-11e7-8e05-3901ab362d90.png">

This makes it hard to annotate objects near the top and the bottom:

<img width="600" alt="hard annotation" src="https://user-images.githubusercontent.com/6630430/32182733-ad783552-bd97-11e7-8452-5cb092dc5068.png">
Repository: puppeteer
Issue: Support extensions execution contexts
Labels: feature,chromium

The [documentation](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#overview)  show that Frames can be associated with extensions but there's no documentation on how to register an extension & run a script under one of the extensions environments (option page/background page/page action/ect...).

It would be awesome to run automated tests for web-extensions developpers.
Repository: opencv
Issue: The output of  cv::convertPointsFromHomogeneous does not match the documentation for points at infinity.
Labels: category: documentation,category: calib3d

<!--
If you have a question rather than reporting a bug please go to http://answers.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
<!-- Example
- OpenCV => 3.1
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2015
-->

- OpenCV => :master:


##### Detailed description
The documentation <https://github.com/opencv/opencv/blob/master/modules/calib3d/include/opencv2/calib3d.hpp#L1290>
says the output should be (0,0,...,0) for points at infinity.

But the implementation just discards the last component.

Please refer to
<https://github.com/opencv/opencv/blob/master/modules/calib3d/src/fundam.cpp#L875>

```.cpp
float scale = sptr[i][3] != 0 ? 1.f/sptr[i][3] : 1.f;
dptr[i] = Point2f(sptr[i].x*scale, sptr[i].y*scale);
```


<!-- your description -->

##### Steps to reproduce
```.cpp
#include <iostream>

#include <opencv2/core.hpp>
#include <opencv2/calib3d.hpp>

int main()
{
   std::vector<cv::Point3f> x1;
   x1.push_back({2,3,0});

   cv::Mat x2;

   cv::convertPointsFromHomogeneous(x1, x2);

   std::cout << x2 << std::endl;
   return 0;
}
```

Output:
```
[2, 3]
```

instead of the expected

```
[0, 0]
```

<!-- to add code example fence it with triple backticks and optional file extension
    ```.cpp
    // C++ code example
    ```
 or attach as .txt or .zip file
-->
Repository: angular
Issue: Animation state is not reapplied
Labels: type: bug/fix,area: animations,freq2: medium,state: needs more investigation,P3

<!--
PLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.

ISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.
-->

## I'm submitting a...
<!-- Check one of the following options with "x" -->
<pre><code>
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
</code></pre>

## Current behavior
<!-- Describe how the issue manifests. -->
Even when disabled, styles of animation are preserved. This is not bad, however when animation state changes and and we enable animation, styles are not updated.


## Expected behavior
<!-- Describe what the desired behavior would be. -->
Styles should update when animation becomes active again.

## Minimal reproduction of the problem with instructions
<!--
For bug reports please provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via
https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).
-->
https://stackblitz.com/edit/angular-ds3u1p

sidenav switches between mobile and mini variant depending on window width(xs - mobile, gt-xs -mini)

1) Go to "mini" variant(`collapse` state is active), 
2) Go to mobile variant(`collapse` state is still active)
3) Open sidenav and close it(`collapse` is no longer active)
4) Go to "mini" variant(`collapse` is not active <- problem)

## What is the motivation / use case for changing the behavior?
<!-- Describe the motivation or the concrete use case. -->
inconsistency

## Environment

<pre><code>
Angular version: 4.4.6
<!-- Check whether this is still an issue in the most recent Angular version -->

Browser:
- [x] Chrome (desktop) version 59
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  <!-- run `node --version` -->
- Platform: Linux(Ubuntu 16.04) <!-- Mac, Linux, Windows -->

Others:
<!-- Anything else relevant?  Operating system version, IDE, package manager, HTTP server, ... -->
</code></pre>
Repository: TypeScript
Issue: hook into `tsc --watch` using stdout -- the unix way
Labels: Suggestion,Awaiting More Feedback

This is a **feature request**.

I would like to launch `tsc -w` and then read from stdout to know when tsc -w has started and completed a build. Like so:

```js
const cp = require('child_process');

const k = cp.spawn('bash');

setImmediate(function(){
     k.stdin.end(`\n  tsc --watch  --project x  \n`);      
});

let stdout = '';
k.stdout.on('data', function(d){
    stdout += String(d);
    if(/foobar/.test(stdout)){
        makeMyDay();
    }
});
```


Right now, `tsc --watch` outputs stdout that is mostly just human readable, and doesn't provide very useful information:

```
1:33:44 PM - File change detected. Starting incremental compilation...

../suman-types/dts/it.d.ts(6,18): error TS2430: Interface 'ITestDataObj' incorrectly extends interface 'ITestOrHookBase'.
  Property 'cb' is optional in type 'ITestDataObj' but required in type 'ITestOrHookBase'.
../suman-types/dts/test-suite.d.ts(13,23): error TS2503: Cannot find namespace 'Chai'.
1:33:44 PM - Compilation complete. Watching for file changes.
```

**Proposal:**

`tsc --watch` should have a new flag, that tells `tsc --watch` to output machine readable data to stdout, instead of human readable data. For example:

`tsc --watch --machine-stdio`

Using this new flag, no existing users will be affected.

Ideally, output JSON to stdout, something like this upon a file change:

```js
const data = {source: '@tscwatch', event: 'file_change', srcfilePath: filePath, willTranspile: true/false, destinationFilePath: null / destinationFilePath};
console.log(JSON.stringify(data);
```

then after transpilation finishes, write something like this to stdout:

```js
const data = {source: '@tscwatch', event: 'compilation_complete', errors: null / errors:[]};
console.log(JSON.stringify(data));
```


if it's behind a flag (`--machine-stdio`) then it won't affect any current users, so should be safe.
I need a truly unique field value like '@tscwatch' so that I know that the JSON is coming from a certain process.  In general, it's possible to be parsing more than one JSON stream from a process, so having a unique field in each JSON object makes this better.
Repository: create-react-app
Issue: Parse build output into a rich format we can display properly
Labels: tag: enhancement

The build overlay still looks less rich than the runtime one:

<img width="813" alt="screen shot 2017-10-30 at 22 07 12" src="https://user-images.githubusercontent.com/810438/32198125-b434c83e-bdbe-11e7-8cc3-8390b197376b.png">

It would be nice to actually parse this (if it matches known Babel and ESLint formats) and display a richer version with:

* Error message and file information in a runtime stack frame-like view
* Highlighted line that causes the issue

There would need to be tests verifying we don't regress if message format updates.
Repository: TypeScript
Issue: Implicit any quick fix should infer from JSX component usage
Labels: Bug,Domain: Quick Fixes

```ts
function Foo(props) {
    return <div>
        {props.x}, {props.y}, {props.z}
    </div>
}

let a = <Foo x={100} y="hello" z={true} />;
```

Expected:

```ts
function Foo(props: { x: number, y: string, z: boolean}) {
    return <div>
        {props.x}, {props.y}, {props.z}
    </div>
}

let a = <Foo x={100} y="hello" z={true} />;
```

Actual:

```ts
function Foo(props: { x: React.ReactNode; y: React.ReactNode; z: React.ReactNode; }) {
    return <div>
        {props.x}, {props.y}, {props.z}
    </div>
}

let a = <Foo x={100} y="hello" z={true} />;
```
Repository: go
Issue: go/importer: fix and enable TestFor for gccgo
Labels: NeedsFix

The go command and gccgo don't get along at the moment. Once they do, importer.TestFor needs to be enabled for gccgo and checked. It may just work.
Repository: pytorch
Issue: High CPU use by clock_gettime syscall
Labels: module: performance,module: cuda,triaged

I noticed, while training a network via https://github.com/abhiskk/fast-neural-style, that CPU use is consistently high in kernel time that is not IO wait. I suspected this was caused by excessive syscalls or context switches.

My platform is Ubuntu 16.04.2, kernel 4.10, CUDA 8, cudnn 6 with a 1080 Ti

To reproduce, I run `python3 neural_style/neural_style.py train --dataset /path/to/COCO2014 --vgg-model-dir vgg --batch-size 4 --save-model-dir saved-models --cuda 1`

`htop` will show high kernel time use (in detailed mode, so it isn't confused with IO waits)

`strace -f -p <PID>` shows that the calls are for `CLOCK_MONOTONIC_RAW`, which is indeed unsupported in vDSO and falls back to a syscall (see http://elixir.free-electrons.com/linux/v4.10.17/source/arch/x86/entry/vdso/vclock_gettime.c#L245). `argdist` for low overhead tracing shows ~2.5m calls per second (`sudo ./argdist -p <PID> -C 'p::sys_clock_gettime(clockid_t clk_id, struct timespec *tp):int'`)

I started manually running parts of the code in the interpreter while sampling the amount of calls happening via `argdist` on the python interpreter, and the culprits are `.cuda()` and `.cpu()` calls on tensors, which trigger many calls to `clock_gettime()` each (amounts are inconsistent and range between hundreds and tens of thousands). I haven't gone down further, but it seems to me that if it's at all possible to replace `CLOCK_MONOTONIC_RAW` with `CLOCK_MONOTONIC`, it will give plenty of performance for such a minor change. Not sure if it's pytorch or CUDA that actually contains said code, though.

cc @ngimel @VitalyFedyunin