Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread Bakul Shah


> On Jan 9, 2022, at 6:15 PM, burak serdar  wrote:
> 
> I think the question is "why do you want to intern strings". The solution can 
> be different for different use cases.

Indeed. This is a given! Such tricks should only be tried if the benefits
outweigh the cost, as per profiling expected use cases for your program.

[Aside:
Though it is unfortunate that most (all?) programming languages
do not make it easy to try out alternative data structures. As an
example, try replacing processing an array of structs with a struct
of arrays, with each struct member stored in a different array!
Row oriented vs Column oriented processing. 
]

> I work with large Json files where keys are repeated, and the keys are long 
> strings (URLs) so using a map[string]string to intern the keys makes a lot of 
> sense. For serialization, the same idea is used to compress large data using 
> string tables: a []string holds all unique strings, and references to those 
> strings are represented using uint32 indexes. For the example where you 
> intern words, you might even consider a single []byte containing all the 
> words concatenated, with a custom string representation containing uint32 
> offset and length. This may or may not be faster than the map implementation, 
> but it will occupy less space, but with a single large object in memory.
> 
> On Sun, Jan 9, 2022 at 5:35 PM Bakul Shah  > wrote:
> The string header will be 16 bytes on 64bit word size machines.
> If most of the words are much shorter, interning won’t buy you
> much. For applications where you *know* all the words are short,
> and the total string space won’t exceed 4GB, you can try other
> alternatives. For instance if the max length of any word is 16 bytes,
> create 16 string tables. Then the ‘interned string’ type is a 4 byte
> index, with the bottom 4 bits indicating the length as well as which
> table to index! A table for N byte words stores one copy of each
> unique word and in consecutive slots on N bytes. Given that on modern
> machines even though memory can be plentiful, memory access is slow
> & computing is fast, this can win. You will also need a possibly unsafe
> String func. that doesn’t allocate string data space. You can even allow
> an overflow table if longer words are not common. And you can allow
> many more unique words by extending the interned string type to 8
> bytes.
> 
>> On Jan 9, 2022, at 3:07 PM, burak serdar > > wrote:
>> 
>> 
>> Note that a with a map[string]string, the code:
>> 
>> m[s]=s
>> 
>> The contents of the string s are not duplicated, only the string header s 
>> is. 
>> 
>> On Sun, Jan 9, 2022 at 3:52 PM jlfo...@berkeley.edu 
>>  > > wrote:
>> I'm aware of Artem Krylysov's idea for string interning published on
>> https://artem.krylysov.com/blog/2018/12/12/string-interning-in-go/ 
>> 
>> 
>> If I understand it correctly, each string is stored twice in a map, once as
>> a key and once as a value. That means that words that only appear once in
>> his example of string interning the words in the novel 1984 are 100% 
>> inefficient
>> in terms of storage. Words that appear twice are neutral. The advantage of 
>> his
>> approach only appears for words that appear three or more times.
>> 
>> I'm wondering if there's a map-like data structure that would store a string
>> as the key, and the address of the key as the value. I'm aware that a 
>> standard
>> Go map can't be used for this because its components might be moved around
>> while a program is running so taking the address of the key would be 
>> dangerous,
>> which is why it isn't allowed.
>> 
>> This came up because I profiled a run of an app I'm working on that
>> processed 12518 strings, of which 9810 appeared 2 or fewer times. Krylysov's
>> approach would only be marginally useful for this app.
>> 
>> The data structure I'm looking for would always be at least neutral, and 
>> would start
>> showing a benefit when a word appears twice.
>> 
>> Does anybody know of such a data structure?
>> 
>> Cordially,
>> Jon Forrest
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts+unsubscr...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/36684584-11eb-4bc0-a436-4906d523c8ban%40googlegroups.com
>>  
>> .
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails 

Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread burak serdar
I think the question is "why do you want to intern strings". The solution
can be different for different use cases.

