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

Avoid linear search in StmtCache #131

Closed
jonhoo opened this issue Feb 9, 2018 · 0 comments
Closed

Avoid linear search in StmtCache #131

jonhoo opened this issue Feb 9, 2018 · 0 comments

Comments

@jonhoo
Copy link
Contributor

jonhoo commented Feb 9, 2018

The StmtCache currently does a linear probe of the order vector (including a string comparison for each position) every time it looks up a query. This is fine if the statement cache is fairly small, or a small set of queries are very common, but if it is larger, this scan + remove + push can become quite costly. From what I can tell, it is only used for keeping an LRU of the items in the HashMap. If the values in the map were instead, say, (usize, InnerStmt), where the usize is an incrementing number kept in the StmtCache, then the scan could happen only on eviction, rather than on every lookup.

jonhoo added a commit to jonhoo/rust-mysql-simple that referenced this issue Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant