Comments (12)
Hey @broady @samthor, any ideas on how to fix this behaviour? At a guess, this is probably caused by the rate limiter...
from google-maps-services-go.
I don't have tests to confirm rate limiting. I'll be migrating to golang.org/x/time/rate within the next couple of weeks. Thanks!
from google-maps-services-go.
Dropped 1 node (cum <= 0.02s)
flat flat% sum% cum cum%
1.84s 46.00% 46.00% 1.84s 46.00% github.com/google-map-geo-benchmark.NewGoogleMapInstance
1.18s 29.50% 75.50% 1.18s 29.50% github.com/google-map-geo-benchmark.BenchmarkMartinlindheGoogleMapInstance
0.96s 24.00% 99.50% 2.80s 70.00% github.com/google-map-geo-benchmark.BenchmarkGoogleMapInstance
My benchmark code
package main
import (
"testing"
geo "github.com/martinlindhe/google-geolocate"
"googlemaps.github.io/maps"
)
var (
googleMapClient *maps.Client
g *geo.GoogleGeo
)
func NewGoogleMapInstance() {
if nil == googleMapClient {
c, _ := maps.NewClient(maps.WithAPIKey("Insert-API-Key-Here"))
googleMapClient = c
}
}
func NewMartinlindheGoogleMapInstance() {
if nil == g {
client := geo.NewGoogleGeo("api-key")
g = client
}
}
func BenchmarkGoogleMapInstance(b *testing.B) {
for i := 0; i < b.N; i++ {
NewGoogleMapInstance()
}
}
func BenchmarkMartinlindheGoogleMapInstance(b *testing.B) {
for i := 0; i < b.N; i++ {
NewMartinlindheGoogleMapInstance()
}
}
Run
go test -benchmem -bench=. -cpuprofile=cpu.out
Result
goos: linux
goarch: amd64
pkg: github.com/google-map-geo-benchmark
BenchmarkGoogleMapInstance-4 1000000000 2.45 ns/op 0 B/op 0 allocs/op
BenchmarkMartinlindheGoogleMapInstance-4 2000000000 0.53 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/google-map-geo-benchmark 3.840s
from google-maps-services-go.
@domesticmouse
U are right after I remove the code
if c.requestsPerSecond > 0 {
// Implement a bursty rate limiter.
// Allow up to 1 second worth of requests to be made at once.
c.rateLimiter = make(chan int, c.requestsPerSecond)
// Prefill rateLimiter with 1 seconds worth of requests.
for i := 0; i < c.requestsPerSecond; i++ {
c.rateLimiter <- 1
}
go func() {
// Wait a second for pre-filled quota to drain
time.Sleep(time.Second)
// Then, refill rateLimiter continuously
for range time.Tick(time.Second / time.Duration(c.requestsPerSecond)) {
c.rateLimiter <- 1
}
}()
}
The cpu drop down to 0 % again.
from google-maps-services-go.
Yeah, NewClient really shouldn't be doing that.
A robust rate limiter is available at golang.org/x/time/rate. This package should probably just use (or copy) that one.
from google-maps-services-go.
Hi, do exiting test case cover rate limit logic ?
As when I run go test ./...
seems all of it has been passed in my local environment.
It is necessary for me to create a real client to call the library > rate limit in order to test the rate limit part ?
from google-maps-services-go.
@domesticmouse thank you very much !!!!!
from google-maps-services-go.
When using Google api in IE11, Edge or Firefox, the CPU is 30-50% + GPU 2-5%
Only in Chrome its work OK
from google-maps-services-go.
@AngelTs I doubt that a server side rate limiter would cause differentiated behavior between Chrome and IE11, Edge and Firefox. I'm guessing you are describing a Google Maps for JavaScript issue?
from google-maps-services-go.
Update: I found the BUG:
the freezing on IE11 and high usage of CPU in Edge and Firefox is occurred only if create table with many columns and rows (> of height of google map) and this table is normal but NOT responsive!.
Tested with default example https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple
plus normal table with 30 columns + 5 rows
[I want reward for this bug :):):)]
from google-maps-services-go.
Hey @AngelTs, you'll need to report it on the correct bug tracker for a start. Try filing it here instead. This bug tracker is for the Go client library for the Google Maps Web Services. Thanks!
from google-maps-services-go.
Thx man
from google-maps-services-go.
Related Issues (20)
- Directions API: Unmarshal error in detecting Route.Legs as type string HOT 1
- Go Version typo in readme HOT 1
- metrics.Request receives an already drained *http.Response HOT 2
- Is there a way to set range for radius parameters? HOT 2
- googleMap Error: connect ECONNREFUSED 0.0.0.0:443 HOT 1
- maps.Client Automatic Retry? Exponential Backoff? HOT 1
- Static maps map_id parameter support HOT 2
- feat: add relative_time_description property to PlaceReview HOT 2
- Places Search has no json tag HOT 1
- ReverseGeocode: invalid character 'U' looking for beginning of value HOT 2
- Empty spaces in the README for the go get command HOT 2
- Client.PlaceDetails fails for ID ChIJUXcBoFD-nkcR3s74TnqlDHM HOT 5
- ParsePlaceSearchFieldMask missing case for 'business_status' HOT 2
- Address Validation API missing HOT 3
- Need extra "new line character" for few postalcodes to geolocate them HOT 1
- New APIs: Address Validation, Datasets, Fleet Engine, new Places API, Routes API
- Add support for Address Descriptors to Geocoding
- @chomsin HOT 1
- @chomsin HOT 1
- Come and see β€ππXπploypoli streaming live on #BIGOLIVE and make new friends! https://slink.bigovideo.tv/BuIBpW ---γ 1 @chomsin HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-maps-services-go.