I work with large Json files where keys are repeated, and the keys are long
strings (URLs) so using a map[string]string to intern the keys makes a lot
of sense. For serialization, the same idea is used to compress large data
using string tables: a []string holds all unique strings, and references to
those strings are represented using uint32 indexes. For the example where
you intern words, you might even consider a single []byte containing all
the words concatenated, with a custom string representation containing
uint32 offset and length. This may or may not be faster than the map
implementation, but it will occupy less space, but with a single large
object in memory.

On Sun, Jan 9, 2022 at 5:35 PM Bakul Shah  wrote:

> The string header will be 16 bytes on 64bit word size machines.
> If most of the words are much shorter, interning won’t buy you
> much. For applications where you *know* all the words are short,
> and the total string space won’t exceed 4GB, you can try other
> alternatives. For instance if the max length of any word is 16 bytes,
> create 16 string tables. Then the ‘interned string’ type is a 4 byte
> index, with the bottom 4 bits indicating the length as well as which
> table to index! A table for N byte words stores one copy of each
> unique word and in consecutive slots on N bytes. Given that on modern
> machines even though memory can be plentiful, memory access is slow
> & computing is fast, this can win. You will also need a possibly unsafe
> String func. that doesn’t allocate string data space. You can even allow
> an overflow table if longer words are not common. And you can allow
> many more unique words by extending the interned string type to 8
> bytes.
>
> On Jan 9, 2022, at 3:07 PM, burak serdar  wrote:
>
> 
> Note that a with a map[string]string, the code:
>
> m[s]=s
>
> The contents of the string s are not duplicated, only the string header s
> is.
>
> On Sun, Jan 9, 2022 at 3:52 PM jlfo...@berkeley.edu <
> jlforr...@berkeley.edu> wrote:
>
>> I'm aware of Artem Krylysov's idea for string interning published on
>> https://artem.krylysov.com/blog/2018/12/12/string-interning-in-go/
>>
>> If I understand it correctly, each string is stored twice in a map, once
>> as
>> a key and once as a value. That means that words that only appear once in
>> his example of string interning the words in the novel 1984 are 100%
>> inefficient
>> in terms of storage. Words that appear twice are neutral. The advantage
>> of his
>> approach only appears for words that appear three or more times.
>>
>> I'm wondering if there's a map-like data structure that would store a
>> string
>> as the key, and the address of the key as the value. I'm aware that a
>> standard
>> Go map can't be used for this because its components might be moved around
>> while a program is running so taking the address of the key would be
>> dangerous,
>> which is why it isn't allowed.
>>
>> This came up because I profiled a run of an app I'm working on that
>> processed 12518 strings, of which 9810 appeared 2 or fewer times.
>> Krylysov's
>> approach would only be marginally useful for this app.
>>
>> The data structure I'm looking for would always be at least neutral, and
>> would start
>> showing a benefit when a word appears twice.
>>
>> Does anybody know of such a data structure?
>>
>> Cordially,
>> Jon Forrest
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/36684584-11eb-4bc0-a436-4906d523c8ban%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/CAMV2RqodPp7kye6%3D5PH0NHha%2BwQC4mqfotipoutm4aeL1EK0Fw%40mail.gmail.com
> 
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqqWOkvCv-bqjpCvJqQjrOUqHdRtTQwGJVnpH%3DUXvpC_zQ%40mail.gmail.com.


Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread Bakul Shah
The string header will be 16 bytes on 64bit word size machines.
If most of the words are much shorter, interning won’t buy you
much. For applications where you *know* all the words are short,
and the total string space won’t exceed 4GB, you can try other
alternatives. For instance if the max length of any word is 16 bytes,
create 16 string tables. Then the ‘interned string’ type is a 4 byte
index, with the bottom 4 bits indicating the length as well as which
table to index! A table for N byte words stores one copy of each
unique word and in consecutive slots on N bytes. Given that on modern
machines even though memory can be plentiful, memory access is slow
& computing is fast, this can win. You will also need a possibly unsafe
String func. that doesn’t allocate string data space. You can even allow
an overflow table if longer words are not common. And you can allow
many more unique words by extending the interned string type to 8
bytes.

