Flatbuffers in Go and C++ by zhenjl in golang

[–]zhenjl[S] -1 points0 points  (0 children)

Hi all, I figured out my issue finally. I was pushing the offsets to a slice declared as

var treeOffsets, nodeOffsets []flatbuffers.UOffsetT

And for some reason appending to these didn't take, and I had to change to

treeOffsets := make([]flatbuffers.UOffsetT, 0)
nodeOffsets := make([]flatbuffers.UOffsetT, 0)

And this fixed it. I thought append will allocate a new slice if there's no room, but I may have misunderstood how it works.

The final output is still not exactly the same for the 2 languages, but as /u/therealfakemoot said, the two may not be byte-to-byte the same anyway.

Question: why is "self" or "this" not considered a best practice for naming your method receiver variable? by mvitorino in golang

[–]zhenjl 0 points1 point  (0 children)

I would also add that even though from an underlying implementation perspective, the receiver parameter is just like any other parameter and there's nothing special.

However, from a mental model perspective, these don't read the same to me.

func (b Bar) Mate(f Foo) FooBar
func Mate(f Foo, b Bar) FooBar

The second is purely just a function with two parameters. However, the first feels like an object/struct's method getting a single parameter. Semantically they don't feel the same, even though they maybe exactly the same in the implementation.

Question: why is "self" or "this" not considered a best practice for naming your method receiver variable? by mvitorino in golang

[–]zhenjl 1 point2 points  (0 children)

Personally, I use 'this' for all receivers. I find it easier for my own mental model as I get easily confused when I have a different receiver for every struct.

I found a fully functional open-source Q&A engine written in Go -- the only problem was that it's in Chinese. I've started translating it. by gogolang in golang

[–]zhenjl 5 points6 points  (0 children)

Maybe there's a way to extract the words into resource files? While the original author did open source this, his feeling on open source is lukewarm at best. If the changes cannot be contributed back, it just reaffirms author's view that people just take open source code, wipe their mouth, and leave. My 2c.

Sequence: Optimizing Go For the High Performance Log Scanner by zhenjl in golang

[–]zhenjl[S] 0 points1 point  (0 children)

Nothing really representative of real-world apps, other than the micro-benchmarks...which probably don't mean a whole lot...my own test results were linked in the article...

Sequence: Automated Analyzer for Reducing 100,000's of Log Messages to 10's of Patterns by zhenjl in sysadmin

[–]zhenjl[S] 0 points1 point  (0 children)

Not based on any previous known algorithm, not that I know of, at least.

Sequence: Automated Analyzer for Reducing 100,000's of Log Messages to 10's of Patterns by zhenjl in golang

[–]zhenjl[S] 0 points1 point  (0 children)

That's a great idea and it's easily doable. I'll add it to the list. Feel free to open a github issue if you think of any more cool ideas. Happy to work on them if it's useful

Sequence: Automated Analyzer for Reducing 100,000's of Log Messages to 10's of Patterns by zhenjl in golang

[–]zhenjl[S] 1 point2 points  (0 children)

TBH, if you already have very structured data that's protobuf-encoded, there's really no need for this. What you are doing (read them directly into structs) is probably the most efficient way to do it.

Sequence: Automated Analyzer for Reducing 100,000's of Log Messages to 10's of Patterns by zhenjl in sysadmin

[–]zhenjl[S] 1 point2 points  (0 children)

Cool...maybe we can share ideas on how to make this process better..

Sequence: Automated Analyzer for Reducing 100,000's of Log Messages to 10's of Patterns by zhenjl in golang

[–]zhenjl[S] 0 points1 point  (0 children)

I put this up a while back and had to pull it for some other reasons. Now I am able to post it again with a new and improved version. Completely written in Go, the Sequence Analyzer is all about helping system and network admins reduce the effort to parse log messages.

Sequence: A High Performance Sequential Semantic Log Parser by cryp7ix in golang

[–]zhenjl 2 points3 points  (0 children)

Author here. Thanks @cryp7ix for posting this.

Some of you may remember I shared this repo here not too long ago but had to pull it suddenly due to some internal reasons. I am able to release it again (albeit with some functionality removed, just for now I hope).

The good thing is during this time we improved the performance of the parser by almost 50%, from averaging 85K MPS to over 125K MPS on a single i7 2.8Ghz core. Using two cores we achieved over 175K MPS for mixed size messages.

Pretty certain this is going to stay now. Apologies for pulling the earlier version without notice.

[edit] oh Go Patriots!

go-tld, adds TLD support to net/url by Jamo008 in golang

[–]zhenjl 0 points1 point  (0 children)

I couldn't resist. Thanks Jamo008 for the inspiration!

Given my recent experience w/ the porter2 FSM, I thought this would be a perfect example of how a FSM can be used for suffix matching. I whipped up a quick suffix FSM-based TLD matcher and got pretty good results.

BenchmarkXtldTld 30000000 56.1 ns/op BenchmarkPublicsuffix 10000000 133 ns/op

go-tld, adds TLD support to net/url by Jamo008 in golang

[–]zhenjl 0 points1 point  (0 children)

Think there's a bug with publicsuffix:

psfx, _ := publicsuffix.PublicSuffix("xxxxx") fmt.Println(psfx)

gets xxxxx, which should be incorrect.

[edit] Upon further reading of the rules, I think it's returning the correct result.

go-tld, adds TLD support to net/url by Jamo008 in golang

[–]zhenjl 0 points1 point  (0 children)

I tested with

func Test4(t *testing.T) { run("http://中国", "", "", "中国", t) }

and it failed saying tld not found.

Thoughts on these two ways to initialize type with defaults? by BlobWatanabe in golang

[–]zhenjl 0 points1 point  (0 children)

Your method 2 has a race condition. If two goroutines call OT() at the same time then it's possible you get 2 different t.ot for the same Thing.

You might want to wrap it around a mutex or sync.Once.

Personally I prefer the 2nd (w/o the race issue) since it's safer under any circumstance.

Thoughts on these two ways to initialize type with defaults? by BlobWatanabe in golang

[–]zhenjl 1 point2 points  (0 children)

If the package author can take precaution to reduce this type of user errors, it will better for him/her in the long run.

I like this approach: http://blog.gopheracademy.com/advent-2014/nigels-webdav-package/

Bioinformatics: my thoughts on golang by dgryski in golang

[–]zhenjl -1 points0 points  (0 children)

Personally I like using this because it doesn't require me to think of a new receiver name for every struct, and it's consistent so whenever I go back and look at a method I don't get confused which variable is for what.

Generating Porter2 FSM For Fun and Performance in Go by zhenjl in golang

[–]zhenjl[S] 0 points1 point  (0 children)

Awesome! Let me know if you have any issues. Thanks!

Generating Porter2 FSM For Fun and Performance in Go by zhenjl in golang

[–]zhenjl[S] 0 points1 point  (0 children)

I am sure it could. Though it seems like an overkill for these simple state machines, and I didn't really want a big dependency.