Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement #9635

Closed
ngaut opened this issue Mar 11, 2019 · 6 comments
Closed

Performance improvement #9635

ngaut opened this issue Mar 11, 2019 · 6 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/performance

Comments

@ngaut
Copy link
Member

ngaut commented Mar 11, 2019

There are some redundant computing in charset.go(https://github.com/pingcap/parser/blob/master/charset/charset.go), some of the functions may just return constants. There is no need to do compute every time if we save a map/slice and initialize them. Such as:

GetAllCharsets, GetCharsetInfoByID.

We may also change the type of argument from string to integer in GetCharsetDesc.
With better redesign, we can save more memory and CPU.

@ngaut ngaut added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/performance labels Mar 11, 2019
@hawkingrei
Copy link
Member

hawkingrei commented Mar 11, 2019

I will try to improve GetAllCharsets. it is so interesting.

@winkyao
Copy link
Contributor

winkyao commented Mar 11, 2019

@hawkingrei Thanks, some tips here:

  1. GetAllCharsets can be inited at the init function, and GetAllCharsets can return the inited array directly.
  2. GetCharsetInfoByID can use a map to fetch Collation effectively, like var collationsMap = make(map[int]*Collation), and init the map in the init function too.

@lkk2003rty
Copy link
Contributor

I'll try to improve GetCharsetInfoByID

@winkyao
Copy link
Contributor

winkyao commented Mar 11, 2019

Actually, you should modify the code in https://github.com/pingcap/parser/blob/master/charset/charset.go, and update the TiDB go.mod.

@winkyao
Copy link
Contributor

winkyao commented Mar 11, 2019

@lkk2003rty Are you interested in this issue #9638?

@ngaut ngaut changed the title Performance improvement inside charset module Performance improvement Mar 11, 2019
@lkk2003rty
Copy link
Contributor

@lkk2003rty Are you interested in this issue #9638?

yep, I can do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/performance
Projects
None yet
Development

No branches or pull requests

4 participants