> On Jan 9, 2022, at 3:07 PM, burak serdar  wrote:
> 
> 
> Note that a with a map[string]string, the code:
> 
> m[s]=s
> 
> The contents of the string s are not duplicated, only the string header s is. 
> 
>> On Sun, Jan 9, 2022 at 3:52 PM jlfo...@berkeley.edu  
>> wrote:
>> I'm aware of Artem Krylysov's idea for string interning published on
>> https://artem.krylysov.com/blog/2018/12/12/string-interning-in-go/
>> 
>> If I understand it correctly, each string is stored twice in a map, once as
>> a key and once as a value. That means that words that only appear once in
>> his example of string interning the words in the novel 1984 are 100% 
>> inefficient
>> in terms of storage. Words that appear twice are neutral. The advantage of 
>> his
>> approach only appears for words that appear three or more times.
>> 
>> I'm wondering if there's a map-like data structure that would store a string
>> as the key, and the address of the key as the value. I'm aware that a 
>> standard
>> Go map can't be used for this because its components might be moved around
>> while a program is running so taking the address of the key would be 
>> dangerous,
>> which is why it isn't allowed.
>> 
>> This came up because I profiled a run of an app I'm working on that
>> processed 12518 strings, of which 9810 appeared 2 or fewer times. Krylysov's
>> approach would only be marginally useful for this app.
>> 
>> The data structure I'm looking for would always be at least neutral, and 
>> would start
>> showing a benefit when a word appears twice.
>> 
>> Does anybody know of such a data structure?
>> 
>> Cordially,
>> Jon Forrest
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/36684584-11eb-4bc0-a436-4906d523c8ban%40googlegroups.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CAMV2RqodPp7kye6%3D5PH0NHha%2BwQC4mqfotipoutm4aeL1EK0Fw%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/F45BFAB2-315B-479A-A7BA-04BC61657AB7%40iitbombay.org.


Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread burak serdar
On Sun, Jan 9, 2022 at 4:30 PM jlfo...@berkeley.edu 
wrote:

>
>
> On Sunday, January 9, 2022 at 3:07:18 PM UTC-8 bse...@computer.org wrote:
>
>> Note that a with a map[string]string, the code:
>>
>> m[s]=s
>>
>> The contents of the string s are not duplicated, only the string header s
>> is.
>>
>
> I didn't know this. That's very good to know.
>
> What about this:
>
> package main
>
> type word struct {
>   s string
>   refcnt int
> }
>
> var w1 = word {"moby", 1}
>
> func main() {
> m := make(map[string]word)
> m["moby"] = w1
> }
>
> This is a little closer to what I'd like to do.
> How many times would the string "moby" be stored?
>

If you write it as follows, the string "moby" will have only one copy:

m[w1.s]=w1

This will only duplicate the string header `s`, not the contents of 's'.


>
> Thanks,
> Jon
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/6f06bbe8-8d50-46f6-8b28-f4e680ecae43n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqocHbKrYz8-a9p_W86qoQK7wGTc9%3DWKHOUEKHVSo18CwA%40mail.gmail.com.


Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread 'Axel Wagner' via golang-nuts
You might be interested in this package:
https://pkg.go.dev/go4.org/intern
It is probably your best choice for a long-term maintained implementation
of this concept. Matt Layher explained the rationale and design here:
https://mdlayher.com/blog/unsafe-string-interning-in-go/
and Brad Fitzpatrick wrote a blog post about how Tailscale uses it here:
https://tailscale.com/blog/netaddr-new-ip-type-for-go/

On Mon, Jan 10, 2022 at 12:30 AM jlfo...@berkeley.edu <
jlforr...@berkeley.edu> wrote:

>
>
> On Sunday, January 9, 2022 at 3:07:18 PM UTC-8 bse...@computer.org wrote:
>
>> Note that a with a map[string]string, the code:
>>
>> m[s]=s
>>
>> The contents of the string s are not duplicated, only the string header s
>> is.
>>
>
> I didn't know this. That's very good to know.
>
> What about this:
>
> package main
>
> type word struct {
>   s string
>   refcnt int
> }
>
> var w1 = word {"moby", 1}
>
> func main() {
> m := make(map[string]word)
> m["moby"] = w1
> }
>
> This is a little closer to what I'd like to do.
> How many times would the string "moby" be stored?
>
> Thanks,
> Jon
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/6f06bbe8-8d50-46f6-8b28-f4e680ecae43n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfGDQ2e3djAZqqDpaR%3DpuGQext9oYNViazdkT3W53r4D1g%40mail.gmail.com.


Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread jlfo...@berkeley.edu


