This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package listener | |
| import ( | |
| "encoding/hex" | |
| "github.com/twmb/murmur3" | |
| "unsafe" | |
| ) | |
| func CalcTagDigest(metricName, source string, tags map[string]string) string { | |
| a1, a2 := hashPair("metric", metricName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 2019-11-01 09:09:29 | |
| Full thread dump Java HotSpot(TM) 64-Bit Server VM (10.0.1+10 mixed mode): | |
| Threads class SMR info: | |
| _java_thread_list=0x00007f9e1f019600, length=147, elements={ | |
| 0x00007f9e1d807800, 0x00007f9e1d81f000, 0x00007f9e1e019800, 0x00007f9e20838800, | |
| 0x00007f9e1d823000, 0x00007f9e1e01a000, 0x00007f9e1e004000, 0x00007f9e1f807000, | |
| 0x00007f9e1f88d800, 0x00007f9e20805800, 0x00007f9e218e1800, 0x00007f9e2086b000, | |
| 0x00007f9e21113000, 0x00007f9e21906800, 0x00007f9e20dfd800, 0x00007f9e1e7f6000, | |
| 0x00007f9e1e7f7000, 0x00007f9e200b5800, 0x00007f9e1dd30800, 0x00007f9e21229800, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| public static void main(String[] args) { | |
| int value = 0; | |
| long now = System.currentTimeMillis(); | |
| for(int i = 0; i < 1e8; i++) { | |
| value++; | |
| } | |
| System.out.println("Unsynched version took " + (System.currentTimeMillis() - now) + "ms"); | |
| Object syncher = new Object(); | |
| now = System.currentTimeMillis(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.HashMap; | |
| public class HashTest { | |
| public static void main(String[] args) { | |
| HashMap<String, String> map = new HashMap<>(); | |
| map.put("foo", "bar"); | |
| long now = System.currentTimeMillis(); | |
| for(int i = 0; i < 1e7; i++) { | |
| map.get("foo"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DoubleCheck { | |
| private SomeResource myResource; | |
| public SomeResource getResource() { | |
| if(myResource != null) { | |
| return myResource | |
| } | |
| synchronized(this) { | |
| if(myResource != null) { | |
| return myResource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BrokenDontUse { | |
| private Map<String, SomeResource> aHashMap = new HashMap<>(); | |
| public SomeResource getResource(String name) { | |
| SomeResource r = aHashMap.get(name); | |
| if(r != null) { | |
| return r; | |
| } | |
| synchronized(aHashMap) { | |
| SomeResource r = aHashMap.get(name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int waiters = 0; | |
| void acquireLock() { | |
| if(atomicIncrement(waiters) == 0) { | |
| rerurn; | |
| } | |
| callSlowAndPainfulLockingLogic(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class QuestionableUseOfDoubleCheck { | |
| private long firstAccess = -1; | |
| public long accessSomething() { | |
| if (firstAccess != -1) { | |
| return this.firstAccess; | |
| } | |
| synchronized (this) { | |
| if (this.firstAccess != -1) { | |
| return this.firstAccess; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "image" | |
| "image/color" | |
| "image/png" | |
| "math" | |
| "math/cmplx" | |
| "os" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "image" | |
| "image/color" | |
| "image/png" | |
| "math" | |
| "math/cmplx" | |
| "os" |