On Sunday, January 9, 2022 at 3:07:18 PM UTC-8 bse...@computer.org wrote:

> Note that a with a map[string]string, the code:
>
> m[s]=s
>
> The contents of the string s are not duplicated, only the string header s 
> is. 
>

I didn't know this. That's very good to know.

What about this:

package main

type word struct {
  s string
  refcnt int
}

var w1 = word {"moby", 1}

func main() {
m := make(map[string]word)
m["moby"] = w1
}

This is a little closer to what I'd like to do.
How many times would the string "moby" be stored?

Thanks,
Jon

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6f06bbe8-8d50-46f6-8b28-f4e680ecae43n%40googlegroups.com.


Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread burak serdar
Note that a with a map[string]string, the code:

m[s]=s

The contents of the string s are not duplicated, only the string header s
is.

On Sun, Jan 9, 2022 at 3:52 PM jlfo...@berkeley.edu 
wrote:

> I'm aware of Artem Krylysov's idea for string interning published on
> https://artem.krylysov.com/blog/2018/12/12/string-interning-in-go/
>
> If I understand it correctly, each string is stored twice in a map, once as
> a key and once as a value. That means that words that only appear once in
> his example of string interning the words in the novel 1984 are 100%
> inefficient
> in terms of storage. Words that appear twice are neutral. The advantage of
> his
> approach only appears for words that appear three or more times.
>
> I'm wondering if there's a map-like data structure that would store a
> string
> as the key, and the address of the key as the value. I'm aware that a
> standard
> Go map can't be used for this because its components might be moved around
> while a program is running so taking the address of the key would be
> dangerous,
> which is why it isn't allowed.
>
> This came up because I profiled a run of an app I'm working on that
> processed 12518 strings, of which 9810 appeared 2 or fewer times.
> Krylysov's
> approach would only be marginally useful for this app.
>
> The data structure I'm looking for would always be at least neutral, and
> would start
> showing a benefit when a word appears twice.
>
> Does anybody know of such a data structure?
>
> Cordially,
> Jon Forrest
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/36684584-11eb-4bc0-a436-4906d523c8ban%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqodPp7kye6%3D5PH0NHha%2BwQC4mqfotipoutm4aeL1EK0Fw%40mail.gmail.com.


[go-nuts] Data Structure for String Interning?

2022-01-09 Thread jlfo...@berkeley.edu
I'm aware of Artem Krylysov's idea for string interning published on
https://artem.krylysov.com/blog/2018/12/12/string-interning-in-go/

If I understand it correctly, each string is stored twice in a map, once as
a key and once as a value. That means that words that only appear once in
his example of string interning the words in the novel 1984 are 100% 
inefficient
in terms of storage. Words that appear twice are neutral. The advantage of 
his
approach only appears for words that appear three or more times.

I'm wondering if there's a map-like data structure that would store a string
as the key, and the address of the key as the value. I'm aware that a 
standard
Go map can't be used for this because its components might be moved around
while a program is running so taking the address of the key would be 
dangerous,
which is why it isn't allowed.

This came up because I profiled a run of an app I'm working on that
processed 12518 strings, of which 9810 appeared 2 or fewer times. Krylysov's
approach would only be marginally useful for this app.

The data structure I'm looking for would always be at least neutral, and 
would start
showing a benefit when a word appears twice.

Does anybody know of such a data structure?

Cordially,
Jon Forrest

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/36684584-11eb-4bc0-a436-4906d523c8ban%40googlegroups.com.


Re: [go-nuts] Re: Getting started with gocc

2022-01-09 Thread Tong Sun
On Sun, Jan 9, 2022 at 4:56 PM Ian Lance Taylor  wrote:
>
> On Sun, Jan 9, 2022, 1:26 PM Tong Sun  wrote:
>>
>> Hi,
>>
>> I'm following with
>> https://github.com/goccmack/gocc/blob/master/doc/gocc_user_guide.pdf
>>
>> and I'm at the step of trying to provide my own ast:
>>
>> For a single bnf of:
>>
>> Hello:  "hello" id << ast.NewHello($1) >> ;
>>
>> (https://github.com/suntong/lang/blob/master/lang/Go/src/parsers/gocc/ex3-hello/hello.bnf)
>>
>> How to provide the corresponding ast.go?
>>
>> My first try was:
>>
>> https://github.com/suntong/lang/blob/master/lang/Go/src/parsers/gocc/ex3-hello/ast/ast.go
>>
>> and I've made several other attempts, but still unable to make it work.
>
>
> These kinds of questions might be better directed to the people who maintain 
> gocc.  I don't know whether they read this mailing list, which is about the 
> Go language in general.

OK, I'll keep that in mind next time. BTW, I've fixed it --

https://github.com/suntong/lang/tree/master/lang/Go/src/parsers/gocc/ex3-hello

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMmz1OcD8zLWaAW1ozfx2rf5NLoAZHHJSA4ehY6BJ7P6HBhoHA%40mail.gmail.com.


Re: [go-nuts] Re: Getting started with gocc

2022-01-09 Thread Ian Lance Taylor
On Sun, Jan 9, 2022, 1:26 PM Tong Sun  wrote:

> Hi,
>
> I'm following with
> https://github.com/goccmack/gocc/blob/master/doc/gocc_user_guide.pdf
>
> and I'm at the step of trying to provide my own ast:
>
> For a single bnf of:
>
> Hello:  "hello" id << ast.NewHello($1) >> ;
>
> (
> https://github.com/suntong/lang/blob/master/lang/Go/src/parsers/gocc/ex3-hello/hello.bnf
> )
>
> How to provide the corresponding ast.go?
>
> My first try was:
>
>
> https://github.com/suntong/lang/blob/master/lang/Go/src/parsers/gocc/ex3-hello/ast/ast.go
>
> and I've made several other attempts, but still unable to make it work.
>

These kinds of questions might be better directed to the people who
maintain gocc.  I don't know whether they read this mailing list, which is
about the Go language in general.

Ian

>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXFiow_Vn--JtgFLRwsDL0fe8%3De%2BA%3Dg2EghMTBjgDrj0Q%40mail.gmail.com.


[go-nuts] Re: Getting started with gocc

2022-01-09 Thread Tong Sun
Hi,

I'm following with
https://github.com/goccmack/gocc/blob/master/doc/gocc_user_guide.pdf

and I'm at the step of trying to provide my own ast:

For a single bnf of:

Hello:  "hello" id << ast.NewHello($1) >> ;

(https://github.com/suntong/lang/blob/master/lang/Go/src/parsers/gocc/ex3-hello/hello.bnf)

How to provide the corresponding ast.go?

My first try was:

https://github.com/suntong/lang/blob/master/lang/Go/src/parsers/gocc/ex3-hello/ast/ast.go

and I've made several other attempts, but still unable to make it work.

please help.

On Sun, Jan 9, 2022 at 12:37 PM Tong Sun wrote:

> How to overcome such hurdle? thx!

Set

GO111MODULE=on

fixed it.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMmz1OcNjs%2BEaSr9tgQnoYu%3DgEA9yTwj_exgPNiXcyweNPJdKA%40mail.gmail.com.


[go-nuts] Re: Getting started with gocc

2022-01-09 Thread Brian Candler
Try this instead:
go install github.com/goccmack/gocc@latest

Reference:
go get: installing executables with 'go get' in module mode is deprecated.
Use 'go install pkg@version' instead.
For more information, see 
https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7206107d-5085-41a3-a420-84608f2f03d1n%40googlegroups.com.


[go-nuts] Re: TiExec: Try to Bring Direct Performance Improvement to Go Applications by Alleviating iTLB-Cache-Miss

2022-01-09 Thread hnes
Sorry, I forgot to attach the link of its github repo:

https://github.com/hnes/tiexec
在2022年1月8日星期六 UTC+8 00:53:41 写道:

> TiExec tries to alleviate the iTLB-Cache-Miss of the application it 
> loaded, so it may bring some direct performance improvement to those 
> applications that are being punished by iTLB-Cache-Miss problem. I guess 
> many Golang applications which have a large .text segment might already 
> suffer from this kind of performance penalty. So I hope it could be useful 
> to you :-D
>
> For example, the .text segment size of some components in TiDB is from 
> ~46MB to ~160MB, and a test in an OLTP scenario of TiDB with these 
> components optimized by TiExec shows that it could bring about an overall 
> 6-11% performance improvement directly. Here is more detailed information 
> about this test:
>
> > In one OLTP scenario of TiDB, the tidb-server suffers 68.62% 
> iTLB-Cache-Miss, overall TPS is 307.68/sec, medium latency is 62.22 ms. 
> After TiExec is used, iTLB-Cache-Miss reduced to 47.1% (- ~31%), overall 
> TPS became 341.35/sec (+10.9%), medium latency became 56.32 ms (-9.5%).
>
> Usage:
>
> ```bash
> $ tiexec echo -e "Hi, I am loaded by tiexec ❤️\nIt may try to make me more 
> performant ☺\n" Hi, I am loaded by tiexec ❤️ It may try to make me more 
> performant ☺ # or even any elf you like $ tiexec go version go version 
> go1.16.4 linux/amd64 $ tiexec rustc -V rustc 1.55.0 (c8dfcfe04 2021-09-06) 
> $ tiexec bin/pd-server ... $ tiexec bin/tidb-server ... $ tiexec 
> bin/tikv-server ... $ tiexec bin/tiflash/tiflash ... $ tiexec 
> bin/prometheus/prometheus ... $ tiexec bin/bin/grafana-server ...
> ```
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/38acb486-4f32-44c3-882a-1374a47ab2e1n%40googlegroups.com.


[go-nuts] Getting started with gocc

2022-01-09 Thread Tong Sun
Hi,

I'm following with
https://github.com/goccmack/gocc/blob/master/doc/gocc_user_guide.pdf

and I'm at the step of trying to install gocc:

```
$ go get -v github.com/goccmack/gocc
github.com/goccmack/gocc (download)
get "golang.org/x/mod/modfile": found meta tag
vcs.metaImport{Prefix:"golang.org/x/mod", VCS:"git",
RepoRoot:"https://go.googlesource.com/mod"} at
//golang.org/x/mod/modfile?go-get=1
get "golang.org/x/mod/modfile": verifying non-authoritative meta tag
golang.org/x/mod (download)
cannot find package "golang.org/x/mod/modfile" in any of:
/usr/lib/go-1.17/src/golang.org/x/mod/modfile (from $GOROOT)
/.../Go/src/golang.org/x/mod/modfile (from $GOPATH)

$ go get -v golang.org/x/mod/modfile
get "golang.org/x/mod/modfile": found meta tag
vcs.metaImport{Prefix:"golang.org/x/mod", VCS:"git",
RepoRoot:"https://go.googlesource.com/mod"} at
//golang.org/x/mod/modfile?go-get=1
get "golang.org/x/mod/modfile": verifying non-authoritative meta tag
golang.org/x/mod (download)
cannot find package "golang.org/x/mod/modfile" in any of:
/usr/lib/go-1.17/src/golang.org/x/mod/modfile (from $GOROOT)
/.../Go/src/golang.org/x/mod/modfile (from $GOPATH)

$ go get -v golang.org/x/mod/
package golang.org/x/mod: no Go files in /.../Go/src/golang.org/x/mod
```

How to overcome such hurdle? thx!

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMmz1Oe%2B32RfW4qi%3DspRpFcixH3u2ZxUZe%3D3nwTmTLYfRHQh3A%40mail.gmail.com.